mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Minor array refactor
This commit is contained in:
@@ -36,8 +36,7 @@ class AddArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
array = {"children": [], "count": 1, "x": 0.0, "y": 0.0, "z": 0.0}
|
array = {"children": [], "count": 1, "x": 0.0, "y": 0.0, "z": 0.0}
|
||||||
|
|
||||||
psets = ifcopenshell.util.element.get_psets(element)
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
||||||
pset = psets.get("BBIM_Array", None)
|
|
||||||
|
|
||||||
if pset:
|
if pset:
|
||||||
data = json.loads(pset["Data"])
|
data = json.loads(pset["Data"])
|
||||||
@@ -77,8 +76,7 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMArrayProperties
|
props = obj.BIMArrayProperties
|
||||||
|
|
||||||
psets = ifcopenshell.util.element.get_psets(element)
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
||||||
pset = psets["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"],
|
||||||
@@ -112,8 +110,7 @@ class EnableEditingArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
psets = ifcopenshell.util.element.get_psets(element)
|
data = json.loads(ifcopenshell.util.element.get_pset(element, "BBIM_Array", "Data"))[self.item]
|
||||||
data = json.loads(psets["BBIM_Array"]["Data"])[self.item]
|
|
||||||
props = obj.BIMArrayProperties
|
props = obj.BIMArrayProperties
|
||||||
props.count = data["count"]
|
props.count = data["count"]
|
||||||
props.x = data["x"]
|
props.x = data["x"]
|
||||||
@@ -134,8 +131,7 @@ class RemoveArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
props = obj.BIMArrayProperties
|
props = obj.BIMArrayProperties
|
||||||
|
|
||||||
psets = ifcopenshell.util.element.get_psets(element)
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
||||||
pset = psets["BBIM_Array"]
|
|
||||||
data = json.loads(pset["Data"])
|
data = json.loads(pset["Data"])
|
||||||
data[self.item]["count"] = 1
|
data[self.item]["count"] = 1
|
||||||
|
|
||||||
|
|||||||
@@ -372,10 +372,11 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
total_existing_children = len(array["children"])
|
total_existing_children = len(array["children"])
|
||||||
children_elements = []
|
children_elements = []
|
||||||
children_objs = []
|
children_objs = []
|
||||||
|
base_offset = Vector([array["x"], array["y"], array["z"]]) * unit_scale
|
||||||
for i in range(0, array["count"]):
|
for i in range(0, array["count"]):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
continue
|
continue
|
||||||
offset = Vector((i * array["x"] * unit_scale, i * array["y"] * unit_scale, i * array["z"] * unit_scale))
|
offset = base_offset * i
|
||||||
for obj in obj_stack:
|
for obj in obj_stack:
|
||||||
if child_i >= total_existing_children:
|
if child_i >= total_existing_children:
|
||||||
child_obj = tool.Spatial.duplicate_object_and_data(obj)
|
child_obj = tool.Spatial.duplicate_object_and_data(obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user