mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
STAIR_ARROW annotations attached to IfcStairFlight object now readjusted after changes in IFC Stair modifier
Later probably will also need some other way to readjust annotations - so they can be readjusted for custom stairs, not created with modifier.
This commit is contained in:
@@ -678,6 +678,8 @@ class AddAnnotation(bpy.types.Operator, Operator):
|
||||
if not drawing:
|
||||
self.report({"WARNING"}, "Not a BIM camera")
|
||||
return
|
||||
# TODO: support adding multiple annotations if there are multiple selected objects
|
||||
# that can be used as annotations references
|
||||
r = core.add_annotation(tool.Ifc, tool.Collector, tool.Drawing, drawing=drawing, object_type=self.object_type)
|
||||
if isinstance(r, str):
|
||||
self.report({"WARNING"}, r)
|
||||
|
||||
@@ -286,7 +286,22 @@ def update_ifc_stair_props(obj):
|
||||
},
|
||||
)
|
||||
tool.Ifc.edit(obj)
|
||||
# TODO: update related STAIR_ARROW products
|
||||
|
||||
# update related annotation objects
|
||||
def get_elements_from_product(product):
|
||||
elements = []
|
||||
for rel in product.ReferencedBy:
|
||||
if not rel.is_a("IfcRelAssignsToProduct"):
|
||||
continue
|
||||
elements.extend(rel.RelatedObjects)
|
||||
return elements
|
||||
|
||||
stair_obj = obj
|
||||
for rel_element in get_elements_from_product(element):
|
||||
if not rel_element.is_a("IfcAnnotation") or rel_element.ObjectType != "STAIR_ARROW":
|
||||
continue
|
||||
if annotation_obj := tool.Ifc.get_object(rel_element):
|
||||
tool.Drawing.setup_annotation_object(annotation_obj, "STAIR_ARROW", stair_obj)
|
||||
|
||||
|
||||
class BIM_OT_add_clever_stair(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@@ -79,13 +79,19 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
return obj
|
||||
|
||||
# TODO: add a way for users to run this method to readjust the annotations
|
||||
# based on non-modifier stairs
|
||||
@classmethod
|
||||
def setup_annotation_object(cls, obj, object_type):
|
||||
def setup_annotation_object(cls, obj, object_type, related_object=None):
|
||||
"""Finish object's adjustments after both object and entity are created"""
|
||||
|
||||
if not related_object:
|
||||
related_object = bpy.context.active_object
|
||||
related_entity = tool.Ifc.get_entity(related_object)
|
||||
|
||||
if object_type == "STAIR_ARROW":
|
||||
stair = bpy.context.active_object
|
||||
stair_entity = tool.Ifc.get_entity(stair)
|
||||
if stair_entity and stair_entity.is_a("IfcStairFlight"):
|
||||
if related_entity and related_entity.is_a("IfcStairFlight"):
|
||||
stair, stair_entity = related_object, related_entity
|
||||
arrow = obj
|
||||
arrow_element = tool.Ifc.get_entity(arrow)
|
||||
arrow.parent = stair
|
||||
@@ -93,9 +99,11 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
# place the arrow
|
||||
bbox = tool.Blender.get_object_bounding_box(stair)
|
||||
arrow.location = Vector((bbox["min_x"], (bbox["max_y"] - bbox["min_y"]) / 2, bbox["max_z"]))
|
||||
arrow.data.splines[0].points[0].co = Vector((0, 0, 0, 1))
|
||||
arrow.data.splines[0].points[1].co = Vector((bbox["max_x"], 0, 0, 1))
|
||||
|
||||
tool.Ifc.run("drawing.assign_product", relating_product=stair_entity, related_object=arrow_element)
|
||||
if not cls.get_assigned_product(arrow_element):
|
||||
tool.Ifc.run("drawing.assign_product", relating_product=stair_entity, related_object=arrow_element)
|
||||
|
||||
@classmethod
|
||||
def create_camera(cls, name, matrix):
|
||||
|
||||
Reference in New Issue
Block a user