From 9118e529e6f9aa53bfe188fdb40988641af60ec9 Mon Sep 17 00:00:00 2001 From: Massimo Fabbro Date: Sun, 23 Apr 2023 08:21:20 +0200 Subject: [PATCH] Add generate space button in UI in N-Panel -> BlenderBim -> Architectural --- .../blenderbim/bim/module/model/space.py | 15 ++++++++++++++- src/blenderbim/blenderbim/bim/module/model/ui.py | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/space.py b/src/blenderbim/blenderbim/bim/module/model/space.py index d58ed99162..02ae2596c9 100644 --- a/src/blenderbim/blenderbim/bim/module/model/space.py +++ b/src/blenderbim/blenderbim/bim/module/model/space.py @@ -33,6 +33,13 @@ class GenerateSpace(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.generate_space" bl_label = "Generate Space" bl_options = {"REGISTER"} + bl_description = "Create a space from the cursor position. Move the cursor position into the desired position, select the right space collection and run the operator" + + @classmethod + def poll(cls, context): + collection = context.view_layer.active_layer_collection.collection + collection_obj = bpy.data.objects.get(collection.name) + return tool.Ifc.get_entity(collection_obj) def _execute(self, context): # This only works based on a 2D plan only considering the standard @@ -177,9 +184,15 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator): @classmethod def poll(cls, context): - return context.selected_objects + active_obj = bpy.context.active_object + element = tool.Ifc.get_entity(active_obj) + return context.selected_objects and element.is_a("IfcWall") def _execute(self, context): + # This only works based on a 2D plan only considering the standard + # walls (i.e. prismatic) in the active object storey. + # In order to run, the active objct must be a wall and + # have to be selected walls props = context.scene.BIMModelProperties active_obj = bpy.context.active_object diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index 755ac76e17..dbae69fcdd 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -136,6 +136,8 @@ class BIM_PT_authoring(Panel): row.operator("bim.align_wall", icon="ANCHOR_CENTER", text="C/L").align_type = "CENTERLINE" row.operator("bim.align_wall", icon="ANCHOR_BOTTOM", text="Int.").align_type = "INTERIOR" row = self.layout.row(align=True) + row.operator("bim.generate_space") + row = self.layout.row(align=True) row.operator("bim.generate_spaces_from_walls")