Fix #2980. Minor cleanup to polish array panel UI.

This commit is contained in:
Dion Moult
2023-04-15 16:01:50 +10:00
parent 156269a53f
commit 7371efde17
4 changed files with 16 additions and 21 deletions
@@ -42,7 +42,7 @@ class AddArray(bpy.types.Operator, tool.Ifc.Operator):
"z": 0.0, "z": 0.0,
"use_local_space": True, "use_local_space": True,
"sync_children": False, "sync_children": False,
"dimension_input_type": "Increment", "method": "OFFSET",
} }
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array") pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
@@ -91,7 +91,7 @@ class EnableEditingArray(bpy.types.Operator, tool.Ifc.Operator):
props.z = data["z"] props.z = data["z"]
props.use_local_space = data.get("use_local_space", False) props.use_local_space = data.get("use_local_space", False)
props.sync_children = data.get("sync_children", False) props.sync_children = data.get("sync_children", False)
props.dimension_input_type = data.get("dimension_input_type", "Increment") props.method = data.get("method", "OFFSET")
props.is_editing = self.item props.is_editing = self.item
return {"FINISHED"} return {"FINISHED"}
@@ -117,7 +117,7 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
"z": props.z, "z": props.z,
"use_local_space": props.use_local_space, "use_local_space": props.use_local_space,
"sync_children": props.sync_children, "sync_children": props.sync_children,
"dimension_input_type": props.dimension_input_type, "method": props.method,
} }
props.is_editing = -1 props.is_editing = -1
@@ -156,18 +156,15 @@ class BIMArrayProperties(PropertyGroup):
description="Use local space for array items offset instead of world space", description="Use local space for array items offset instead of world space",
default=True, default=True,
) )
dimension_input_type: bpy.props.EnumProperty( method: bpy.props.EnumProperty(
items=( items=(("OFFSET", "Offset", ""), ("DISTRIBUTE", "Distribute", "")),
("Increment", "Increment", ""), name="Method",
("Total", "Total", ""), default="OFFSET",
),
name="Type of input dimension",
default="Increment",
) )
sync_children: bpy.props.BoolProperty( sync_children: bpy.props.BoolProperty(
name="Sync Children", name="Sync Children",
description="Keep children objects in sync with parent object", description="Regenerate all children based on the parent object",
default = False, default=False,
) )
@@ -171,7 +171,7 @@ class BIM_PT_array(bpy.types.Panel):
row.operator("bim.edit_array", icon="CHECKMARK", text="").item = i row.operator("bim.edit_array", icon="CHECKMARK", text="").item = i
row.operator("bim.disable_editing_array", icon="CANCEL", text="") row.operator("bim.disable_editing_array", icon="CANCEL", text="")
row = box.row(align=True) row = box.row(align=True)
row.prop(props, "dimension_input_type") row.prop(props, "method")
row = box.row(align=True) row = box.row(align=True)
row.prop(props, "use_local_space") row.prop(props, "use_local_space")
row.prop(props, "sync_children") row.prop(props, "sync_children")
@@ -185,18 +185,15 @@ class BIM_PT_array(bpy.types.Panel):
row = col.row(align=True) row = col.row(align=True)
row.prop(props, "z") row.prop(props, "z")
row.operator("bim.input_cursor_z_array", icon="CURSOR", text="") row.operator("bim.input_cursor_z_array", icon="CURSOR", text="")
else: else:
row = box.row(align=True) row = box.row(align=True)
row.label(text=f"{array['count']} Items", icon="MOD_ARRAY") 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 row.operator("bim.enable_editing_array", icon="GREASEPENCIL", text="").item = i
row.operator("bim.remove_array", icon="X", text="").item = i row.operator("bim.remove_array", icon="X", text="").item = i
row = box.row(align=True) row = box.row(align=True)
row.label(text=f"Dimension input type: {array.get('dimension_input_type', 'Increment')}") icon = "EMPTY_ARROWS" if array.get("use_local_space", False) else "EMPTY_AXIS"
row = box.row(align=True) row.label(text=f"X: {array['x']}", icon=icon)
row.label(text=f"Use Local Space: {array.get('use_local_space', False)}")
row = box.row(align=True)
row.label(text=f"X: {array['x']}")
row.label(text=f"Y: {array['y']}") row.label(text=f"Y: {array['y']}")
row.label(text=f"Z: {array['z']}") row.label(text=f"Z: {array['z']}")
else: else:
+2 -1
View File
@@ -421,13 +421,14 @@ class Model(blenderbim.core.tool.Model):
obj = tool.Ifc.get_object(element) obj = tool.Ifc.get_object(element)
if obj: if obj:
tool.Geometry.delete_ifc_object(obj) tool.Geometry.delete_ifc_object(obj)
array["children"].clear()
child_i = 0 child_i = 0
existing_children = set(array["children"]) existing_children = set(array["children"])
total_existing_children = len(array["children"]) total_existing_children = len(array["children"])
children_elements = [] children_elements = []
children_objs = [] children_objs = []
if array["dimension_input_type"] == "Total": if array["method"] == "DISTRIBUTE":
divider = 1 if ((array["count"] - 1) == 0) else (array["count"] - 1) divider = 1 if ((array["count"] - 1) == 0) else (array["count"] - 1)
base_offset = Vector([array["x"] / divider, array["y"] / divider, array["z"] / divider]) * unit_scale base_offset = Vector([array["x"] / divider, array["y"] / divider, array["z"] / divider]) * unit_scale
else: else: