mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 07:42:41 +00:00
Add operator to toggle aggregate mode on and off.
This commit is contained in:
committed by
Bruno Perdigão
parent
ccdf1cee0a
commit
cbdbd5bd83
@@ -30,8 +30,9 @@ classes = (
|
|||||||
operator.BIM_OT_aggregate_unassign_object,
|
operator.BIM_OT_aggregate_unassign_object,
|
||||||
operator.BIM_OT_break_link_to_other_aggregates,
|
operator.BIM_OT_break_link_to_other_aggregates,
|
||||||
operator.BIM_OT_select_linked_aggregates,
|
operator.BIM_OT_select_linked_aggregates,
|
||||||
operator.BIM_OT_aggregate_mode_set_edit,
|
operator.BIM_OT_mode_set_aggregate,
|
||||||
operator.BIM_OT_disable_aggregate_mode_set_edit,
|
operator.BIM_OT_disable_mode_set_aggregate,
|
||||||
|
operator.BIM_OT_toggle_mode_set_aggregate,
|
||||||
prop.BIMObjectAggregateProperties,
|
prop.BIMObjectAggregateProperties,
|
||||||
prop.NotEditingObjects,
|
prop.NotEditingObjects,
|
||||||
prop.BIMAggregateProperties,
|
prop.BIMAggregateProperties,
|
||||||
@@ -39,12 +40,24 @@ classes = (
|
|||||||
ui.BIM_PT_linked_aggregate,
|
ui.BIM_PT_linked_aggregate,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
addon_keymaps = []
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.types.Object.BIMObjectAggregateProperties = bpy.props.PointerProperty(type=prop.BIMObjectAggregateProperties)
|
bpy.types.Object.BIMObjectAggregateProperties = bpy.props.PointerProperty(type=prop.BIMObjectAggregateProperties)
|
||||||
bpy.types.Scene.BIMAggregateProperties = bpy.props.PointerProperty(type=prop.BIMAggregateProperties)
|
bpy.types.Scene.BIMAggregateProperties = bpy.props.PointerProperty(type=prop.BIMAggregateProperties)
|
||||||
|
wm = bpy.context.window_manager
|
||||||
|
if wm.keyconfigs.addon:
|
||||||
|
km = wm.keyconfigs.addon.keymaps.new(name="Object Mode", space_type="EMPTY")
|
||||||
|
kmi = km.keymap_items.new("bim.toggle_mode_set_aggregate", "TAB", "PRESS", ctrl=True)
|
||||||
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
del bpy.types.Object.BIMObjectAggregateProperties
|
del bpy.types.Object.BIMObjectAggregateProperties
|
||||||
del bpy.types.Scene.BIMAggregateProperties
|
del bpy.types.Scene.BIMAggregateProperties
|
||||||
|
wm = bpy.context.window_manager
|
||||||
|
kc = wm.keyconfigs.addon
|
||||||
|
if kc:
|
||||||
|
for km, kmi in addon_keymaps:
|
||||||
|
km.keymap_items.remove(kmi)
|
||||||
|
addon_keymaps.clear()
|
||||||
|
|||||||
@@ -371,7 +371,34 @@ class BIM_OT_select_linked_aggregates(bpy.types.Operator):
|
|||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BIM_OT_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operator):
|
class BIM_OT_toggle_mode_set_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
bl_description = "Toggle Aggregate mode on and off"
|
||||||
|
bl_idname = "bim.toggle_mode_set_aggregate"
|
||||||
|
bl_label = "IFC Toggle Mode Set Aggregate"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
return IfcStore.execute_ifc_operator(self, context, is_invoke=True)
|
||||||
|
|
||||||
|
def _invoke(self, context, event):
|
||||||
|
if not tool.Ifc.get():
|
||||||
|
return {"FINISHED"}
|
||||||
|
return self.execute(context)
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
props = context.scene.BIMAggregateProperties
|
||||||
|
if props.in_aggregate_mode:
|
||||||
|
#AggregateModeDecorator.uninstall()
|
||||||
|
BIM_OT_disable_mode_set_aggregate._execute(self, context)
|
||||||
|
else:
|
||||||
|
#AggregateModeDecorator.install(context)
|
||||||
|
BIM_OT_mode_set_aggregate._execute(self, context)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_OT_mode_set_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_description = "Switch from Object to Aggregate Edit mode"
|
bl_description = "Switch from Object to Aggregate Edit mode"
|
||||||
bl_idname = "bim.aggregate_mode_set_edit"
|
bl_idname = "bim.aggregate_mode_set_edit"
|
||||||
bl_label = "IFC Aggregate Mode Set Edit"
|
bl_label = "IFC Aggregate Mode Set Edit"
|
||||||
@@ -388,8 +415,8 @@ class BIM_OT_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
active_object = context.active_object
|
active_object = context.active_object
|
||||||
props = context.scene.BIMAggregateProperties
|
props = context.scene.BIMAggregateProperties
|
||||||
if props.in_edit_mode == True:
|
if props.in_aggregate_mode:
|
||||||
BIM_OT_disable_aggregate_mode_set_edit._execute(self, context)
|
BIM_OT_disable_mode_set_aggregate._execute(self, context)
|
||||||
|
|
||||||
element = tool.Ifc.get_entity(active_object)
|
element = tool.Ifc.get_entity(active_object)
|
||||||
if not element:
|
if not element:
|
||||||
@@ -401,6 +428,7 @@ class BIM_OT_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if not parts:
|
if not parts:
|
||||||
parts = ifcopenshell.util.element.get_parts(aggregate)
|
parts = ifcopenshell.util.element.get_parts(aggregate)
|
||||||
if parts:
|
if parts:
|
||||||
|
props.editing_aggregate = tool.Ifc.get_object(aggregate) if aggregate else tool.Ifc.get_object(element)
|
||||||
parts_objs = [tool.Ifc.get_object(part) for part in parts]
|
parts_objs = [tool.Ifc.get_object(part) for part in parts]
|
||||||
objs = []
|
objs = []
|
||||||
visible_objects = tool.Raycast.get_visible_objects(context)
|
visible_objects = tool.Raycast.get_visible_objects(context)
|
||||||
@@ -416,10 +444,10 @@ class BIM_OT_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
not_editing_obj = props.not_editing_objects.add()
|
not_editing_obj = props.not_editing_objects.add()
|
||||||
not_editing_obj.obj = obj.original
|
not_editing_obj.obj = obj.original
|
||||||
|
|
||||||
props.in_edit_mode = True
|
props.in_aggregate_mode = True
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BIM_OT_disable_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operator):
|
class BIM_OT_disable_mode_set_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_description = "Switch from Aggregate to Object Edit mode"
|
bl_description = "Switch from Aggregate to Object Edit mode"
|
||||||
bl_idname = "bim.disable_aggregate_mode_set_edit"
|
bl_idname = "bim.disable_aggregate_mode_set_edit"
|
||||||
bl_label = "IFC Disable Aggregate Mode Set Edit"
|
bl_label = "IFC Disable Aggregate Mode Set Edit"
|
||||||
@@ -443,5 +471,5 @@ class BIM_OT_disable_aggregate_mode_set_edit(bpy.types.Operator, tool.Ifc.Operat
|
|||||||
if not element:
|
if not element:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
props.in_edit_mode = False
|
props.in_aggregate_mode = False
|
||||||
props.not_editing_objects.clear()
|
props.not_editing_objects.clear()
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ class NotEditingObjects(bpy.types.PropertyGroup):
|
|||||||
obj: PointerProperty(type=bpy.types.Object)
|
obj: PointerProperty(type=bpy.types.Object)
|
||||||
|
|
||||||
class BIMAggregateProperties(PropertyGroup):
|
class BIMAggregateProperties(PropertyGroup):
|
||||||
in_edit_mode: BoolProperty(name="In Edit Mode")
|
in_aggregate_mode: BoolProperty(name="In Edit Mode")
|
||||||
|
editing_aggregate: PointerProperty(name="Editing Aggregate", type=bpy.types.Object)
|
||||||
not_editing_objects: CollectionProperty(type=NotEditingObjects)
|
not_editing_objects: CollectionProperty(type=NotEditingObjects)
|
||||||
aggregate_decorator: BoolProperty(
|
aggregate_decorator: BoolProperty(
|
||||||
name="Display Aggregate",
|
name="Display Aggregate",
|
||||||
|
|||||||
@@ -2901,7 +2901,7 @@ class OverrideMoveAggregate(bpy.types.Operator):
|
|||||||
print("foi")
|
print("foi")
|
||||||
break
|
break
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if not element or props.in_edit_mode:
|
if not element or props.in_aggregate_mode:
|
||||||
continue
|
continue
|
||||||
aggregate = ifcopenshell.util.element.get_aggregate(element)
|
aggregate = ifcopenshell.util.element.get_aggregate(element)
|
||||||
if aggregate:
|
if aggregate:
|
||||||
|
|||||||
Reference in New Issue
Block a user