Have svg tags with IfcColumn/IfcBeam classes always on top.

discussion: https://community.osarch.org/discussion/2572/a-clever-way-to-get-a-column-buried-in-a-wall-to-still-read-when-you-print-a-drawing
This commit is contained in:
Ryan Schultz
2024-10-22 18:45:19 -05:00
parent 0c0225543b
commit f62b1ed326
@@ -748,9 +748,11 @@ class CreateDrawing(bpy.types.Operator):
self.remove_cut_linework(root)
self.generate_bisect_linework(context, root)
self.merge_linework_and_add_metadata(root)
self.move_elements_to_top(root)
elif self.camera.data.BIMCameraProperties.cut_mode == "OPENCASCADE":
self.move_projection_to_bottom(root)
self.merge_linework_and_add_metadata(root)
self.move_elements_to_top(root)
if self.camera.data.BIMCameraProperties.fill_mode == "SHAPELY":
# shapely variant
@@ -1314,6 +1316,22 @@ class CreateDrawing(bpy.types.Operator):
for projection in projections:
projection.getparent().remove(projection)
group.insert(0, projection)
def move_elements_to_top(self, root):
group = root.find("{http://www.w3.org/2000/svg}g")
#TODO: don't hardcode, make the following an assignable preference
classes_to_move = ['IfcColumn', 'IfcBeam']
xpath_query = " or ".join([f"contains(@class, '{name}')" for name in classes_to_move])
full_xpath = f".//svg:g[{xpath_query}]"
elements_to_top = root.xpath(full_xpath, namespaces={"svg": "http://www.w3.org/2000/svg"})
for element in elements_to_top:
element.getparent().remove(element)
group.append(element)
def generate_annotation(self, context: bpy.types.Context) -> Union[str, None]:
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasAnnotation"):