diff --git a/src/bonsai/bonsai/bim/operator.py b/src/bonsai/bonsai/bim/operator.py index a3f58d1c44..ffe2e4f662 100644 --- a/src/bonsai/bonsai/bim/operator.py +++ b/src/bonsai/bonsai/bim/operator.py @@ -260,7 +260,6 @@ class SaveBlendMetadataFile(bpy.types.Operator): self.report({"WARNING"}, "No IFC file path set.") return {"CANCELLED"} - blendmetadata_path = ifc_file + ".metadata.blend" ifc_dir = os.path.dirname(ifc_file) @@ -332,12 +331,14 @@ except Exception: bpy.ops.wm.save_as_mainfile(filepath=r'{blendmetadata_path}') """ import tempfile + with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as script_file: script_file.write(cleanup_script) script_path = script_file.name blender_exe = bpy.app.binary_path import subprocess + result = subprocess.run( [blender_exe, temp_path, "--background", "--python", script_path], capture_output=True, text=True ) diff --git a/src/bonsai/bonsai/core/drawing.py b/src/bonsai/bonsai/core/drawing.py index 118fc3b69c..fd721cd4be 100644 --- a/src/bonsai/bonsai/core/drawing.py +++ b/src/bonsai/bonsai/core/drawing.py @@ -488,28 +488,28 @@ def sync_references( for element in potential_reference_elements: # Skip spatial elements - their IFC placement is the source of truth - if element.is_a("IfcSpatialElement"): + if element.is_a("IfcSpatialElement"): continue - + # Skip grids - their IFC placement is the source of truth if element.is_a("IfcGrid") or element.is_a("IfcGridAxis"): continue - + if (obj := ifc.get_object(element)) and ifc.is_moved(obj): drawing_tool.sync_object_placement(obj) for element in drawing_tool.get_group_elements(group): if not drawing_tool.is_auto_annotation(element): continue - + # Skip spatial elements - should never sync their placement if element.is_a("IfcSpatialElement"): continue - + # Skip grids if element.is_a("IfcGrid") or element.is_a("IfcGridAxis"): - continue - + continue + if (obj := ifc.get_object(element)) and ifc.is_moved(obj): drawing_tool.sync_object_placement(obj) if not (reference_element := drawing_tool.get_assigned_product(element)):