mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Clear constraint and transform lock on duplicating array child object
Previously it was locked even though it's not part of an array anymore.
This commit is contained in:
@@ -737,10 +737,7 @@ class OverrideDuplicateMove(bpy.types.Operator):
|
|||||||
tool.Blender.remove_data_block(temp_data)
|
tool.Blender.remove_data_block(temp_data)
|
||||||
|
|
||||||
if new:
|
if new:
|
||||||
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
|
tool.Model.remove_array_from_element(new)
|
||||||
if array_pset:
|
|
||||||
array_pset = tool.Ifc.get().by_id(array_pset["id"])
|
|
||||||
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new, pset=array_pset)
|
|
||||||
old_to_new[tool.Ifc.get_entity(obj)] = [new]
|
old_to_new[tool.Ifc.get_entity(obj)] = [new]
|
||||||
if new.is_a("IfcRelSpaceBoundary"):
|
if new.is_a("IfcRelSpaceBoundary"):
|
||||||
tool.Boundary.decorate_boundary(new_obj)
|
tool.Boundary.decorate_boundary(new_obj)
|
||||||
@@ -807,10 +804,7 @@ class OverrideDuplicateMoveLinked(bpy.types.Operator):
|
|||||||
# Copy the actual class
|
# Copy the actual class
|
||||||
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
||||||
if new:
|
if new:
|
||||||
array_pset = ifcopenshell.util.element.get_pset(new, "BBIM_Array")
|
tool.Model.remove_array_from_element(new)
|
||||||
if array_pset:
|
|
||||||
array_pset = tool.Ifc.get().by_id(array_pset["id"])
|
|
||||||
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new, pset=array_pset)
|
|
||||||
old_to_new[tool.Ifc.get_entity(obj)] = new
|
old_to_new[tool.Ifc.get_entity(obj)] = new
|
||||||
# Recreate decompositions
|
# Recreate decompositions
|
||||||
tool.Root.recreate_decompositions(relationships, old_to_new)
|
tool.Root.recreate_decompositions(relationships, old_to_new)
|
||||||
@@ -1054,12 +1048,7 @@ class OverrideDuplicateMoveAggregate(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if new_entity:
|
if new_entity:
|
||||||
# Checks if the object belongs to an Ifc Array
|
tool.Model.remove_array_from_element(new_entity)
|
||||||
array_pset = ifcopenshell.util.element.get_pset(new_entity, "BBIM_Array")
|
|
||||||
if array_pset:
|
|
||||||
array_pset = tool.Ifc.get().by_id(array_pset["id"])
|
|
||||||
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new_entity, pset=array_pset)
|
|
||||||
|
|
||||||
blenderbim.core.aggregate.unassign_object(
|
blenderbim.core.aggregate.unassign_object(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
tool.Aggregate,
|
tool.Aggregate,
|
||||||
@@ -1187,12 +1176,7 @@ class RefreshAggregate(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if new_entity:
|
if new_entity:
|
||||||
# Checks if the object belongs to an Ifc Array
|
tool.Model.remove_array_from_element(new_entity)
|
||||||
array_pset = ifcopenshell.util.element.get_pset(new_entity, "BBIM_Array")
|
|
||||||
if array_pset:
|
|
||||||
array_pset = tool.Ifc.get().by_id(array_pset["id"])
|
|
||||||
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=new_entity, pset=array_pset)
|
|
||||||
|
|
||||||
blenderbim.core.aggregate.unassign_object(
|
blenderbim.core.aggregate.unassign_object(
|
||||||
tool.Ifc,
|
tool.Ifc,
|
||||||
tool.Aggregate,
|
tool.Aggregate,
|
||||||
|
|||||||
@@ -484,6 +484,13 @@ class Blender:
|
|||||||
if obj:
|
if obj:
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def lock_transform(cls, obj, lock_state=True):
|
||||||
|
for prop in ("lock_location", "lock_rotation", "lock_scale"):
|
||||||
|
attr = getattr(obj, prop)
|
||||||
|
for axis_idx in range(3):
|
||||||
|
attr[axis_idx] = lock_state
|
||||||
|
|
||||||
class Modifier:
|
class Modifier:
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_eligible_for_railing_modifier(cls, obj):
|
def is_eligible_for_railing_modifier(cls, obj):
|
||||||
@@ -560,10 +567,7 @@ class Blender:
|
|||||||
modifier_data = list(cls.get_modifiers_data(parent_element))[item]
|
modifier_data = list(cls.get_modifiers_data(parent_element))[item]
|
||||||
children = cls.get_children_objects(modifier_data)
|
children = cls.get_children_objects(modifier_data)
|
||||||
for child_obj in children:
|
for child_obj in children:
|
||||||
for prop in ("lock_location", "lock_rotation", "lock_scale"):
|
Blender.lock_transform(child_obj, lock_state)
|
||||||
attr = getattr(child_obj, prop)
|
|
||||||
for axis_idx in range(3):
|
|
||||||
attr[axis_idx] = lock_state
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def remove_constraints(cls, parent_element):
|
def remove_constraints(cls, parent_element):
|
||||||
|
|||||||
@@ -539,6 +539,24 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
]
|
]
|
||||||
return axes
|
return axes
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def remove_array_from_element(cls, element):
|
||||||
|
array_pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
|
||||||
|
if not array_pset:
|
||||||
|
return
|
||||||
|
|
||||||
|
array_pset_data = array_pset["Data"]
|
||||||
|
array_pset = tool.Ifc.get().by_id(array_pset["id"])
|
||||||
|
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=element, pset=array_pset)
|
||||||
|
|
||||||
|
# remove constraints
|
||||||
|
obj = tool.Ifc.get_object(element)
|
||||||
|
if not array_pset_data and (
|
||||||
|
constraint := next((c for c in obj.constraints if c.type == "CHILD_OF"), None)
|
||||||
|
): # skip array parents
|
||||||
|
obj.constraints.remove(constraint)
|
||||||
|
tool.Blender.lock_transform(obj, False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def regenerate_array(cls, parent, data, keep_objs=False):
|
def regenerate_array(cls, parent, data, keep_objs=False):
|
||||||
tool.Blender.Modifier.Array.remove_constraints(tool.Ifc.get_entity(parent))
|
tool.Blender.Modifier.Array.remove_constraints(tool.Ifc.get_entity(parent))
|
||||||
|
|||||||
Reference in New Issue
Block a user