mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Fix #4616. You can now create a new representation based off any other object. This makes it easy to custom model whatever you want as a starting point.
This commit is contained in:
@@ -136,15 +136,17 @@ class AddRepresentation(bpy.types.Operator, Operator):
|
|||||||
"for Profile - 2D bounding box by local XZ axes.\n"
|
"for Profile - 2D bounding box by local XZ axes.\n"
|
||||||
"For other contexts - bounding box is 3d.",
|
"For other contexts - bounding box is 3d.",
|
||||||
),
|
),
|
||||||
("PROJECT", "Full Representation", ""),
|
("OBJECT", "From Object", "Copies geometry from another object"),
|
||||||
|
("PROJECT", "Full Representation", "Reuses the current representation"),
|
||||||
],
|
],
|
||||||
name="Representation Conversion Method",
|
name="Representation Conversion Method",
|
||||||
)
|
)
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
props = obj.BIMGeometryProperties
|
props = context.scene.BIMGeometryProperties
|
||||||
ifc_context = int(props.contexts or "0") or None
|
oprops = obj.BIMGeometryProperties
|
||||||
|
ifc_context = int(oprops.contexts or "0") or None
|
||||||
if not ifc_context:
|
if not ifc_context:
|
||||||
return
|
return
|
||||||
ifc_context = tool.Ifc.get().by_id(ifc_context)
|
ifc_context = tool.Ifc.get().by_id(ifc_context)
|
||||||
@@ -167,6 +169,13 @@ class AddRepresentation(bpy.types.Operator, Operator):
|
|||||||
else:
|
else:
|
||||||
data = tool.Geometry.generate_3d_box_mesh(obj)
|
data = tool.Geometry.generate_3d_box_mesh(obj)
|
||||||
tool.Geometry.change_object_data(obj, data, is_global=True)
|
tool.Geometry.change_object_data(obj, data, is_global=True)
|
||||||
|
elif (
|
||||||
|
self.representation_conversion_method == "OBJECT"
|
||||||
|
and props.representation_from_object
|
||||||
|
and props.representation_from_object.data
|
||||||
|
):
|
||||||
|
data = tool.Geometry.duplicate_object_data(props.representation_from_object)
|
||||||
|
tool.Geometry.change_object_data(obj, data, is_global=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
core.add_representation(
|
core.add_representation(
|
||||||
@@ -192,6 +201,9 @@ class AddRepresentation(bpy.types.Operator, Operator):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(self, "representation_conversion_method", text="")
|
row.prop(self, "representation_conversion_method", text="")
|
||||||
|
if self.representation_conversion_method == "OBJECT":
|
||||||
|
row = self.layout.row()
|
||||||
|
row.prop(context.scene.BIMGeometryProperties, "representation_from_object", text="")
|
||||||
|
|
||||||
|
|
||||||
class SelectConnection(bpy.types.Operator, Operator):
|
class SelectConnection(bpy.types.Operator, Operator):
|
||||||
|
|||||||
@@ -138,3 +138,4 @@ class BIMGeometryProperties(PropertyGroup):
|
|||||||
name="IFC Interaction Mode",
|
name="IFC Interaction Mode",
|
||||||
update=update_mode,
|
update=update_mode,
|
||||||
)
|
)
|
||||||
|
representation_from_object: PointerProperty(type=bpy.types.Object)
|
||||||
|
|||||||
Reference in New Issue
Block a user