mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
spatial decomposition ui - use poll_message_set instead of .enabled
To give user more descriptive message about what's wrong.
This commit is contained in:
@@ -270,6 +270,18 @@ class DeleteContainer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
container: bpy.props.IntProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
props = tool.Spatial.get_spatial_props()
|
||||
active_container = props.active_container
|
||||
if not active_container:
|
||||
cls.poll_message_set("No active container.")
|
||||
return False
|
||||
if active_container.ifc_class == "IfcProject":
|
||||
cls.poll_message_set("Cannot delete IfcProject.")
|
||||
return False
|
||||
return True
|
||||
|
||||
def _execute(self, context):
|
||||
core.delete_container(tool.Ifc, tool.Spatial, tool.Geometry, container=tool.Ifc.get().by_id(self.container))
|
||||
|
||||
@@ -332,6 +344,18 @@ class SetDefaultContainer(bpy.types.Operator):
|
||||
bl_description = "Set this as the default container that all new elements will be contained in"
|
||||
container: bpy.props.IntProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
props = tool.Spatial.get_spatial_props()
|
||||
active_container = props.active_container
|
||||
if not active_container:
|
||||
cls.poll_message_set("No active container.")
|
||||
return False
|
||||
if active_container.ifc_class == "IfcProject":
|
||||
cls.poll_message_set("Cannot set default IfcProject as default container.")
|
||||
return False
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
core.set_default_container(tool.Spatial, container=tool.Ifc.get().by_id(self.container))
|
||||
core.set_orientation_slot(tool.Spatial, container=tool.Ifc.get().by_id(self.container))
|
||||
|
||||
@@ -143,10 +143,8 @@ class BIM_PT_spatial_decomposition(Panel):
|
||||
op.part_class = self.props.subelement_class
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
non_ifc_project_active = self.props.active_container.ifc_class != "IfcProject"
|
||||
|
||||
col = row.column(align=True)
|
||||
col.enabled = non_ifc_project_active
|
||||
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
|
||||
op.container = ifc_definition_id
|
||||
|
||||
@@ -155,7 +153,6 @@ class BIM_PT_spatial_decomposition(Panel):
|
||||
col.operator("bim.select_container", icon="OBJECT_DATA", text="").container = ifc_definition_id
|
||||
|
||||
col = row.column(align=True)
|
||||
col.enabled = non_ifc_project_active
|
||||
op = col.operator("bim.delete_container", icon="X", text="")
|
||||
op.container = ifc_definition_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user