bim.add_representation - OBJECT conversion method UX tweaks

1) Filter only objects with representations in the pointer property.
2) Add description to the pointer property.
3) More descriptive error if object is not selected.
This commit is contained in:
Andrej730
2024-07-03 12:27:04 +05:00
parent 2feae06ebd
commit e72f2758c6
2 changed files with 14 additions and 4 deletions
@@ -183,9 +183,11 @@ class AddRepresentation(bpy.types.Operator, Operator):
else:
data = tool.Geometry.generate_3d_box_mesh(obj)
tool.Geometry.change_object_data(obj, data, is_global=True)
elif (
conversion_method == "OBJECT" and props.representation_from_object and props.representation_from_object.data
):
elif conversion_method == "OBJECT":
if not props.representation_from_object:
self.report({"ERROR"}, "No object is selected to copy a representation from.")
return {"FINISHED"}
data = tool.Geometry.duplicate_object_data(props.representation_from_object)
tool.Geometry.change_object_data(obj, data, is_global=True)
@@ -136,4 +136,12 @@ class BIMGeometryProperties(PropertyGroup):
should_force_triangulation: BoolProperty(name="Force Triangulation", default=False)
is_changing_mode: BoolProperty(name="Is Changing Mode", default=False)
mode: EnumProperty(items=get_mode, name="IFC Interaction Mode", update=update_mode)
representation_from_object: PointerProperty(type=bpy.types.Object)
def is_object_valid_for_representation_copy(self, obj: bpy.types.Object) -> bool:
return bool(obj != bpy.context.active_object and obj.data)
representation_from_object: PointerProperty(
name="Object to copy a representation from.\nIt doesn't have to be an IFC object.",
type=bpy.types.Object,
poll=is_object_valid_for_representation_copy,
)