mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Array children now follow their parent with a "child-of" constraint #3492
This commit is contained in:
@@ -134,6 +134,8 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
pset = tool.Ifc.get().by_id(pset["id"])
|
pset = tool.Ifc.get().by_id(pset["id"])
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Data": data})
|
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Data": data})
|
||||||
|
|
||||||
|
tool.Blender.Modifier.Array.constrain_children_to_parent(element)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -522,6 +522,16 @@ class Blender:
|
|||||||
return cls.is_stair(element) or cls.is_door(element) or cls.is_window(element)
|
return cls.is_stair(element) or cls.is_door(element) or cls.is_window(element)
|
||||||
|
|
||||||
class Array:
|
class Array:
|
||||||
|
@classmethod
|
||||||
|
def constrain_children_to_parent(cls, parent_element):
|
||||||
|
parent_obj = tool.Ifc.get_object(parent_element)
|
||||||
|
children = cls.get_all_children_objects(parent_element)
|
||||||
|
for child in children:
|
||||||
|
constraint = next(
|
||||||
|
(c for c in child.constraints if c.type == "CHILD_OF"), None
|
||||||
|
) or child.constraints.new("CHILD_OF")
|
||||||
|
constraint.target = parent_obj
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all_objects(cls, parent_element):
|
def get_all_objects(cls, parent_element):
|
||||||
parent_obj = tool.Ifc.get_object(parent_element)
|
parent_obj = tool.Ifc.get_object(parent_element)
|
||||||
|
|||||||
Reference in New Issue
Block a user