Adding assets (modifiers, such as Smooth by Angle) not working in background Python script because Asset list might not be fully loaded yet #117399
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117399
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: Quadro RTX 3000/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 528.02
Blender Version
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2024-01-17 00:18, hash:
35028d9480b0
Worked: None as it is a new feature
Short description of error
I try to apply the new "Smooth by Angle" operator from a Python script that runs in a Blender background process. But while it works from inside of Blender it fails when running from the command line as background with the message:
Warning: Asset loading is unfinished
Exact steps for others to reproduce the error
test_simple.blend
test_simple.py
with this content:blender test_simple.blend --background -P test_simple.py
As result I get
Warning: Asset loading is unfinished
. If the modified blend file is saved to the disk and opened in blender one can see that a GeoemetryNodes group was created for the cube but that it is empty.Running exactly the same script from inside Blender while the
test_simple.blend
is opened works fine and produces the expected modifier.Can confirm.
Not sure if there is a way to ensure the Asset list is loaded from python, will ask around.
Note this might be on the border of a feature request if such functionality/handler/callback does not exist (yet).
Maybe it would be ideal if this operator was blocking when called with
exec
rather thaninvoke
. I'm not sure how to load assets in a blocking way though, I haven't seen the asset system expose that functionality.Might be overkill, but maybe add a handler (for when all the loading has finished)?
Thank you for checking and confirming. Unfortunately this effect avoids usage of the "Smooth by Angle" from background Python scripts while it was no problem at all with the old "Auto Smooth" option. I fully understand the idea behind introducing the new way with the GeometryNodes but this is limiting in this application.
I thought about using timers to delay the execution when I have to apply the "Smooth by Angle" but then found out that this is limited in background Python scripts when the UI is not loaded.
I think for now I will try to rework my script to first load all geometry and then step through all objects and apply the modifier. Hopefully loading all geometry first keeps Blender busy until the required assets are loaded. But depending on the size of the assets and the amount of data that I have to load this will be a random behavior.
I like the idea of a handler etc. that indicates that loading has finished.
Smooth by Angle not working in background Python scriptto Adding assets (modifiers, such as Smooth by Angle) not working in background Python script because Asset list might not be fully loaded yetGot confirmation from @JulianEisel that there is no such system in place (yet).
For now, delaying the procedure of loading asset (modifiers) in some other way seems the best choice.
The asset loading is currently written to be non-blocking and happen in the background as it's first needed. There is no blocking version of the code, so the first time an operator like this is run, it will just trigger the loading of assets.
The reason having an object in the scene makes this work is that the assets are loaded for node tools.
I think we should just load the all library as soon as Blender starts, we aren't going to be able to avoid that much longer. It will already be needed for node tools in object mode, and brush assets. And node tools should work without an active object in the future too.
@JulianEisel What do you think about that?
I just ran into this issue while updating my pcb2blender addon for Blender 4.1. I've found that as a workaround for now (althought this is obviously not very ideal), loading the asset library manually seems to do the trick.
Here's the helper function I use now:
(Edit: Seems like the location of the internal assets is system dependant.)