mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Ctrl+P and Alt+P BIMTool Hotekys to assign/unassign aggregation
This commit is contained in:
@@ -47,7 +47,14 @@ class BIM_OT_assign_object(bpy.types.Operator, Operator):
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not element:
|
||||
continue
|
||||
relating_obj = tool.Ifc.get_object(tool.Ifc.get().by_id(self.relating_object))
|
||||
if self.relating_object:
|
||||
relating_obj = tool.Ifc.get_object(tool.Ifc.get().by_id(self.relating_object))
|
||||
else:
|
||||
if obj == context.active_object:
|
||||
continue
|
||||
relating_obj = context.active_object
|
||||
if not relating_obj:
|
||||
continue
|
||||
result = core.assign_object(
|
||||
tool.Ifc,
|
||||
tool.Aggregate,
|
||||
@@ -56,7 +63,7 @@ class BIM_OT_assign_object(bpy.types.Operator, Operator):
|
||||
related_obj=obj,
|
||||
)
|
||||
if not result:
|
||||
self.report({"ERROR"}, f"Objects {relating_obj} and {obj} cannot be aggregated")
|
||||
self.report({"ERROR"}, f" Cannot aggregate {obj.name} to {relating_obj.name}")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -509,6 +509,8 @@ def update_annotation_object_type(self, context):
|
||||
# changing enum doesn't trigger refresh by itself
|
||||
AnnotationData.is_loaded = False
|
||||
|
||||
def update_sheet_data(self, context):
|
||||
SheetsData.is_loaded = False
|
||||
|
||||
class BIMAnnotationProperties(PropertyGroup):
|
||||
object_type: bpy.props.EnumProperty(
|
||||
|
||||
@@ -126,7 +126,6 @@ classes = (
|
||||
pie.OpenPieClass,
|
||||
pie.PieUpdateContainer,
|
||||
pie.PieAddOpening,
|
||||
pie.PieAssignObjectAggregation,
|
||||
pie.VIEW3D_MT_PIE_bim,
|
||||
pie.VIEW3D_MT_PIE_bim_class,
|
||||
sverchok_modifier.CreateNewSverchokGraph,
|
||||
|
||||
@@ -76,22 +76,6 @@ class PieUpdateContainer(bpy.types.Operator):
|
||||
break
|
||||
return {"FINISHED"}
|
||||
|
||||
class PieAssignObjectAggregation(bpy.types.Operator,tool.Ifc.Operator):
|
||||
bl_idname = "bim.pie_assign_object_aggregation"
|
||||
bl_label = "Assign Parts to Active Object"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
for obj in context.selected_objects:
|
||||
if obj == context.active_object:
|
||||
continue
|
||||
blenderbim.core.aggregate.assign_object(
|
||||
tool.Ifc,
|
||||
tool.Aggregate,
|
||||
tool.Collector,
|
||||
relating_obj=context.active_object,
|
||||
related_obj=obj,
|
||||
)
|
||||
|
||||
class VIEW3D_MT_PIE_bim(bpy.types.Menu):
|
||||
bl_label = "Geometry"
|
||||
@@ -103,7 +87,8 @@ class VIEW3D_MT_PIE_bim(bpy.types.Menu):
|
||||
pie.operator("bim.pie_add_opening")
|
||||
pie.operator("bim.pie_update_container")
|
||||
pie.operator("bim.open_pie_class", text="Assign IFC Class")
|
||||
pie.operator("bim.pie_assign_object_aggregation", text ="Assign Aggregation")
|
||||
pie.operator("bim.assign_object", text ="Assign Aggregation")
|
||||
pie.operator("bim.unassign_object", text ="Unassign Aggregation")
|
||||
|
||||
|
||||
class VIEW3D_MT_PIE_bim_class(bpy.types.Menu):
|
||||
|
||||
@@ -62,6 +62,8 @@ class BimTool(WorkSpaceTool):
|
||||
("bim.hotkey", {"type": "D", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_D")]}),
|
||||
("bim.hotkey", {"type": "E", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_E")]}),
|
||||
("bim.hotkey", {"type": "O", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_O")]}),
|
||||
("bim.hotkey", {"type": "P", "value": "PRESS", "ctrl": True}, {"properties": [("hotkey", "C_P")]}),
|
||||
("bim.hotkey", {"type": "P", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_P")]}),
|
||||
)
|
||||
|
||||
def draw_settings(context, layout, ws_tool):
|
||||
@@ -404,6 +406,16 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
bpy.ops.bim.calculate_all_quantities()
|
||||
|
||||
def hotkey_C_P(self):
|
||||
if not bpy.context.selected_objects:
|
||||
return
|
||||
bpy.ops.bim.assign_object()
|
||||
|
||||
def hotkey_A_P(self):
|
||||
if not bpy.context.selected_objects:
|
||||
return
|
||||
bpy.ops.bim.unassign_object()
|
||||
|
||||
def hotkey_S_C(self):
|
||||
if not bpy.context.selected_objects:
|
||||
return
|
||||
|
||||
@@ -40,11 +40,16 @@ def assign_object(ifc, aggregator, collector, relating_obj=None, related_obj=Non
|
||||
def unassign_object(ifc, aggregate, collector, relating_obj=None, related_obj=None):
|
||||
related_element = ifc.get_entity(related_obj)
|
||||
container = aggregate.get_container(related_element)
|
||||
ifc.run("aggregate.unassign_object", product=related_element)
|
||||
if container:
|
||||
ifc.run("spatial.assign_container", product=related_element, relating_structure=container)
|
||||
collector.assign(relating_obj)
|
||||
collector.assign(related_obj)
|
||||
if not relating_obj:
|
||||
relating_element = aggregate.get_relating_object(related_element)
|
||||
if related_element:
|
||||
relating_obj = ifc.get_object(relating_element)
|
||||
if relating_obj:
|
||||
ifc.run("aggregate.unassign_object", product=related_element)
|
||||
if container:
|
||||
ifc.run("spatial.assign_container", product=related_element, relating_structure=container)
|
||||
collector.assign(relating_obj)
|
||||
collector.assign(related_obj)
|
||||
|
||||
|
||||
def add_part_to_object(ifc, aggregator, collector, blender, obj, part_class, part_name=None):
|
||||
|
||||
@@ -55,3 +55,9 @@ class Aggregate(blenderbim.core.tool.Aggregate):
|
||||
@classmethod
|
||||
def get_container(cls, element):
|
||||
return ifcopenshell.util.element.get_container(element)
|
||||
|
||||
@classmethod
|
||||
def get_relating_object(cls, related_element):
|
||||
for rel in related_element.Decomposes:
|
||||
if rel.is_a("IfcRelAggregates"):
|
||||
return rel.RelatingObject
|
||||
@@ -96,7 +96,7 @@ class Usecase:
|
||||
break
|
||||
|
||||
if decomposes and decomposes == is_decomposed_by:
|
||||
return
|
||||
return decomposes
|
||||
|
||||
container = ifcopenshell.util.element.get_container(self.settings["product"], should_get_direct=True)
|
||||
if container:
|
||||
|
||||
Reference in New Issue
Block a user