Skip to content

Commit

Permalink
Fix #4616. You can now create a new representation based off any othe…
Browse files Browse the repository at this point in the history
…r object. This makes it easy to custom model whatever you want as a starting point.
  • Loading branch information
Moult committed May 11, 2024
1 parent 3fa573e commit 55026ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/blenderbim/blenderbim/bim/module/geometry/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ class AddRepresentation(bpy.types.Operator, Operator):
"for Profile - 2D bounding box by local XZ axes.\n"
"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",
)

def _execute(self, context):
obj = context.active_object
props = obj.BIMGeometryProperties
ifc_context = int(props.contexts or "0") or None
props = context.scene.BIMGeometryProperties
oprops = obj.BIMGeometryProperties
ifc_context = int(oprops.contexts or "0") or None
if not ifc_context:
return
ifc_context = tool.Ifc.get().by_id(ifc_context)
Expand All @@ -167,6 +169,13 @@ def _execute(self, context):
else:
data = tool.Geometry.generate_3d_box_mesh(obj)
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:
core.add_representation(
Expand All @@ -192,6 +201,9 @@ def invoke(self, context, event):
def draw(self, context):
row = self.layout.row()
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):
Expand Down
1 change: 1 addition & 0 deletions src/blenderbim/blenderbim/bim/module/geometry/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ class BIMGeometryProperties(PropertyGroup):
name="IFC Interaction Mode",
update=update_mode,
)
representation_from_object: PointerProperty(type=bpy.types.Object)

0 comments on commit 55026ca

Please sign in to comment.