ifc array modifier: adds the option to choose between "total" and "increment" as dimension input

This commit is contained in:
Bruno Perdigão
2023-04-05 09:30:11 -03:00
parent 91d7229353
commit 0627d90486
4 changed files with 20 additions and 2 deletions
@@ -34,7 +34,7 @@ class AddArray(bpy.types.Operator, tool.Ifc.Operator):
obj = context.active_object
element = tool.Ifc.get_entity(obj)
array = {"children": [], "count": 1, "x": 0.0, "y": 0.0, "z": 0.0, "use_local_space": True}
array = {"children": [], "count": 1, "x": 0.0, "y": 0.0, "z": 0.0, "use_local_space": True, "dimension_input_type": "Increment"}
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
@@ -81,6 +81,7 @@ class EnableEditingArray(bpy.types.Operator, tool.Ifc.Operator):
props.y = data["y"]
props.z = data["z"]
props.use_local_space = data.get("use_local_space", False)
props.dimension_input_type = data.get("dimension_input_type", "Increment")
props.is_editing = self.item
return {"FINISHED"}
@@ -105,6 +106,7 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
"y": props.y,
"z": props.z,
"use_local_space": props.use_local_space,
"dimension_input_type": props.dimension_input_type,
}
props.is_editing = -1
@@ -261,6 +261,14 @@ class BIMArrayProperties(PropertyGroup):
description="Use local space for array items offset instead of world space",
default=True,
)
dimension_input_type: bpy.props.EnumProperty(
items=(
("Increment", "Increment", ""),
("Total", "Total", ""),
),
name="Type of input dimension",
default="Increment",
)
class BIMStairProperties(PropertyGroup):
@@ -224,6 +224,8 @@ class BIM_PT_array(bpy.types.Panel):
row.operator("bim.edit_array", icon="CHECKMARK", text="").item = i
row.operator("bim.disable_editing_array", icon="CANCEL", text="")
row = box.row(align=True)
row.prop(props, "dimension_input_type")
row = box.row(align=True)
row.prop(props, "use_local_space")
row = box.row(align=True)
row.prop(props, "x")
@@ -236,6 +238,8 @@ class BIM_PT_array(bpy.types.Panel):
row.operator("bim.enable_editing_array", icon="GREASEPENCIL", text="").item = i
row.operator("bim.remove_array", icon="X", text="").item = i
row = box.row(align=True)
row.label(text=f"Dimension input type: {array.get('dimension_input_type', 'Increment')}")
row = box.row(align=True)
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']}")
+5 -1
View File
@@ -419,7 +419,11 @@ class Model(blenderbim.core.tool.Model):
total_existing_children = len(array["children"])
children_elements = []
children_objs = []
base_offset = Vector([array["x"], array["y"], array["z"]]) * unit_scale
if array['dimension_input_type'] == "Total":
divider = array["count"] -1
base_offset = Vector([array["x"] / divider, array["y"] / divider, array["z"] / divider]) * unit_scale
else:
base_offset = Vector([array["x"], array["y"], array["z"]]) * unit_scale
for i in range(array["count"]):
if i == 0:
continue