Depending on internal details of how Blender is run, attempting to load elements from the asset library may either execute as synchronous & blocking or asynchronously. When executing a script in background mode, prior to this commit, operators that are dependent on the asset system will not execute correctly due to the loading not being complete. Busy-waiting for this by repeatedly calling the operator over and over again in python does not resolve. To match behavior of other operators when called from python scripts such as the quadriflow remesh, this commit changes the `brush.asset_activate` operator and dependent code to force a blocking call instead of optionally using the wmJob background abstraction system. Related to #117399 Pull Request: https://projects.blender.org/blender/blender/pulls/134203
26 lines
856 B
Python
26 lines
856 B
Python
# SPDX-FileCopyrightText: 2025 Blender Authors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import sys
|
|
import unittest
|
|
|
|
import bpy
|
|
|
|
|
|
class AssetActivateTest(unittest.TestCase):
|
|
def setUp(self):
|
|
# Test case isn't specific to Sculpt Mode, but we need a paint mode in general.
|
|
bpy.ops.object.mode_set(mode='SCULPT')
|
|
|
|
def test_loads_essential_asset(self):
|
|
result = bpy.ops.brush.asset_activate(
|
|
asset_library_type='ESSENTIALS',
|
|
relative_asset_identifier='brushes/essentials_brushes-mesh_sculpt.blend/Brush/Smooth')
|
|
self.assertEqual({'FINISHED'}, result)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Drop all arguments before "--", or everything if the delimiter is absent. Keep the executable path.
|
|
unittest.main(argv=sys.argv[:1] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []))
|