mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 08:45:22 +00:00
bim.add_representation - OBJECT method to use the final geometry
E.g. with all modifiers and shape keys applied. Example - https://imgur.com/a/rbf5RtI
This commit is contained in:
@@ -142,7 +142,14 @@ 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.",
|
||||||
),
|
),
|
||||||
("OBJECT", "From Object", "Copies geometry from another object"),
|
(
|
||||||
|
"OBJECT",
|
||||||
|
"From Object",
|
||||||
|
(
|
||||||
|
"Copies geometry from another object.\n"
|
||||||
|
"Final version of the geometry will be used (e.g. with all modifiers, shape keys applied)"
|
||||||
|
),
|
||||||
|
),
|
||||||
("PROJECT", "Full Representation", "Reuses the current representation"),
|
("PROJECT", "Full Representation", "Reuses the current representation"),
|
||||||
(
|
(
|
||||||
"CUBE",
|
"CUBE",
|
||||||
@@ -195,13 +202,13 @@ class AddRepresentation(bpy.types.Operator, Operator):
|
|||||||
tool.Geometry.change_object_data(obj, data, is_global=True)
|
tool.Geometry.change_object_data(obj, data, is_global=True)
|
||||||
elif conversion_method in ("OBJECT", "CUBE"):
|
elif conversion_method in ("OBJECT", "CUBE"):
|
||||||
if conversion_method == "OBJECT":
|
if conversion_method == "OBJECT":
|
||||||
if not props.representation_from_object:
|
if not (source_obj := props.representation_from_object):
|
||||||
self.report({"ERROR"}, "No object is selected to copy a representation from.")
|
self.report({"ERROR"}, "No object is selected to copy a representation from.")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
data_ = tool.Geometry.duplicate_object_data(props.representation_from_object)
|
depsgraph = context.evaluated_depsgraph_get()
|
||||||
assert isinstance(data_, bpy.types.Mesh) # Type checker.
|
eval_obj = source_obj.evaluated_get(depsgraph)
|
||||||
data = data_
|
data = bpy.data.meshes.new_from_object(eval_obj)
|
||||||
else: # CUBE
|
else: # CUBE
|
||||||
data = bpy.data.meshes.new("Cube")
|
data = bpy.data.meshes.new("Cube")
|
||||||
bm = tool.Blender.get_bmesh_for_mesh(data)
|
bm = tool.Blender.get_bmesh_for_mesh(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user