mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
switch_representation not to break with temporary mesh representations
I've found a bug that if you have some object that consists of extrusion and can be edited in profile edit mode, when you finish editing, it would remove the type object (and I guess the other occurences objects). It happened because during edit mode it's using temporary mesh data and `switch_representation` would replace this temp mesh data with new representation and remove the old mesh data that might still used by the other occurences and the type. The issue also was leading to a crash during `box.template_icon(icon_value=AuthoringData.data["type_thumbnail"], scale=5)` if you had BIM Tool thumbnail preview opened in the process - removing type object would make thumbnail icon become invalid leading to the crash. Crash mentioned here: https://community.osarch.org/discussion/1753/bbim-two-door-types-with-connected-properties
This commit is contained in:
@@ -104,6 +104,7 @@ def switch_representation(
|
||||
return
|
||||
|
||||
entity = ifc.get_entity(obj)
|
||||
current_obj_data = obj.data
|
||||
|
||||
# doesn't resolve mapped representations in case if it's going to have openings
|
||||
# otherwise we would also add openings to the type and other occurences mesh data
|
||||
@@ -125,6 +126,10 @@ def switch_representation(
|
||||
# we assume that all the occurences and the type have the same representation context active
|
||||
# so geometry.delete_data cannot remove the data that's still used by some other object
|
||||
if should_reload and old_repr_data:
|
||||
# if current object was using some temporary mesh (like during profile edit mode) instead of `old_repr_data`
|
||||
# then `change_object_data` won't switch the mesh for all the occurences and we need to do it explicitly
|
||||
if current_obj_data != old_repr_data and old_repr_data.users:
|
||||
geometry.replace_object_data_globally(old_repr_data, new_repr_data)
|
||||
geometry.delete_data(old_repr_data)
|
||||
|
||||
geometry.clear_modifiers(obj)
|
||||
|
||||
Reference in New Issue
Block a user