mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
You can now eyedrop an object in the viewport to copy container when editing container
This commit is contained in:
@@ -57,6 +57,25 @@ def updateContainerName(self, context):
|
|||||||
props.container_name = self.name
|
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):
|
class SpatialElement(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
long_name: StringProperty(name="Long Name")
|
long_name: StringProperty(name="Long Name")
|
||||||
@@ -73,6 +92,13 @@ class BIMSpatialProperties(PropertyGroup):
|
|||||||
|
|
||||||
class BIMObjectSpatialProperties(PropertyGroup):
|
class BIMObjectSpatialProperties(PropertyGroup):
|
||||||
is_editing: BoolProperty(name="Is Editing")
|
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):
|
class BIMContainer(PropertyGroup):
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class BIM_PT_spatial(Panel):
|
|||||||
row.operator("bim.disable_editing_container", icon="CANCEL", text="")
|
row.operator("bim.disable_editing_container", icon="CANCEL", text="")
|
||||||
|
|
||||||
self.layout.template_list("BIM_UL_containers", "", props, "containers", props, "active_container_index")
|
self.layout.template_list("BIM_UL_containers", "", props, "containers", props, "active_container_index")
|
||||||
|
self.layout.prop(osprops, "relating_container_object")
|
||||||
else:
|
else:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if SpatialData.data["label"]:
|
if SpatialData.data["label"]:
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Spatial(blenderbim.core.tool.Spatial):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def enable_editing(cls, obj):
|
def enable_editing(cls, obj):
|
||||||
obj.BIMObjectSpatialProperties.is_editing = True
|
obj.BIMObjectSpatialProperties.is_editing = True
|
||||||
|
obj.BIMObjectSpatialProperties.relating_container_object = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_container(cls, element):
|
def get_container(cls, element):
|
||||||
|
|||||||
Reference in New Issue
Block a user