Skip to content

Bonsai: reload external styles from .blend in update_current_style - #9478

Open
theoryshaw wants to merge 1 commit into
IfcOpenShell:v0.9.0from
theoryshaw:update_current_style_reload_9477
Open

theoryshaw wants to merge 1 commit into
IfcOpenShell:v0.9.0from
theoryshaw:update_current_style_reload_9477

Conversation

@theoryshaw

Copy link
Copy Markdown
Member

Fixes #9477

The Update Current Style refresh button in the Styles panel (bim.update_current_style, added for #3293) stopped reloading external .blend styles after the Flat/Pretty dual-branch change in #8342. For a material that already has both branches, setting active_style_type only switches between BIM_Output_External and BIM_Output_Flat, so bim.activate_external_style is never called and edits to the external material never come through.

Changes

  • UpdateCurrentStyle now calls a new reload_external_style() for each material it updates when the style type is External, and for every IFC material on SHIFT+CLICK. It only runs for styles whose external Location is a .blend file, and it reports a warning if loading fails.
  • For dual-branch materials this goes through Style.update_external_branch(), which replaces only the external branch and leaves the flat branch alone.
  • Style.switch_shading() is unchanged. Viewport shading changes and the Flat/Pretty toggle set active_style_type on every material, and they should keep switching without reading from disk.
  • The tooltip now says that External styles are reloaded from their .blend file.

Testing

Tested manually in Blender on a model whose materials use external styles from a shared Materials.blend. After editing and saving materials in that file, clicking the button reloaded each selected object's materials (activate_external_style returned {'FINISHED'} for each), and the changes appeared in the viewport.

🤖 Generated with Claude Code

Since the Flat/Pretty dual-branch change (IfcOpenShell#8342), setting a material's
active_style_type to External only flips the cached BIM_Output_External /
BIM_Output_Flat outputs, so the refresh button next to the style type
dropdown no longer picked up edits made to the external .blend material.

When the style type is External, re-append the external style via
bim.activate_external_style (which replaces the external branch of
dual-branch materials) for each updated material, and for all IFC
materials on SHIFT+CLICK. switch_shading keeps its fast path so viewport
shading changes and the Flat/Pretty toggle stay disk-free.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Bonsai: Update Current Style no longer reloads external .blend styles (regression from #8342)

1 participant