fixed bug removing representation item

if you'd click on "remove item" button for some item it wouldn't remove the corresponding item but would go for removing active item instead
This commit is contained in:
Andrej730
2024-02-02 14:53:10 +05:00
parent ad76c3ae82
commit 10ef4293f3
2 changed files with 5 additions and 3 deletions
@@ -1619,6 +1619,8 @@ class RemoveRepresentationItem(bpy.types.Operator, Operator):
bl_label = "Remove Representation Item"
bl_options = {"REGISTER", "UNDO"}
representation_item_id: bpy.props.IntProperty()
@classmethod
def poll(cls, context):
if context.active_object is None or len(context.active_object.BIMGeometryProperties.items) <= 1:
@@ -1633,8 +1635,7 @@ class RemoveRepresentationItem(bpy.types.Operator, Operator):
props = obj.BIMGeometryProperties
ifc_file = tool.Ifc.get()
representation_item_id = props.items[props.active_item_index].ifc_definition_id
representation_item = ifc_file.by_id(representation_item_id)
representation_item = ifc_file.by_id(self.representation_item_id)
tool.Geometry.remove_representation_item(representation_item)
tool.Geometry.reload_representation(obj)
@@ -510,4 +510,5 @@ class BIM_UL_representation_items(UIList):
row.label(text=item.name, icon=icon)
if item.layer:
row.label(text="", icon="STICKY_UVS_LOC")
row.operator("bim.remove_representation_item", icon="X", text="")
op = row.operator("bim.remove_representation_item", icon="X", text="")
op.representation_item_id = item.ifc_definition_id