mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 02:00:01 +00:00
Array Modifier - support typing units in props
Example - https://i.imgur.com/a0r0vUs.png Also accidentally fixed input_cursor_array not working properly for projects with non-meters units.
This commit is contained in:
@@ -86,9 +86,10 @@ class EnableEditingArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Array", "Data"))[self.item]
|
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Array", "Data"))[self.item]
|
||||||
props = obj.BIMArrayProperties
|
props = obj.BIMArrayProperties
|
||||||
props.count = data["count"]
|
props.count = data["count"]
|
||||||
props.x = data["x"]
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
props.y = data["y"]
|
props.x = data["x"] * si_conversion
|
||||||
props.z = data["z"]
|
props.y = data["y"] * si_conversion
|
||||||
|
props.z = data["z"] * si_conversion
|
||||||
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.method = data.get("method", "OFFSET")
|
props.method = data.get("method", "OFFSET")
|
||||||
@@ -106,15 +107,16 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMArrayProperties
|
props = obj.BIMArrayProperties
|
||||||
|
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
|
||||||
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
||||||
data = json.loads(pset["Data"])
|
data = json.loads(pset["Data"])
|
||||||
data[self.item] = {
|
data[self.item] = {
|
||||||
"children": data[self.item]["children"],
|
"children": data[self.item]["children"],
|
||||||
"count": props.count,
|
"count": props.count,
|
||||||
"x": props.x,
|
"x": props.x / si_conversion,
|
||||||
"y": props.y,
|
"y": props.y / si_conversion,
|
||||||
"z": props.z,
|
"z": props.z / si_conversion,
|
||||||
"use_local_space": props.use_local_space,
|
"use_local_space": props.use_local_space,
|
||||||
"sync_children": props.sync_children,
|
"sync_children": props.sync_children,
|
||||||
"method": props.method,
|
"method": props.method,
|
||||||
@@ -187,6 +189,7 @@ class SelectArrayParent(bpy.types.Operator):
|
|||||||
obj.select_set(True)
|
obj.select_set(True)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class Input3DCursorXArray(bpy.types.Operator):
|
class Input3DCursorXArray(bpy.types.Operator):
|
||||||
bl_idname = "bim.input_cursor_x_array"
|
bl_idname = "bim.input_cursor_x_array"
|
||||||
bl_label = "Get 3d Cursor X Input for Array"
|
bl_label = "Get 3d Cursor X Input for Array"
|
||||||
@@ -202,6 +205,7 @@ class Input3DCursorXArray(bpy.types.Operator):
|
|||||||
props.x = cursor.location.x - obj.location.x
|
props.x = cursor.location.x - obj.location.x
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class Input3DCursorYArray(bpy.types.Operator):
|
class Input3DCursorYArray(bpy.types.Operator):
|
||||||
bl_idname = "bim.input_cursor_y_array"
|
bl_idname = "bim.input_cursor_y_array"
|
||||||
bl_label = "Get 3d Cursor Y Input for Array"
|
bl_label = "Get 3d Cursor Y Input for Array"
|
||||||
@@ -217,6 +221,7 @@ class Input3DCursorYArray(bpy.types.Operator):
|
|||||||
props.y = cursor.location.y - obj.location.y
|
props.y = cursor.location.y - obj.location.y
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class Input3DCursorZArray(bpy.types.Operator):
|
class Input3DCursorZArray(bpy.types.Operator):
|
||||||
bl_idname = "bim.input_cursor_z_array"
|
bl_idname = "bim.input_cursor_z_array"
|
||||||
bl_label = "Get 3d Cursor Z Input for Array"
|
bl_label = "Get 3d Cursor Z Input for Array"
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ class BIMArrayProperties(PropertyGroup):
|
|||||||
default=-1, description="Currently edited array index. -1 if not in array editing mode."
|
default=-1, description="Currently edited array index. -1 if not in array editing mode."
|
||||||
)
|
)
|
||||||
count: bpy.props.IntProperty(name="Count", default=0, min=0)
|
count: bpy.props.IntProperty(name="Count", default=0, min=0)
|
||||||
x: bpy.props.FloatProperty(name="X", default=0)
|
x: bpy.props.FloatProperty(name="X", default=0, subtype="DISTANCE")
|
||||||
y: bpy.props.FloatProperty(name="Y", default=0)
|
y: bpy.props.FloatProperty(name="Y", default=0, subtype="DISTANCE")
|
||||||
z: bpy.props.FloatProperty(name="Z", default=0)
|
z: bpy.props.FloatProperty(name="Z", default=0, subtype="DISTANCE")
|
||||||
use_local_space: bpy.props.BoolProperty(
|
use_local_space: bpy.props.BoolProperty(
|
||||||
name="Use Local Space",
|
name="Use Local Space",
|
||||||
description="Use local space for array items offset instead of world space",
|
description="Use local space for array items offset instead of world space",
|
||||||
|
|||||||
Reference in New Issue
Block a user