mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 07:49:59 +00:00
Don't call transform_apply on cameras in Geometry.clear_scale
clear_scale routed camera, light and speaker objects into bpy.ops.object.transform_apply, which cannot act on that data. It reported "Objects have no data to transform" and left the scale untouched -- the no-op the docstring already describes when it says clearing scale has no impact on cameras. Besides the warning spam on every drawing camera update, the call is a crash vector: transform_apply resolves bpy.context from inside the temp_override, and that has been seen to segfault (EXCEPTION_ACCESS_VIOLATION in BPY_context_member_get, via ctx_wm_python_context_get) when reached from a UI-invoked operator through bim.update_representation on a drawing camera. Return early for those data types instead. Behaviour is unchanged, since the operator was already doing nothing for them. Generated with the assistance of an AI coding tool. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -350,6 +350,15 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
Note that clearing scale has no impact on cameras.
|
||||
"""
|
||||
if cls.is_scaled(obj):
|
||||
if isinstance(obj.data, (bpy.types.Camera, bpy.types.Light, bpy.types.Speaker)):
|
||||
# object.transform_apply cannot touch this data -- it just reports
|
||||
# "Objects have no data to transform" and leaves the scale alone, which
|
||||
# is why the docstring says cameras are unaffected. Skipping the call
|
||||
# keeps that behaviour and avoids the operator resolving bpy.context
|
||||
# from inside the temp_override below, which has been seen to segfault
|
||||
# (EXCEPTION_ACCESS_VIOLATION in BPY_context_member_get) when reached
|
||||
# from a UI-invoked operator via bim.update_representation.
|
||||
return
|
||||
if not obj.data:
|
||||
location, rotation, _ = obj.matrix_world.decompose()
|
||||
obj.matrix_world = Matrix.Translation(location) @ rotation.to_matrix().to_4x4()
|
||||
|
||||
Reference in New Issue
Block a user