Fix bug where pie update container didn't work.

This commit is contained in:
Dion Moult
2021-11-04 22:23:26 +11:00
parent 7fbe365599
commit 2b710ffbde
7 changed files with 34 additions and 16 deletions
@@ -17,6 +17,8 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>. # along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy import bpy
import blenderbim.tool as tool
import blenderbim.core.spatial
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
@@ -67,8 +69,8 @@ class PieUpdateContainer(bpy.types.Operator):
for collection in obj.users_collection: for collection in obj.users_collection:
spatial_obj = bpy.data.objects.get(collection.name) spatial_obj = bpy.data.objects.get(collection.name)
if spatial_obj and spatial_obj.BIMObjectProperties.ifc_definition_id: if spatial_obj and spatial_obj.BIMObjectProperties.ifc_definition_id:
bpy.ops.bim.assign_container( blenderbim.core.spatial.assign_container(
relating_structure=spatial_obj.BIMObjectProperties.ifc_definition_id, related_element=obj.name tool.Ifc, tool.Collector, tool.Spatial, structure_obj=spatial_obj, element_obj=obj
) )
break break
return {"FINISHED"} return {"FINISHED"}
@@ -24,7 +24,7 @@ classes = (
operator.ColourByAttribute, operator.ColourByAttribute,
operator.ColourByClass, operator.ColourByClass,
operator.ColourByPset, operator.ColourByPset,
operator.IfcTypeFilterSelectingAction, #Add selecting/deselecting all operator operator.ToggleFilterSelection,
operator.ResetObjectColours, operator.ResetObjectColours,
operator.SelectAttribute, operator.SelectAttribute,
operator.SelectGlobalId, operator.SelectGlobalId,
@@ -322,19 +322,22 @@ class ResetObjectColours(bpy.types.Operator):
obj.color = (1, 1, 1, 1) obj.color = (1, 1, 1, 1)
return {"FINISHED"} return {"FINISHED"}
class IfcTypeFilterSelectingAction(bpy.types.Operator):
class ToggleFilterSelection(bpy.types.Operator):
"Click to select/deselect all ifctype" "Click to select/deselect all ifctype"
bl_idname = "bim.ifctype_filter_selecting_action" bl_idname = "bim.toggle_filter_selection"
bl_label = "IfcType Filter Selecting Action" bl_label = "Toggle Filter Selection"
selecting_action: bpy.props.EnumProperty(items=( ("SELECT",'Select',"") , ("DESELECT","Deselect","") )) action: bpy.props.EnumProperty(items=(("SELECT", "Select", ""), ("DESELECT", "Deselect", "")))
def execute(self, context): def execute(self, context):
if self.selecting_action == "SELECT": if self.action == "SELECT":
self.selecting_actionbool = True self.selecting_actionbool = True
else: else:
self.selecting_actionbool = False self.selecting_actionbool = False
for ifcelement in bpy.context.scene.BIMSearchProperties.filter_classes: for ifcelement in bpy.context.scene.BIMSearchProperties.filter_classes:
ifcelement.is_selected = self.selecting_actionbool ifcelement.is_selected = self.selecting_actionbool
return {'FINISHED'} return {"FINISHED"}
class ActivateIfcTypeFilter(bpy.types.Operator): class ActivateIfcTypeFilter(bpy.types.Operator):
"It helps you to filter your selection by IFC class" "It helps you to filter your selection by IFC class"
@@ -371,8 +374,10 @@ class ActivateIfcTypeFilter(bpy.types.Operator):
"filter_classes", "filter_classes",
context.scene.BIMSearchProperties, context.scene.BIMSearchProperties,
"filter_classes_index", "filter_classes_index",
rows = 20 if len(bpy.context.scene.BIMSearchProperties.filter_classes) > 20 else len(bpy.context.scene.BIMSearchProperties.filter_classes), rows=20
if len(bpy.context.scene.BIMSearchProperties.filter_classes) > 20
else len(bpy.context.scene.BIMSearchProperties.filter_classes),
) )
row = self.layout.row() row = self.layout.row(align=True)
row.operator(IfcTypeFilterSelectingAction.bl_idname, text = "Select All").selecting_action = "SELECT" row.operator("bim.toggle_filter_selection", text="Select All").action = "SELECT"
row.operator(IfcTypeFilterSelectingAction.bl_idname, text = "Deselect All").selecting_action = "DESELECT" row.operator("bim.toggle_filter_selection", text="Deselect All").action = "DESELECT"
@@ -50,7 +50,7 @@ def update_is_selected(self, context):
class BIMFilterClasses(PropertyGroup): class BIMFilterClasses(PropertyGroup):
name: StringProperty(name="Name") name: StringProperty(name="Name")
is_selected: BoolProperty(name="Is Selected", default=True, update=update_is_selected) is_selected: BoolProperty(name="Is Selected", default=True, update=update_is_selected)
total: IntProperty(name="Total") total: IntProperty(name="Total")
unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects") unselected_objects: CollectionProperty(type=ObjProperty, name="Unfiltered Objects")
@@ -78,8 +78,10 @@ class BIM_UL_ifctype_filter(bpy.types.UIList):
split = layout split = layout
split.use_property_split = True split.use_property_split = True
split.use_property_decorate = False split.use_property_decorate = False
split.prop(item, "is_selected", text="", icon="CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT") split.prop(
item, "is_selected", text="", emboss=False, icon="CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT"
)
split.prop(item, "name", text="", emboss=False, slider=True) split.prop(item, "name", text="", emboss=False, slider=True)
split = split.column() split = split.column()
split.scale_x = 0.5 split.scale_x = 0.5
split.label(text=str(item.total)) split.label(text=str(item.total))
@@ -1141,6 +1141,7 @@ class ImportPP(bpy.types.Operator, ImportHelper):
print("Import finished in {:.2f} seconds".format(time.time() - start)) print("Import finished in {:.2f} seconds".format(time.time() - start))
return {"FINISHED"} return {"FINISHED"}
class ImportMSP(bpy.types.Operator, ImportHelper): class ImportMSP(bpy.types.Operator, ImportHelper):
bl_idname = "import_msp.bim" bl_idname = "import_msp.bim"
bl_label = "Import MSP" bl_label = "Import MSP"
@@ -37,3 +37,11 @@ Scenario: Add grid
And the object "IfcGridAxis/01" is an "IfcGridAxis" And the object "IfcGridAxis/01" is an "IfcGridAxis"
And the object "IfcGridAxis/02" is an "IfcGridAxis" And the object "IfcGridAxis/02" is an "IfcGridAxis"
And the object "IfcGridAxis/03" is an "IfcGridAxis" And the object "IfcGridAxis/03" is an "IfcGridAxis"
Scenario: Pie update container
Given an empty Blender session
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Then the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
When the object "IfcSlab/Slab" is placed in the collection "IfcBuildingStorey/Level 1"
And I press "bim.pie_update_container"
Then nothing happens