mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fixing bug with updating window/door modifier with element types
The bug occured when you created a window/door type and some instance of it and then would try to update modifier. There were two problems: 1) Because `remove_representation` removes all the meshes of the representation, representation has to be switched before removing the old one. 2) `switch_representation` parameter `is_global` was set to `False` and it wasn't affecting all instances of the type which led to errors during representation switch later on.
This commit is contained in:
@@ -105,7 +105,7 @@ def update_door_modifier_representation(context):
|
|||||||
obj=obj,
|
obj=obj,
|
||||||
representation=model_representation,
|
representation=model_representation,
|
||||||
should_reload=True,
|
should_reload=True,
|
||||||
is_global=False,
|
is_global=True,
|
||||||
should_sync_changes_first=True,
|
should_sync_changes_first=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,23 @@ def replace_ifc_representation_for_object(ifc_file, ifc_context, obj, new_repres
|
|||||||
ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView
|
ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def switch_to_new_representation():
|
||||||
|
core.switch_representation(
|
||||||
|
tool.Ifc,
|
||||||
|
tool.Geometry,
|
||||||
|
obj=obj,
|
||||||
|
representation=new_representation,
|
||||||
|
should_reload=True,
|
||||||
|
is_global=True,
|
||||||
|
should_sync_changes_first=True,
|
||||||
|
)
|
||||||
|
|
||||||
if old_representation:
|
if old_representation:
|
||||||
|
# switch should happen before `remove_representation` to make sure that
|
||||||
|
# no elements is using old representation
|
||||||
|
# otherwise `remove_representation` will replace them with empty objects
|
||||||
|
# and will lead to errors
|
||||||
|
switch_to_new_representation()
|
||||||
for inverse in ifc_file.get_inverse(old_representation):
|
for inverse in ifc_file.get_inverse(old_representation):
|
||||||
ifcopenshell.util.element.replace_attribute(inverse, old_representation, new_representation)
|
ifcopenshell.util.element.replace_attribute(inverse, old_representation, new_representation)
|
||||||
core.remove_representation(tool.Ifc, tool.Geometry, obj=obj, representation=old_representation)
|
core.remove_representation(tool.Ifc, tool.Geometry, obj=obj, representation=old_representation)
|
||||||
@@ -53,12 +69,6 @@ def replace_ifc_representation_for_object(ifc_file, ifc_context, obj, new_repres
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation
|
"geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation
|
||||||
)
|
)
|
||||||
core.switch_representation(
|
switch_to_new_representation()
|
||||||
tool.Ifc,
|
|
||||||
tool.Geometry,
|
|
||||||
obj=obj,
|
|
||||||
representation=new_representation,
|
|
||||||
should_reload=True,
|
|
||||||
is_global=False,
|
|
||||||
should_sync_changes_first=True,
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user