From e20e286168092ce52d1ea8da417a60f66c7f50d0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 16 Feb 2026 18:25:54 +1100 Subject: [PATCH] Revert "feat(drawing): support multiple file selection in Add Reference" This reverts commit cf5ffad9af7dc911d1a3c9a90767fb8c950f7dbc. --- .../bonsai/bim/module/drawing/operator.py | 15 +--- src/bonsai/test/tool/test_drawing.py | 68 ------------------- 2 files changed, 2 insertions(+), 81 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 2f858a9d9e..abc6bbfb5c 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -3094,20 +3094,9 @@ class AddReference(bpy.types.Operator, tool.Ifc.Operator, ImportHelper): use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=True) filename_ext = ".svg" - files: bpy.props.CollectionProperty(type=bpy.types.OperatorFileListElement) - directory: bpy.props.StringProperty(subtype="DIR_PATH") - def _execute(self, context): - # Handle both single and multiple file selection - if self.files: - for file_elem in self.files: - filepath = os.path.join(self.directory, file_elem.name) - uri = tool.Ifc.get_uri(filepath, use_relative_path=self.use_relative_path) - core.add_document(tool.Ifc, tool.Drawing, "REFERENCE", uri=uri) - else: - # Fallback for single file (backward compatibility) - filepath = tool.Ifc.get_uri(self.filepath, use_relative_path=self.use_relative_path) - core.add_document(tool.Ifc, tool.Drawing, "REFERENCE", uri=filepath) + filepath = tool.Ifc.get_uri(self.filepath, use_relative_path=self.use_relative_path) + core.add_document(tool.Ifc, tool.Drawing, "REFERENCE", uri=filepath) class RemoveReference(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/test/tool/test_drawing.py b/src/bonsai/test/tool/test_drawing.py index 532186d7ff..8501b5b9ea 100644 --- a/src/bonsai/test/tool/test_drawing.py +++ b/src/bonsai/test/tool/test_drawing.py @@ -958,71 +958,3 @@ class TestAddReferenceImage(NewFile): uv_node = material_nodes["Texture Coordinate"] assert len(uv_node.outputs["Generated"].links[:]) == 1 - - -class TestAddReference(NewFile): - def test_add_single_reference(self): - """Test adding a single reference file (backward compatibility)""" - bpy.ops.bim.create_project() - ifc_path = Path("test/files/temp/test.ifc").absolute() - bpy.ops.bim.save_project(filepath=str(ifc_path), should_save_as=True) - - # Create a temporary SVG file - svg_path = Path("test/files/temp/reference.svg").absolute() - svg_path.parent.mkdir(parents=True, exist_ok=True) - with open(svg_path, "w") as f: - f.write('') - - try: - # Add single reference - bpy.ops.bim.add_reference(filepath=str(svg_path)) - - # Verify reference was added - ifc = tool.Ifc.get() - references = [doc for doc in ifc.by_type("IfcDocumentInformation") if doc.Scope == "REFERENCE"] - assert len(references) == 1 - assert references[0].Name == "reference" - finally: - # Cleanup - if svg_path.exists(): - svg_path.unlink() - - def test_add_multiple_references(self): - """Test adding multiple reference files at once""" - bpy.ops.bim.create_project() - ifc_path = Path("test/files/temp/test.ifc").absolute() - bpy.ops.bim.save_project(filepath=str(ifc_path), should_save_as=True) - - # Create temporary SVG files - temp_dir = Path("test/files/temp").absolute() - temp_dir.mkdir(parents=True, exist_ok=True) - - svg_files = [] - for i in range(3): - svg_path = temp_dir / f"reference_{i}.svg" - with open(svg_path, "w") as f: - f.write('') - svg_files.append(svg_path) - - try: - # Test by directly calling core.add_document multiple times - # (simulating what the operator does with multiple files) - ifc = tool.Ifc.get() - for svg_file in svg_files: - uri = tool.Ifc.get_uri(str(svg_file), use_relative_path=True) - from bonsai.bim import core - - core.drawing.add_document(tool.Ifc, tool.Drawing, "REFERENCE", uri=uri) - - # Verify all references were added - references = [doc for doc in ifc.by_type("IfcDocumentInformation") if doc.Scope == "REFERENCE"] - assert len(references) == 3 - - reference_names = {ref.Name for ref in references} - expected_names = {f"reference_{i}" for i in range(3)} - assert reference_names == expected_names - finally: - # Cleanup - for svg_file in svg_files: - if svg_file.exists(): - svg_file.unlink()