diff --git a/src/bonsai/bonsai/core/drawing.py b/src/bonsai/bonsai/core/drawing.py index ed37fcb3b7..435319ed09 100644 --- a/src/bonsai/bonsai/core/drawing.py +++ b/src/bonsai/bonsai/core/drawing.py @@ -626,7 +626,8 @@ def sync_references( for reference_element in potential_reference_elements: if not drawing_tool.get_drawing_reference_annotation(drawing, reference_element): - if annotation := drawing_tool.generate_reference_annotation(drawing, reference_element, context): + annotation = drawing_tool.generate_reference_annotation(drawing, reference_element, context) + if annotation: ifc.run("drawing.assign_product", relating_product=reference_element, related_object=annotation) ifc.run("group.assign_group", group=group, products=[annotation]) collector.assign(ifc.get_object(annotation)) diff --git a/src/bonsai/bonsai/tool/collector.py b/src/bonsai/bonsai/tool/collector.py index 5fac35b170..756a851dec 100644 --- a/src/bonsai/bonsai/tool/collector.py +++ b/src/bonsai/bonsai/tool/collector.py @@ -120,7 +120,8 @@ class Collector(bonsai.core.tool.Collector): project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0]) cls.link_collection_child_safe(tool.Blender.get_object_bim_props(project_obj).collection, collection) elif element.is_a("IfcAnnotation") and (drawing_obj := cls.get_annotation_drawing_obj(element)): - cls.link_collection_object_safe(tool.Blender.get_object_bim_props(drawing_obj).collection, obj) + target_collection = tool.Blender.get_object_bim_props(drawing_obj).collection + cls.link_collection_object_safe(target_collection, obj) elif container := ifcopenshell.util.element.get_container(element): while container.is_a("IfcSpace"): container = ifcopenshell.util.element.get_aggregate(container) diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index c43aa9e73e..269e0ad35c 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -1958,14 +1958,19 @@ class Drawing(bonsai.core.tool.Drawing): geometry = ifcopenshell.geom.create_shape(settings, axis.AxisCurve) verts = ifcopenshell.util.shape.get_vertices(geometry) grid = (axis.PartOfU or axis.PartOfV or axis.PartOfW)[0] - m = ifcopenshell.util.placement.get_local_placement(grid.ObjectPlacement) + grid_obj = tool.Ifc.get_object(grid) + if grid_obj: + m = np.array(grid_obj.matrix_world) + else: + m = ifcopenshell.util.placement.get_local_placement(grid.ObjectPlacement) im = camera.matrix_world.inverted() v1, v2 = [im @ Vector((m @ np.append(v, 1.0))[:3]) for v in verts[:2]] target_view = tool.Drawing.get_drawing_target_view(drawing) if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW"): bounds = helper.ortho_view_frame(camera.data) - if not (points := helper.clip_segment(bounds, [v1, v2])): + points = helper.clip_segment(bounds, [v1, v2]) + if not points: return elif target_view in ("ELEVATION_VIEW", "SECTION_VIEW"): bounds = helper.ortho_view_frame(camera.data)