removed total_items from the operator

This commit is contained in:
Bruno Perdigão
2023-07-07 11:16:00 -03:00
committed by Dion Moult
parent 1afcec2005
commit 0ee5e3887b
2 changed files with 5 additions and 7 deletions
@@ -142,13 +142,9 @@ class RemoveArray(bpy.types.Operator, tool.Ifc.Operator):
bl_label = "Remove Array"
bl_options = {"REGISTER", "UNDO"}
item: bpy.props.IntProperty()
total_items: bpy.props.IntProperty()
keep_objs: bpy.props.BoolProperty(name="Keep Objects", default=False)
def _execute(self, context):
if (self.keep_objs) & (self.item < (self.total_items - 1)):
self.report({"INFO"}, "Keeping the objects is only allowed when you are removing the last Array of the object")
return {"FINISHED"}
obj = context.active_object
element = tool.Ifc.get_entity(obj)
props = obj.BIMArrayProperties
@@ -156,6 +152,10 @@ class RemoveArray(bpy.types.Operator, tool.Ifc.Operator):
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
data = json.loads(pset["Data"])
data[self.item]["count"] = 1
if (self.keep_objs) & (self.item < (len(data) - 1)):
self.report({"INFO"}, "Keeping the objects is only allowed when you are removing the last Array of the object")
return {"FINISHED"}
props.is_editing = -1
@@ -219,9 +219,7 @@ class BIM_PT_array(bpy.types.Panel):
name = f"{array['count']} Items ({array.get('method', 'OFFSET').capitalize()})"
row.label(text=name, icon="MOD_ARRAY")
row.operator("bim.enable_editing_array", icon="GREASEPENCIL", text="").item = i
op = row.operator("bim.remove_array", icon="X", text="")
op.item = i
op.total_items = len(ArrayData.data["parameters"]["data_dict"])
row.operator("bim.remove_array", icon="X", text="").item = i
row = box.row(align=True)
icon = "EMPTY_ARROWS" if array.get("use_local_space", False) else "EMPTY_AXIS"
row.label(text=f"X: {array['x']}", icon=icon)