From 733e80737ae9af0d84077884c2ff1823b4be917c Mon Sep 17 00:00:00 2001 From: Gorgious Date: Sat, 23 Jul 2022 15:03:26 +0200 Subject: [PATCH 1/5] Fix error messages when using the search operator on blank file (F3) --- src/blenderbim/blenderbim/bim/module/bcf/operator.py | 2 ++ src/blenderbim/blenderbim/bim/module/bcf/prop.py | 2 +- src/blenderbim/blenderbim/bim/module/geometry/operator.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/bcf/operator.py b/src/blenderbim/blenderbim/bim/module/bcf/operator.py index 3ff328fe78..0cfacf9fa1 100644 --- a/src/blenderbim/blenderbim/bim/module/bcf/operator.py +++ b/src/blenderbim/blenderbim/bim/module/bcf/operator.py @@ -768,6 +768,8 @@ class ActivateBcfViewpoint(bpy.types.Operator): bcfxml = bcfstore.BcfStore.get_bcfxml() props = context.scene.BCFProperties blender_topic = props.active_topic + if blender_topic is None: + return False topic = bcfxml.topics[blender_topic.name] return topic.viewpoints diff --git a/src/blenderbim/blenderbim/bim/module/bcf/prop.py b/src/blenderbim/blenderbim/bim/module/bcf/prop.py index e24f5adba0..066982c67d 100644 --- a/src/blenderbim/blenderbim/bim/module/bcf/prop.py +++ b/src/blenderbim/blenderbim/bim/module/bcf/prop.py @@ -95,7 +95,7 @@ def getBcfViewpoints(self, context, force_update=False): props = context.scene.BCFProperties bcfxml = bcfstore.BcfStore.get_bcfxml() topic = props.active_topic - viewpoints = bcfxml.get_viewpoints(topic.name) + viewpoints = bcfxml.get_viewpoints(topic.name) if topic else {} bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())]) return bcfviewpoints_enum diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index 81b78dd4a2..99908cc927 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -132,7 +132,7 @@ class UpdateRepresentation(bpy.types.Operator): @classmethod def poll(cls, context): - return context.active_object.mode == "OBJECT" + return context.active_object and context.active_object.mode == "OBJECT" def execute(self, context): return IfcStore.execute_ifc_operator(self, context) @@ -240,7 +240,7 @@ class UpdateParametricRepresentation(bpy.types.Operator): @classmethod def poll(cls, context): - return context.active_object.mode == "OBJECT" + return context.active_object and context.active_object.mode == "OBJECT" def execute(self, context): self.file = IfcStore.get_file() From 5f7630e527cb5700f056a3e86e3c9ecba43362ba Mon Sep 17 00:00:00 2001 From: Vukas Pajic <83825269+vulevukusej@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:13:15 +0200 Subject: [PATCH 2/5] added test for creating new ifcgroups --- .../test/bim/feature/search.feature | 16 +++++++++++--- src/blenderbim/test/bim/test_feature.py | 21 ++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/blenderbim/test/bim/feature/search.feature b/src/blenderbim/test/bim/feature/search.feature index b4070cc05a..8fcf781ff1 100644 --- a/src/blenderbim/test/bim/feature/search.feature +++ b/src/blenderbim/test/bim/feature/search.feature @@ -7,11 +7,21 @@ Scenario: Select all walls And the object "Cube" is selected And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" - And I add a new group to IfcSelector - And I add a new query to IfcSelector + And I add a new item to "scene.IfcSelectorProperties.groups" + And I add a new item to "scene.IfcSelectorProperties.groups[0].queries" And I set "scene.IfcSelectorProperties.groups[0].queries[0].selector" to "IFC Class" And I set "scene.IfcSelectorProperties.groups[0].queries[0].active_option" to "124: IfcWall" When I press "bim.filter_model_elements(option='select')" Then the object "IfcWall/Cube" is selected - +Scenario: Add selection to IfcGroup + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" + And I press "bim.assign_class" + And I set "scene.IfcSelectorProperties.selector_query_syntax" to ".IfcWall" + And I set "scene.IfcSelectorProperties.manual_override" to "True" + When I press "bim.add_to_ifc_group(group_name='Walls')" + And I press "bim.load_groups" + Then "scene.BIMGroupProperties.groups[-1].name" is "Walls" diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index b56785404a..579930012f 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -88,7 +88,7 @@ def i_add_an_empty(): @given("I add a sun") -@when("I add an sun") +@when("I add a sun") def i_add_a_sun(): bpy.ops.object.light_add(type="SUN") @@ -98,15 +98,15 @@ def i_add_a_sun(): def i_add_a_material(): bpy.context.active_object.active_material = bpy.data.materials.new("Material") -@given("I add a new group to IfcSelector") -@when("I add a new group to IfcSelector") -def i_add_a_new_collection_item(): - bpy.data.scenes["Scene"].IfcSelectorProperties.groups.add() - -@given("I add a new query to IfcSelector") -@when("I add a new query to IfcSelector") -def i_add_a_new_collection_item(): - bpy.data.scenes["Scene"].IfcSelectorProperties.groups[0].queries.add() + +@given(parsers.parse('I add a new item to "{collection}"')) +@when(parsers.parse('I add a new item to "{collection}"')) +def i_add_a_new_collection_item(collection): + try: + eval(f"bpy.context.{collection}.add()") + except: + assert False, "Collection does not exist" + @given(parsers.parse('the material "{name}" colour is set to "{colour}"')) @when(parsers.parse('the material "{name}" colour is set to "{colour}"')) @@ -485,6 +485,7 @@ def prop_is_value(prop, value): except: pass if not is_value: + print(f"bpy.context.{prop}") actual_value = eval(f"bpy.context.{prop}") assert False, f"Value is {actual_value}" From 5f6c584a58d324acde974c8b07900ee849333d89 Mon Sep 17 00:00:00 2001 From: Vukas Pajic Date: Mon, 25 Jul 2022 12:25:55 +0200 Subject: [PATCH 3/5] fix error where prop name wasn't shown --- src/blenderbim/blenderbim/bim/module/pset/operator.py | 4 ++-- src/blenderbim/blenderbim/bim/module/pset/ui.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/pset/operator.py b/src/blenderbim/blenderbim/bim/module/pset/operator.py index e758230c82..0b1a523efe 100644 --- a/src/blenderbim/blenderbim/bim/module/pset/operator.py +++ b/src/blenderbim/blenderbim/bim/module/pset/operator.py @@ -209,8 +209,8 @@ class EnablePsetEditing(bpy.types.Operator): new.is_selected = enum in selected_enum_items else: value = prop["NominalValue"] - prop = self.props.properties.add() - metadata = prop.metadata + new_prop = self.props.properties.add() + metadata = new_prop.metadata metadata.set_value(value) metadata.name = prop["Name"] metadata.is_null = value is None diff --git a/src/blenderbim/blenderbim/bim/module/pset/ui.py b/src/blenderbim/blenderbim/bim/module/pset/ui.py index 2efe7e1167..a74ad6078f 100644 --- a/src/blenderbim/blenderbim/bim/module/pset/ui.py +++ b/src/blenderbim/blenderbim/bim/module/pset/ui.py @@ -41,7 +41,7 @@ def draw_property(prop, layout, copy_operator=None): def draw_single_property(prop, layout, copy_operator=None): value_name = prop.metadata.get_value_name() if not value_name: - layout.label(text=prop.metadata.name) + layout.label(text=prop["Name"]) return layout.prop( prop.metadata, From dc7062e182274ee30c9a1833d4b5828be0047012 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Mon, 25 Jul 2022 14:55:37 -0500 Subject: [PATCH 4/5] fix broken links in Documentation --- src/blenderbim/docs/devs/hello_world.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/docs/devs/hello_world.rst b/src/blenderbim/docs/devs/hello_world.rst index 8e88985edc..cba68bf5a9 100644 --- a/src/blenderbim/docs/devs/hello_world.rst +++ b/src/blenderbim/docs/devs/hello_world.rst @@ -63,7 +63,7 @@ architecture flow charts and diagrams. The code and its comments will guide you through the process. Before playing with the demo module, you may want to switch to using a source -installation. See `blenderbim/installation <./installation.rst>`_ for details. +installation. See `blenderbim/installation <./installation.html>`_ for details. To see the demo module in action, you'll need to enable it. In ``src/blenderbim/blenderbim/bim/__init__.py``, uncomment the line for the demo @@ -95,7 +95,7 @@ and how to test and structure it so that you can build incredibly complex features in a maintainable way. Tests for quality checking also exist. The system is designed so that you can -do "Test Driven Development". For reference on how to run these tests, see `blenderbim/running_tests <./running_tests.rst>`_ +do "Test Driven Development". For reference on how to run these tests, see `blenderbim/running_tests <./running_tests.html>`_ for details. You can find the tests here: :: From fafdc764944e6513e42e2a3b133d943d8a9180af Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 26 Jul 2022 09:29:57 +1000 Subject: [PATCH 5/5] Minor fix --- src/blenderbim/blenderbim/bim/module/project/operator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index f78f1858e1..58fcb3db30 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -678,7 +678,7 @@ class LinkIfc(bpy.types.Operator): if self.use_relative_path: filepath = os.path.relpath(filepath, bpy.path.abspath("//")) new.name = filepath - bpy.ops.bim.load_link(filepath=self.filepath) + bpy.ops.bim.load_link(filepath=filepath) return {"FINISHED"} def invoke(self, context, event):