You can now eyedrop an object in the viewport to copy container when editing container

This commit is contained in:
Gorgious56
2023-10-31 11:14:54 +01:00
parent 3b3668eedf
commit b42f072bd5
3 changed files with 28 additions and 0 deletions
@@ -57,6 +57,25 @@ def updateContainerName(self, context):
props.container_name = self.name
def update_relating_container_from_object(self, context):
if self.relating_container_object is None or context.active_object is None:
return
element = tool.Ifc.get_entity(self.relating_container_object)
if not element:
return
container = ifcopenshell.util.element.get_container(element)
if container:
bpy.ops.bim.assign_container(structure=container.id())
else:
bpy.ops.bim.disable_editing_container()
bpy.ops.bim.remove_container()
def is_object_applicable(self, obj):
element = tool.Ifc.get_entity(obj)
return bool(element)
class SpatialElement(PropertyGroup):
name: StringProperty(name="Name")
long_name: StringProperty(name="Long Name")
@@ -73,6 +92,13 @@ class BIMSpatialProperties(PropertyGroup):
class BIMObjectSpatialProperties(PropertyGroup):
is_editing: BoolProperty(name="Is Editing")
relating_container_object: PointerProperty(
type=bpy.types.Object,
name="Copy Container",
update=update_relating_container_from_object,
poll=is_object_applicable,
description="Copy the target object's container to the active object",
)
class BIMContainer(PropertyGroup):
@@ -62,6 +62,7 @@ class BIM_PT_spatial(Panel):
row.operator("bim.disable_editing_container", icon="CANCEL", text="")
self.layout.template_list("BIM_UL_containers", "", props, "containers", props, "active_container_index")
self.layout.prop(osprops, "relating_container_object")
else:
row = self.layout.row(align=True)
if SpatialData.data["label"]:
@@ -78,6 +78,7 @@ class Spatial(blenderbim.core.tool.Spatial):
@classmethod
def enable_editing(cls, obj):
obj.BIMObjectSpatialProperties.is_editing = True
obj.BIMObjectSpatialProperties.relating_container_object = None
@classmethod
def get_container(cls, element):