PyAPI: add preferences.filepaths.asset_libraries.new/remove methods #116381

Merged
Philipp Oeser merged 4 commits from lichtwerk/blender:preferences_asset_libraries_API into main 2024-01-12 15:42:46 +01:00
Member

Can be convenient to do this from python (e.g. afaict, these preferences
are not used from Application Templates userpref.blend, but could now at
least be configured via the template script init.py)

Can be convenient to do this from python (e.g. afaict, these preferences are not used from Application Templates userpref.blend, but could now at least be configured via the template script __init__.py)
Philipp Oeser added 1 commit 2023-12-20 16:20:35 +01:00
9679d73bd1 PyAPI: add preferences.filepaths.asset_libraries.new/remove methods
Can be convenient to do this from python (e.g. afaict, these preferences
are not used from Application Templates userpref.blend, but could now at
least be configured via the template script __init__.py)
Philipp Oeser requested review from Sybren A. Stüvel 2023-12-20 16:21:02 +01:00
Philipp Oeser requested review from Campbell Barton 2023-12-20 16:21:07 +01:00
Philipp Oeser added this to the Pipeline, Assets & IO project 2023-12-20 16:21:20 +01:00
Philipp Oeser added the
Interest
Python API
label 2023-12-20 16:21:26 +01:00
Philipp Oeser requested review from Julian Eisel 2023-12-21 11:11:18 +01:00
Sybren A. Stüvel reviewed 2023-12-21 16:01:30 +01:00
@ -448,0 +470,4 @@
CLAMP(U.active_asset_library, 0, count_remaining - 1);
/* Trigger refresh for the Asset Browser. */
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);

Shouldn't this happen when adding a new library as well?

Shouldn't this happen when adding a new library as well?
Author
Member

In theory probably yes (I will add it)

In practice, this is probably only relevant for removal since it only updates something when the library is visible in the Asset Browser (see 990406e1ff, something that is not really happening when adding a library).

However, if one takes into account we also have the All mode in the Asset Library dropdown, it indeed makes sense to have the notifier here, just noting that the All does not properly update in main as well when removing a library, so this will have to be looked at seperately.

In theory probably yes (I will add it) In practice, this is probably only relevant for removal since it only updates something when the library is visible in the Asset Browser (see 990406e1ff9371a8c896b71171caa876cfdff2f6, something that is not really happening when adding a library). However, if one takes into account we also have the `All` mode in the `Asset Library` dropdown, it indeed makes sense to have the notifier here, just noting that the `All` does not properly update in main as well when removing a library, so this will have to be looked at seperately.
dr.sybren marked this conversation as resolved
Philipp Oeser added 1 commit 2023-12-22 10:40:42 +01:00
Campbell Barton requested changes 2024-01-09 12:13:10 +01:00
Campbell Barton left a comment
Owner

Requesting minor change, otherwise LGTM.

Requesting minor change, otherwise LGTM.
@ -448,0 +449,4 @@
{
bUserAssetLibrary *new_library = BKE_preferences_asset_library_add(
&U, name ? name : "", directory ? directory : "");
U.active_asset_library = BLI_findindex(&U.asset_libraries, new_library);

Setting active seems more like something an operator would do. Shouldn't the active be left it it's current value?

Setting active seems more like something an operator would do. Shouldn't the active be left it it's current value?
Author
Member

Havent checked all of the API, most of them use some internal BKE_ functions and behavior is not consistent in those (some make the new active [modifiers, vertexgroups, ...], some dont).

But I guess this is more of a problem of the "other" new functions, agree to not touch active (if we have the choice).

Will update shortly.

Havent checked all of the API, most of them use some internal `BKE_` functions and behavior is not consistent in those (some make the new active [modifiers, vertexgroups, ...], some dont). But I guess this is more of a problem of the "other" `new` functions, agree to not touch active (if we have the choice). Will update shortly.
Philipp Oeser added 2 commits 2024-01-10 14:30:40 +01:00
Philipp Oeser requested review from Campbell Barton 2024-01-10 14:31:38 +01:00
Campbell Barton approved these changes 2024-01-11 00:01:48 +01:00
Philipp Oeser merged commit 0061f2f650 into main 2024-01-12 15:42:46 +01:00
Philipp Oeser deleted branch preferences_asset_libraries_API 2024-01-12 15:42:49 +01:00
Sign in to join this conversation.
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 Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#116381
No description provided.