#1153 Drawing titles now display IFC scale and identification data

This commit is contained in:
Dion Moult
2022-04-13 12:21:18 +10:00
parent 029b402d11
commit c099a6cb75
5 changed files with 46 additions and 27 deletions
@@ -70,7 +70,7 @@
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.96055365px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:center;text-anchor:middle;stroke-width:0.26458332px" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.96055365px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:center;text-anchor:middle;stroke-width:0.26458332px"
y="103.10933" y="103.10933"
x="32.822662" x="32.822662"
id="tspan857">{{no}}</tspan></text> id="tspan857">{{Identification}}</tspan></text>
<text <text
xml:space="preserve" xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.71626091px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458329px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.71626091px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458329px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -80,7 +80,7 @@
id="tspan861" id="tspan861"
x="39.12896" x="39.12896"
y="100.19173" y="100.19173"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325247px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:start;text-anchor:start;stroke-width:0.26458329px">{{name}}</tspan></text> style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325247px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:start;text-anchor:start;stroke-width:0.26458329px">{{Name}}</tspan></text>
<text <text
id="text867" id="text867"
y="105.0553" y="105.0553"
@@ -90,6 +90,6 @@
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325247px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:start;text-anchor:start;stroke-width:0.26458332px" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.54325247px;font-family:'OpenGost Type B TT';-inkscape-font-specification:'OpenGost Type B TT';text-align:start;text-anchor:start;stroke-width:0.26458332px"
y="105.0553" y="105.0553"
x="39.285267" x="39.285267"
id="tspan865">{{scale}}</tspan></text> id="tspan865">{{Scale}}</tspan></text>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

@@ -72,8 +72,10 @@ def update_diagram_scale(self, context):
scale = self.diagram_scale scale = self.diagram_scale
if scale == "CUSTOM": if scale == "CUSTOM":
scale = self.custom_diagram_scale scale = self.custom_diagram_scale
scale = scale.split("|")[1] if "|" not in scale:
element = tool.Ifc.get_entity(context.scene.camera) return
human_scale, scale = scale.split("|")
element = tool.Ifc.get_entity(context.scene.active_object)
if not element: if not element:
return return
pset = ifcopenshell.util.element.get_psets(element).get("EPset_Drawing") pset = ifcopenshell.util.element.get_psets(element).get("EPset_Drawing")
@@ -81,7 +83,9 @@ def update_diagram_scale(self, context):
pset = tool.Ifc.get().by_id(pset["id"]) pset = tool.Ifc.get().by_id(pset["id"])
else: else:
pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Drawing") pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Drawing")
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Scale": scale}) ifcopenshell.api.run(
"pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Scale": scale, "HumanScale": human_scale}
)
def get_diagram_scales(self, context): def get_diagram_scales(self, context):
@@ -180,7 +180,7 @@ class SheetBuilder:
root = tree.getroot() root = tree.getroot()
self.build_titleblock(root, sheet) self.build_titleblock(root, sheet)
self.build_drawings(root, sheet_name) self.build_drawings(root, sheet)
self.build_schedules(root.findall('{http://www.w3.org/2000/svg}g[@data-type="schedule"]')) self.build_schedules(root.findall('{http://www.w3.org/2000/svg}g[@data-type="schedule"]'))
with open(os.path.join(self.data_dir, "build", sheet_name, f"{sheet_name}.svg"), "wb") as output: with open(os.path.join(self.data_dir, "build", sheet_name, f"{sheet_name}.svg"), "wb") as output:
@@ -192,8 +192,15 @@ class SheetBuilder:
titleblock.append(self.parse_embedded_svg(image, sheet.get_info())) titleblock.append(self.parse_embedded_svg(image, sheet.get_info()))
titleblock.remove(image) titleblock.remove(image)
def build_drawings(self, root, sheet_name): def build_drawings(self, root, sheet):
sheet_name = tool.Drawing.get_sheet_filename(sheet)
references = tool.Drawing.get_document_references(sheet)
drawing_references = {tool.Drawing.get_reference_element(r): r for r in references}
for view in root.findall('{http://www.w3.org/2000/svg}g[@data-type="drawing"]'): for view in root.findall('{http://www.w3.org/2000/svg}g[@data-type="drawing"]'):
drawing = [d for d in drawing_references.keys() if d and d.GlobalId == view.attrib["data-guid"]][0]
reference = drawing_references[drawing]
images = view.findall("{http://www.w3.org/2000/svg}image") images = view.findall("{http://www.w3.org/2000/svg}image")
background = None background = None
@@ -208,8 +215,6 @@ class SheetBuilder:
elif image.attrib["data-type"] == "view-title": elif image.attrib["data-type"] == "view-title":
view_title = image view_title = image
self.scale = "NTS"
if foreground is not None: if foreground is not None:
view.append(self.parse_embedded_svg(foreground, {})) view.append(self.parse_embedded_svg(foreground, {}))
@@ -219,12 +224,11 @@ class SheetBuilder:
if view_title is not None: if view_title is not None:
foreground_path = self.get_href(foreground) foreground_path = self.get_href(foreground)
view.append( data = reference.get_info()
self.parse_embedded_svg( if not data["Name"]:
view_title, data["Name"] = ntpath.basename(foreground_path)[0:-4]
{"no": 1, "name": ntpath.basename(foreground_path)[0:-4], "scale": self.scale}, data["Scale"] = tool.Drawing.get_drawing_human_scale(drawing)
) view.append(self.parse_embedded_svg(view_title, data))
)
for image in images: for image in images:
view.remove(image) view.remove(image)
+1 -1
View File
@@ -115,7 +115,7 @@ def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
ifc.run("group.assign_group", group=group, product=element) ifc.run("group.assign_group", group=group, product=element)
collector.assign(camera) collector.assign(camera)
pset = ifc.run("pset.add_pset", product=element, name="EPset_Drawing") pset = ifc.run("pset.add_pset", product=element, name="EPset_Drawing")
ifc.run("pset.edit_pset", pset=pset, properties={"TargetView": target_view, "Scale": "1/100"}) ifc.run("pset.edit_pset", pset=pset, properties={"TargetView": target_view, "Scale": "1/100", "HumanScale": "1:100"})
drawing.import_drawings() drawing.import_drawings()
+21 -10
View File
@@ -291,24 +291,17 @@ class Drawing(blenderbim.core.tool.Drawing):
if not new.is_expanded: if not new.is_expanded:
continue continue
if tool.Ifc.get_schema() == "IFC2X3": for reference in cls.get_document_references(sheet):
references = sheet.DocumentReferences or []
else:
references = sheet.HasDocumentReferences or []
for reference in references:
new = props.sheets.add() new = props.sheets.add()
new.ifc_definition_id = reference.id() new.ifc_definition_id = reference.id()
new.is_sheet = False new.is_sheet = False
if tool.Ifc.get_schema() == "IFC2X3": if tool.Ifc.get_schema() == "IFC2X3":
new.identification = reference.ItemReference or "X" new.identification = reference.ItemReference or "X"
element = [
r for r in tool.Ifc.by_type("IfcRelAssociatesDocument") if r.RelatingDocument == reference
][0].RelatedObjects[0]
else: else:
new.identification = reference.Identification or "X" new.identification = reference.Identification or "X"
element = reference.DocumentRefForObjects[0].RelatedObjects[0]
element = cls.get_reference_element(reference)
new.name = element.Name new.name = element.Name
new.reference_type = "DRAWING" new.reference_type = "DRAWING"
@@ -720,3 +713,21 @@ class Drawing(blenderbim.core.tool.Drawing):
if grid_obj.matrix_world != obj.matrix_world: if grid_obj.matrix_world != obj.matrix_world:
bpy.ops.bim.update_representation(obj=obj.name) bpy.ops.bim.update_representation(obj=obj.name)
tool.Geometry.record_object_position(obj) tool.Geometry.record_object_position(obj)
@classmethod
def get_document_references(cls, document):
if tool.Ifc.get_schema() == "IFC2X3":
return document.DocumentReferences or []
return document.HasDocumentReferences or []
@classmethod
def get_reference_element(cls, reference):
if tool.Ifc.get_schema() == "IFC2X3":
return [
r for r in tool.Ifc.by_type("IfcRelAssociatesDocument") if r.RelatingDocument == reference
][0].RelatedObjects[0]
return reference.DocumentRefForObjects[0].RelatedObjects[0]
@classmethod
def get_drawing_human_scale(cls, drawing):
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"]["HumanScale"]