Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 55026ca

Browse files
committed
Fix IfcOpenShell#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.
1 parent 3fa573e commit 55026ca

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/blenderbim/blenderbim/bim/module/geometry/operator.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ class AddRepresentation(bpy.types.Operator, Operator):
136136
"for Profile - 2D bounding box by local XZ axes.\n"
137137
"For other contexts - bounding box is 3d.",
138138
),
139-
("PROJECT", "Full Representation", ""),
139+
("OBJECT", "From Object", "Copies geometry from another object"),
140+
("PROJECT", "Full Representation", "Reuses the current representation"),
140141
],
141142
name="Representation Conversion Method",
142143
)
143144

144145
def _execute(self, context):
145146
obj = context.active_object
146-
props = obj.BIMGeometryProperties
147-
ifc_context = int(props.contexts or "0") or None
147+
props = context.scene.BIMGeometryProperties
148+
oprops = obj.BIMGeometryProperties
149+
ifc_context = int(oprops.contexts or "0") or None
148150
if not ifc_context:
149151
return
150152
ifc_context = tool.Ifc.get().by_id(ifc_context)
@@ -167,6 +169,13 @@ def _execute(self, context):
167169
else:
168170
data = tool.Geometry.generate_3d_box_mesh(obj)
169171
tool.Geometry.change_object_data(obj, data, is_global=True)
172+
elif (
173+
self.representation_conversion_method == "OBJECT"
174+
and props.representation_from_object
175+
and props.representation_from_object.data
176+
):
177+
data = tool.Geometry.duplicate_object_data(props.representation_from_object)
178+
tool.Geometry.change_object_data(obj, data, is_global=True)
170179

171180
try:
172181
core.add_representation(
@@ -192,6 +201,9 @@ def invoke(self, context, event):
192201
def draw(self, context):
193202
row = self.layout.row()
194203
row.prop(self, "representation_conversion_method", text="")
204+
if self.representation_conversion_method == "OBJECT":
205+
row = self.layout.row()
206+
row.prop(context.scene.BIMGeometryProperties, "representation_from_object", text="")
195207

196208

197209
class SelectConnection(bpy.types.Operator, Operator):

src/blenderbim/blenderbim/bim/module/geometry/prop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ class BIMGeometryProperties(PropertyGroup):
138138
name="IFC Interaction Mode",
139139
update=update_mode,
140140
)
141+
representation_from_object: PointerProperty(type=bpy.types.Object)

0 commit comments

Comments
 (0)