#1153 Fix bugs with importing existing annotations

This commit is contained in:
Dion Moult
2022-04-18 10:26:03 +10:00
parent f70ab060e3
commit ca502cc293
2 changed files with 14 additions and 27 deletions
+8 -23
View File
@@ -1509,9 +1509,10 @@ class IfcImporter:
return self.structural_member_collection.objects.link(obj) return self.structural_member_collection.objects.link(obj)
elif element.is_a("IfcStructuralConnection"): elif element.is_a("IfcStructuralConnection"):
return self.structural_connection_collection.objects.link(obj) return self.structural_connection_collection.objects.link(obj)
elif element.is_a("IfcAnnotation") and self.is_drawing_annotation(element): elif element.is_a("IfcAnnotation"):
group = [r for r in element.HasAssignments if r.is_a("IfcRelAssignsToGroup")][0].RelatingGroup group = self.get_drawing_group(element)
return self.collections[group.GlobalId].objects.link(obj) if group:
return self.collections[group.GlobalId].objects.link(obj)
container = ifcopenshell.util.element.get_container(element) container = ifcopenshell.util.element.get_container(element)
if container: if container:
@@ -1531,32 +1532,16 @@ class IfcImporter:
return element.ObjectType in [ return element.ObjectType in [
"DIMENSION", "DIMENSION",
"EQUAL_DIMENSION", "EQUAL_DIMENSION",
"MISC",
"PLAN_LEVEL", "PLAN_LEVEL",
"SECTION_LEVEL", "SECTION_LEVEL",
"STAIR_ARROW", "STAIR_ARROW",
"TEXT_LEADER", "TEXT_LEADER",
] ]
def is_drawing_annotation(self, element): def get_drawing_group(self, element):
return element.ObjectType in [ for rel in element.HasAssignments or []:
"BREAKLINE", if rel.is_a("IfcRelAssignsToGroup"):
"DIMENSION", return rel.RelatingGroup
"DRAWING",
"EQUAL_DIMENSION",
"GRID",
"HIDDEN_LINE",
"MISC",
"PLAN_LEVEL",
"SECTION_LEVEL",
"STAIR_ARROW",
"TEXT",
"TEXT_LEADER",
"LEADER",
"HATCH",
"LINEWORK",
"AREA",
]
def get_element_matrix(self, element): def get_element_matrix(self, element):
result = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) result = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement)
@@ -442,13 +442,15 @@ class CreateDrawing(bpy.types.Operator):
svg_writer.camera_height = height svg_writer.camera_height = height
svg_writer.camera_projection = tuple(camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))) svg_writer.camera_projection = tuple(camera.matrix_world.to_quaternion() @ Vector((0, 0, -1)))
for obj in camera.users_collection[0].objects: for element in tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(self.camera_element)):
if "IfcAnnotation/" not in obj.name: if not element.is_a("IfcAnnotation"):
continue
obj = tool.Ifc.get_object(element)
if not obj:
continue continue
element = tool.Ifc.get_entity(obj)
if element.ObjectType == "GRID": if element.ObjectType == "GRID":
svg_writer.annotations.setdefault("grid_objs", []).append(obj) svg_writer.annotations.setdefault("grid_objs", []).append(obj)
elif obj.type == "CAMERA": elif element.ObjectType == "DRAWING":
continue continue
elif element.ObjectType == "TEXT_LEADER": elif element.ObjectType == "TEXT_LEADER":
svg_writer.annotations.setdefault("leader_objs", []).append(obj) svg_writer.annotations.setdefault("leader_objs", []).append(obj)