Skip to content

fix: preserve custom properties when boolean modifier is applied during export#2713

Open
Jefsky wants to merge 1 commit into
KhronosGroup:mainfrom
Jefsky:fix/boolean-modifier-custom-properties
Open

fix: preserve custom properties when boolean modifier is applied during export#2713
Jefsky wants to merge 1 commit into
KhronosGroup:mainfrom
Jefsky:fix/boolean-modifier-custom-properties

Conversation

@Jefsky

@Jefsky Jefsky commented Jun 17, 2026

Copy link
Copy Markdown

When "Apply Modifiers" is enabled and a Boolean modifier is active on an object, the to_mesh() call creates a new evaluated mesh datablock. If that evaluated mesh has any auto-generated properties (e.g. from the modifier evaluation pipeline), blender_data.keys() becomes non-empty, and the old code would skip copying custom properties from the original mesh — only removing blacklisted ones. This silently drops Python-registered custom properties on Mesh datablocks.

Root cause: The if len(blender_data.keys()) == 0 condition guarded the custom property copy. Any property present on the evaluated mesh (even irrelevant ones) flipped the behavior to delete-only.

Fix: Unconditionally copy non-blacklisted custom properties from the original mesh data to the evaluated mesh, using try/except to gracefully skip Blender 4.2+ statically-typed properties that cannot be overwritten. Blacklisted properties introduced by the modifier evaluation are still cleaned up.

How to test:

  1. Open Blender, create a Cube
  2. Run a script that registers a BoolProperty on bpy.types.Mesh (e.g. bpy.types.Mesh.testProp = bpy.props.BoolProperty(name="Test"))
  3. Set the property to True
  4. Add a Boolean modifier to the Cube and enable it in viewport
  5. Export to glTF with "Apply Modifiers" and "Include Custom Properties" both checked
  6. Verify the custom property appears in the glTF extras
  7. Toggle the modifier off and re-export — property should still be present

Fixes #2700

…ng export

When 'Apply Modifiers' is enabled with a boolean modifier active on
an object, to_mesh() creates a new evaluated mesh that may contain
auto-generated properties from the modifier evaluation pipeline.
The original logic only copied custom properties when the evaluated
mesh had zero keys(); any existing property (even irrelevant ones)
would skip the copy entirely, silently dropping Python-registered
custom properties on the mesh datablock.

The fix unconditionally copies non-blacklisted custom properties
from the original mesh data to the evaluated mesh, using try/except
to gracefully skip Blender 4.2+ statically-typed properties that
cannot be overwritten. Blacklisted properties introduced by the
modifier evaluation are still cleaned up.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@julienduroure

Copy link
Copy Markdown
Collaborator

Hello,
You didn't sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Boolean modifier blocks export of Blender properties registered through Python

4 participants