prefix bim.assign/unassign_object to avoid operator override #4099

Co-Authored-By: Bruno Perdigão <57102715+brunoperdigao@users.noreply.github.com>
This commit is contained in:
Andrej730
2023-12-20 13:47:50 +05:00
parent 3d8de40407
commit 1652629332
8 changed files with 24 additions and 24 deletions
@@ -22,12 +22,12 @@ from . import ui, prop, operator
classes = ( classes = (
operator.BIM_OT_add_aggregate, operator.BIM_OT_add_aggregate,
operator.BIM_OT_add_part_to_object, operator.BIM_OT_add_part_to_object,
operator.BIM_OT_assign_object, operator.BIM_OT_aggregate_assign_object,
operator.BIM_OT_disable_editing_aggregate, operator.BIM_OT_disable_editing_aggregate,
operator.BIM_OT_enable_editing_aggregate, operator.BIM_OT_enable_editing_aggregate,
operator.BIM_OT_select_aggregate, operator.BIM_OT_select_aggregate,
operator.BIM_OT_select_parts, operator.BIM_OT_select_parts,
operator.BIM_OT_unassign_object, operator.BIM_OT_aggregate_unassign_object,
prop.BIMObjectAggregateProperties, prop.BIMObjectAggregateProperties,
ui.BIM_PT_aggregate, ui.BIM_PT_aggregate,
) )
@@ -33,11 +33,11 @@ class Operator:
return {"FINISHED"} return {"FINISHED"}
class BIM_OT_assign_object(bpy.types.Operator, Operator): class BIM_OT_aggregate_assign_object(bpy.types.Operator, Operator):
"""Create aggregation relationship between two ifc elements""" """Create aggregation relationship between two ifc elements"""
bl_idname = "bim.assign_object" bl_idname = "bim.aggregate_assign_object"
bl_label = "Assign Object" bl_label = "Assign Object To Aggregation"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
relating_object: bpy.props.IntProperty() relating_object: bpy.props.IntProperty()
@@ -67,11 +67,11 @@ class BIM_OT_assign_object(bpy.types.Operator, Operator):
self.report({"ERROR"}, f" Cannot aggregate {obj.name} to {relating_obj.name}") self.report({"ERROR"}, f" Cannot aggregate {obj.name} to {relating_obj.name}")
class BIM_OT_unassign_object(bpy.types.Operator, Operator): class BIM_OT_aggregate_unassign_object(bpy.types.Operator, Operator):
"""Remove aggregation relationship between two ifc elements""" """Remove aggregation relationship between two ifc elements"""
bl_idname = "bim.unassign_object" bl_idname = "bim.aggregate_unassign_object"
bl_label = "Unassign Object" bl_label = "Unassign Object From Aggregation"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
def _execute(self, context): def _execute(self, context):
@@ -54,7 +54,7 @@ class BIM_PT_aggregate(Panel):
row = layout.row(align=True) row = layout.row(align=True)
row.prop(props, "relating_object", text="") row.prop(props, "relating_object", text="")
if props.relating_object: if props.relating_object:
op = row.operator("bim.assign_object", icon="CHECKMARK", text="") op = row.operator("bim.aggregate_assign_object", icon="CHECKMARK", text="")
op.relating_object = props.relating_object.BIMObjectProperties.ifc_definition_id op.relating_object = props.relating_object.BIMObjectProperties.ifc_definition_id
row.operator("bim.disable_editing_aggregate", icon="CANCEL", text="") row.operator("bim.disable_editing_aggregate", icon="CANCEL", text="")
else: else:
@@ -65,7 +65,7 @@ class BIM_PT_aggregate(Panel):
op.obj = context.active_object.name op.obj = context.active_object.name
row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="")
row.operator("bim.add_aggregate", icon="ADD", text="") row.operator("bim.add_aggregate", icon="ADD", text="")
op = row.operator("bim.unassign_object", icon="X", text="") op = row.operator("bim.aggregate_unassign_object", icon="X", text="")
else: else:
row.label(text="No Aggregate", icon="TRIA_UP") row.label(text="No Aggregate", icon="TRIA_UP")
row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="")
@@ -87,8 +87,8 @@ class VIEW3D_MT_PIE_bim(bpy.types.Menu):
pie.operator("bim.pie_add_opening") pie.operator("bim.pie_add_opening")
pie.operator("bim.pie_update_container") pie.operator("bim.pie_update_container")
pie.operator("bim.open_pie_class", text="Assign IFC Class") pie.operator("bim.open_pie_class", text="Assign IFC Class")
pie.operator("bim.assign_object", text ="Assign Aggregation") pie.operator("bim.aggregate_assign_object", text="Assign Aggregation")
pie.operator("bim.unassign_object", text ="Unassign Aggregation") pie.operator("bim.aggregate_unassign_object", text="Unassign Aggregation")
class VIEW3D_MT_PIE_bim_class(bpy.types.Menu): class VIEW3D_MT_PIE_bim_class(bpy.types.Menu):
@@ -20,12 +20,12 @@ import bpy
from . import ui, prop, operator from . import ui, prop, operator
classes = ( classes = (
operator.BIM_OT_assign_object, operator.BIM_OT_nest_assign_object,
operator.BIM_OT_disable_editing_nest, operator.BIM_OT_disable_editing_nest,
operator.BIM_OT_enable_editing_nest, operator.BIM_OT_enable_editing_nest,
operator.BIM_OT_select_components, operator.BIM_OT_select_components,
operator.BIM_OT_select_nest, operator.BIM_OT_select_nest,
operator.BIM_OT_unassign_object, operator.BIM_OT_nest_unassign_object,
prop.BIMObjectNestProperties, prop.BIMObjectNestProperties,
ui.BIM_PT_nest, ui.BIM_PT_nest,
) )
@@ -33,11 +33,11 @@ class Operator:
return {"FINISHED"} return {"FINISHED"}
class BIM_OT_assign_object(bpy.types.Operator, Operator): class BIM_OT_nest_assign_object(bpy.types.Operator, Operator):
"""Create nest relationship between two ifc elements""" """Create nest relationship between two ifc elements"""
bl_idname = "bim.assign_object" bl_idname = "bim.nest_assign_object"
bl_label = "Assign Object" bl_label = "Assign Object To Nesting"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
relating_object: bpy.props.IntProperty() relating_object: bpy.props.IntProperty()
@@ -67,11 +67,11 @@ class BIM_OT_assign_object(bpy.types.Operator, Operator):
self.report({"ERROR"}, f" Cannot nest {obj.name} to {relating_obj.name}") self.report({"ERROR"}, f" Cannot nest {obj.name} to {relating_obj.name}")
class BIM_OT_unassign_object(bpy.types.Operator, Operator): class BIM_OT_nest_unassign_object(bpy.types.Operator, Operator):
"""Remove nest relationship between two ifc elements""" """Remove nest relationship between two ifc elements"""
bl_idname = "bim.unassign_object" bl_idname = "bim.nest_unassign_object"
bl_label = "Unassign Object" bl_label = "Unassign Object From Nesting"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
def _execute(self, context): def _execute(self, context):
@@ -54,7 +54,7 @@ class BIM_PT_nest(Panel):
row = layout.row(align=True) row = layout.row(align=True)
row.prop(props, "relating_object", text="") row.prop(props, "relating_object", text="")
if props.relating_object: if props.relating_object:
op = row.operator("bim.assign_object", icon="CHECKMARK", text="") op = row.operator("bim.nest_assign_object", icon="CHECKMARK", text="")
op.relating_object = props.relating_object.BIMObjectProperties.ifc_definition_id op.relating_object = props.relating_object.BIMObjectProperties.ifc_definition_id
row.operator("bim.disable_editing_nest", icon="CANCEL", text="") row.operator("bim.disable_editing_nest", icon="CANCEL", text="")
else: else:
@@ -64,7 +64,7 @@ class BIM_PT_nest(Panel):
op = row.operator("bim.select_nest", icon="RESTRICT_SELECT_OFF", text="") op = row.operator("bim.select_nest", icon="RESTRICT_SELECT_OFF", text="")
op.obj = context.active_object.name op.obj = context.active_object.name
row.operator("bim.enable_editing_nest", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_nest", icon="GREASEPENCIL", text="")
op = row.operator("bim.unassign_object", icon="X", text="") op = row.operator("bim.nest_unassign_object", icon="X", text="")
else: else:
row.label(text="No Host", icon="TRIA_UP") row.label(text="No Host", icon="TRIA_UP")
row.operator("bim.enable_editing_nest", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_nest", icon="GREASEPENCIL", text="")
@@ -33,7 +33,7 @@ Scenario: Unassign object
And the variable "relating_object" is "tool.Ifc.get().by_type('IfcSite')[0].id()" And the variable "relating_object" is "tool.Ifc.get().by_type('IfcSite')[0].id()"
And I press "bim.assign_object(relating_object={relating_object})" And I press "bim.assign_object(relating_object={relating_object})"
And the object "IfcBuildingStorey/My Storey" is selected And the object "IfcBuildingStorey/My Storey" is selected
When I press "bim.unassign_object" When I press "bim.aggregate_unassign_object"
Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site" Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey" And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey"
And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcProject/My Project" And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcProject/My Project"
@@ -54,7 +54,7 @@ Scenario: Unassign object - multiple objects are contained again to their indire
And I press "bim.add_aggregate(ifc_class='IfcWall')" And I press "bim.add_aggregate(ifc_class='IfcWall')"
And the object "IfcMember/Cube" is selected And the object "IfcMember/Cube" is selected
And additionally the object "IfcCovering/Cube" is selected And additionally the object "IfcCovering/Cube" is selected
When I press "bim.unassign_object" When I press "bim.aggregate_unassign_object"
Then the object "IfcMember/Cube" is in the collection "IfcBuildingStorey/My Storey" Then the object "IfcMember/Cube" is in the collection "IfcBuildingStorey/My Storey"
And the object "IfcCovering/Cube" is in the collection "IfcBuildingStorey/My Storey" And the object "IfcCovering/Cube" is in the collection "IfcBuildingStorey/My Storey"