Including/Excluding IfcAnnotations from drawing #2903

Including or excluding elements from the drawing using EPset_Drawing.Include/Exclude now also works for IfcAnnotation elements. Both in viewport (on "activate view") and on svg print.

Related change - annotation decorations are now hidden in viewport if their object is hidden.
This commit is contained in:
Andrej730
2023-04-10 12:37:09 +05:00
parent d1dee1e908
commit 7623eddcd7
3 changed files with 26 additions and 8 deletions
@@ -159,9 +159,13 @@ class BaseDecorator:
"BATTING",
)
for obj in collection.all_objects:
if obj.hide_get():
continue
element = tool.Ifc.get_entity(obj)
if not element:
continue
if element.is_a("IfcAnnotation"):
if element.ObjectType == self.objecttype:
results.append(obj)
@@ -605,6 +605,9 @@ class CreateDrawing(bpy.types.Operator):
return svg_path
elements = tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(self.camera_element))
filtered_drawing_elements = tool.Drawing.get_drawing_elements(self.camera_element)
elements = [e for e in elements if e in filtered_drawing_elements]
annotations = sorted(elements, key=lambda a: tool.Drawing.get_annotation_z_index(a))
self.svg_writer.metadata = tool.Drawing.get_drawing_metadata(self.camera_element)
+19 -8
View File
@@ -1211,16 +1211,21 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def get_drawing_elements(cls, drawing):
"""returns a set of elements that are included in the drawing"""
ifc_file = tool.Ifc.get()
pset = ifcopenshell.util.element.get_psets(drawing).get("EPset_Drawing", {})
include = pset.get("Include", None)
if include:
elements = set(ifcopenshell.util.selector.Selector.parse(tool.Ifc.get(), include))
elements = set(ifcopenshell.util.selector.Selector.parse(ifc_file, include))
else:
elements = set(tool.Ifc.get().by_type("IfcElement"))
elements = set(ifc_file.by_type("IfcElement"))
annotations = tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(drawing))
elements.update(annotations)
exclude = pset.get("Exclude", None)
if exclude:
elements -= set(ifcopenshell.util.selector.Selector.parse(tool.Ifc.get(), exclude, elements=elements))
elements -= set(tool.Ifc.get().by_type("IfcOpeningElement"))
elements -= set(ifcopenshell.util.selector.Selector.parse(ifc_file, exclude, elements=elements))
elements -= set(ifc_file.by_type("IfcOpeningElement"))
return elements
@classmethod
@@ -1293,11 +1298,17 @@ class Drawing(blenderbim.core.tool.Drawing):
tool.Spatial.set_active_object(camera)
# sync viewport objects visibility with selectors from EPset_Drawing/Include and /Exclude
drawing_elements = cls.get_drawing_elements(tool.Ifc.get_entity(camera))
for element in tool.Ifc.get().by_type("IfcElement"):
ifc_file = tool.Ifc.get()
drawing = tool.Ifc.get_entity(camera)
all_drawing_elements = set(ifc_file.by_type("IfcElement"))
annotations = tool.Drawing.get_group_elements(tool.Drawing.get_drawing_group(drawing))
all_drawing_elements.update(annotations)
filtered_drawing_elements = cls.get_drawing_elements(drawing)
for element in all_drawing_elements:
if element.is_a() in ("IfcOpeningElement",):
continue
obj = tool.Ifc.get_object(element)
obj.hide_viewport = element not in drawing_elements
obj.hide_render = element not in drawing_elements
obj.hide_set(element not in filtered_drawing_elements)
obj.hide_render = element not in filtered_drawing_elements