mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Change how new objects added are handled in aggregate mode.
When in aggregate mode, new objects will now be automatically assigned to the current aggregate.
This commit is contained in:
@@ -32,7 +32,6 @@ classes = (
|
||||
operator.BIM_OT_select_linked_aggregates,
|
||||
operator.BIM_OT_disable_aggregate_mode,
|
||||
operator.BIM_OT_toggle_aggregate_mode_local_view,
|
||||
operator.BIM_OT_aggregate_assign_new_objects_in_aggregate_mode,
|
||||
prop.BIMObjectAggregateProperties,
|
||||
prop.Objects,
|
||||
prop.BIMAggregateProperties,
|
||||
|
||||
@@ -327,33 +327,3 @@ class AggregateModeDecorator:
|
||||
indices, edges = create_bounding_box(parts_objs)
|
||||
self.line_shader.uniform_float("lineWidth", 0.5)
|
||||
self.draw_batch("LINES", indices, color, edges)
|
||||
|
||||
def draw_new_objects(self, context):
|
||||
if not context.scene.BIMAggregateProperties.in_aggregate_mode:
|
||||
return
|
||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||
self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
|
||||
self.line_shader.bind()
|
||||
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
||||
self.line_shader.uniform_float("lineWidth", 2.0)
|
||||
color = self.addon_prefs.decorator_color_unselected
|
||||
props = context.scene.BIMAggregateProperties
|
||||
editing_objects = set([o.obj for o in props.editing_objects])
|
||||
not_editing_objects = set([o.obj for o in props.not_editing_objects])
|
||||
objs = []
|
||||
visible_objects = tool.Raycast.get_visible_objects(context)
|
||||
for obj in visible_objects:
|
||||
if obj.visible_in_viewport_get(context.space_data):
|
||||
objs.append(obj.original)
|
||||
new_objs = set(objs) - not_editing_objects - editing_objects
|
||||
new_objs = [o for o in new_objs if o.data]
|
||||
for obj in new_objs:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if (aggregate := ifcopenshell.util.element.get_aggregate(element)) == tool.Ifc.get_entity(
|
||||
props.editing_aggregate
|
||||
):
|
||||
continue
|
||||
if element and element.is_a("IfcElement"):
|
||||
data = ItemDecorator.get_obj_data(obj)
|
||||
if data:
|
||||
self.draw_batch("TRIS", data["verts"], transparent_color((1, 0, 0, 1)), data["tris"])
|
||||
|
||||
@@ -401,43 +401,3 @@ class BIM_OT_toggle_aggregate_mode_local_view(bpy.types.Operator):
|
||||
bpy.ops.view3d.localview()
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class BIM_OT_aggregate_assign_new_objects_in_aggregate_mode(bpy.types.Operator):
|
||||
bl_idname = "bim.aggregate_assign_new_objects_in_aggregate_mode"
|
||||
bl_label = "Aggregate Assign New Objects In Aggregate Mode"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
relating_object: bpy.props.IntProperty()
|
||||
related_object: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
props = context.scene.BIMAggregateProperties
|
||||
editing_objects = set([o.obj for o in props.editing_objects])
|
||||
not_editing_objects = set([o.obj for o in props.not_editing_objects])
|
||||
objs = []
|
||||
visible_objects = tool.Raycast.get_visible_objects(context)
|
||||
for obj in visible_objects:
|
||||
if obj.visible_in_viewport_get(context.space_data):
|
||||
objs.append(obj.original)
|
||||
new_objs = set(objs) - not_editing_objects - editing_objects
|
||||
new_objs = [o for o in new_objs if o.data]
|
||||
for obj in new_objs:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if (aggregate := ifcopenshell.util.element.get_aggregate(element)) == tool.Ifc.get_entity(
|
||||
props.editing_aggregate
|
||||
):
|
||||
continue
|
||||
if element and element.is_a("IfcElement"):
|
||||
obj.select_set(True)
|
||||
editing_obj = props.editing_objects.add()
|
||||
editing_obj.obj = obj
|
||||
props.editing_aggregate.select_set(True)
|
||||
if new_objs:
|
||||
context.view_layer.objects.active = new_objs[0]
|
||||
self.relating_object = tool.Ifc.get_entity(props.editing_aggregate).id()
|
||||
self.related_object = tool.Ifc.get_entity(obj).id()
|
||||
|
||||
BIM_OT_aggregate_assign_object._execute(self, context)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -575,7 +575,6 @@ class EditObjectUI:
|
||||
row = cls.layout.row(align=True)
|
||||
op = row.operator("bim.disable_aggregate_mode", text="", icon="X")
|
||||
op = row.operator("bim.toggle_aggregate_mode_local_view", text="", icon="ZOOM_SELECTED")
|
||||
op = row.operator("bim.aggregate_assign_new_objects_in_aggregate_mode", text="", icon="CUBE")
|
||||
|
||||
text = format_ifc_camel_case(AuthoringData.data["active_class"])
|
||||
layout.label(text=f"{text} Edit Tools:", icon="RESTRICT_SELECT_OFF")
|
||||
|
||||
@@ -88,5 +88,7 @@ def assign_class(
|
||||
ifc.run("aggregate.assign_object", products=[element], relating_object=default_container)
|
||||
elif root.is_containable(element):
|
||||
ifc.run("spatial.assign_container", products=[element], relating_structure=default_container)
|
||||
if relating_obj := root.is_in_aggregate_mode(element):
|
||||
ifc.run("aggregate.assign_object", products=[element], relating_object=relating_obj)
|
||||
collector.assign(obj)
|
||||
return element
|
||||
|
||||
@@ -217,6 +217,12 @@ class Root(bonsai.core.tool.Root):
|
||||
def is_grid_axis(cls, element: ifcopenshell.entity_instance) -> bool:
|
||||
return element.is_a("IfcGridAxis")
|
||||
|
||||
@classmethod
|
||||
def is_in_aggregate_mode(cls, element: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||
props = bpy.context.scene.BIMAggregateProperties
|
||||
if props.editing_aggregate and props.in_aggregate_mode:
|
||||
return tool.Ifc.get_entity(props.editing_aggregate)
|
||||
|
||||
@classmethod
|
||||
def reload_grid_decorator(cls) -> None:
|
||||
axes = bpy.context.scene.BIMGridProperties.grid_axes
|
||||
|
||||
Reference in New Issue
Block a user