mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix error using bim.updating_representation for object with material set
Possibly occurred after 4c255cc, but haven't investigated deeper.
@BIMvoice
The error you were reporting about Split Along Edge operator was caused by this issue, should be fixed now too.
See https://jmp.sh/hgJEHsgH
Example error traceback:
```
Error: Python: Traceback (most recent call last):
File "C\bonsai\bim\ifc.py", line 487, in execute_ifc_operator
result = getattr(operator, "_execute")(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C\bonsai\bim\module\geometry\operator.py", line 541, in _execute
self.update_obj_mesh_representation(context, obj)
File "C\bonsai\bim\module\geometry\operator.py", line 666, in update_obj_mesh_representation
tool.Ifc.link(new_representation, data)
File "C\bonsai\tool\ifc.py", line 230, in link
IfcStore.link_element(element, obj)
File "C\bonsai\bim\ifc.py", line 258, in link_element
tool.Geometry.get_mesh_props(obj).ifc_definition_id = element.id()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C\bonsai\tool\geometry.py", line 92, in get_mesh_props
return mesh.BIMMeshProperties
^^^^^^^^^^^^^^^^^^^^^^
ReferenceError: StructRNA of type Mesh has been removed
```
This commit is contained in:
@@ -589,6 +589,7 @@ class UpdateRepresentation(bpy.types.Operator, tool.Ifc.Operator):
|
||||
tool.Material.ensure_material_unassigned([element_type])
|
||||
ifcopenshell.api.material.unassign_material(self.file, products=[product])
|
||||
tool.Material.ensure_material_unassigned([product])
|
||||
data = obj.data # Required after ensure_material_unassigned
|
||||
else:
|
||||
# These objects are parametrically based on an axis and should not be modified as a mesh
|
||||
if extrusion := tool.Model.get_extrusion(old_representation):
|
||||
|
||||
@@ -329,7 +329,10 @@ class Material(bonsai.core.tool.Material):
|
||||
or some other may be applied now since it's no longer overridden,
|
||||
therefore we need to make sure blender materials reflect correct styles.
|
||||
|
||||
Designed to be called after material.unassign_material API call."""
|
||||
Designed to be called after material.unassign_material API call.
|
||||
|
||||
Will reload representations, invalidating existing object data.
|
||||
"""
|
||||
elements = elements.copy() # Avoid argument mutation.
|
||||
for element in elements[:]:
|
||||
if element.is_a("IfcElementType"):
|
||||
|
||||
Reference in New Issue
Block a user