Running scripts on append/link #78794

Open
opened 2020-07-10 14:21:35 +02:00 by Demeter Dzadik · 16 comments
Member

(I mentioned this at lunch and @dr.sybren said I should make a design task here c: )

Problem

Most production rigs come with their own scripts, whether it's just for UI purposes or have actual functionality. It's standard practice for riggers to make these text datablocks a dependency of the rig to make sure that it's brought along when the rig is appended or linked somewhere. However, such scripts will not run on append or link.

This introduces a piece of poor UX for animators, which in my experience results in a huge amount of confusion. The animator would have to save and reload the file, or open a text editor and run the script file, but they have no reason to know that they have to do either of these, unless the rigger tells them so. @Hjalti and @PabloFournier probably remember running into this on many occasions.

Proposal

My idea is to add a piece of functionality to the append and link operators; A "Run Scripts" bool param, enabled by default, with a tooltip like "Execute scripts which are set to register on file load after appending/linking". Can probably come up with better wording, but I guess you get the idea; Appending or linking(directly or indirectly) a text datablock with the register checkbox enabled(use_module==True), will also execute it.

If the user has Auto-Run Python Scripts user preference disabled, it should throw up the usual pop-up to request permission to run the script.

An example file with a rig and rig UI script, all ready to be linked/appended:
custom_rig_ui.blend

Thoughts? Are there other use cases? Are there any scenarios where this would cause problems?

(I mentioned this at lunch and @dr.sybren said I should make a design task here c: ) # Problem Most production rigs come with their own scripts, whether it's just for UI purposes or have actual functionality. It's standard practice for riggers to make these text datablocks a dependency of the rig to make sure that it's brought along when the rig is appended or linked somewhere. However, such scripts will not run on append or link. This introduces a piece of poor UX for animators, which in my experience results in a huge amount of confusion. The animator would have to save and reload the file, or open a text editor and run the script file, but they have no reason to know that they have to do either of these, unless the rigger tells them so. @Hjalti and @PabloFournier probably remember running into this on many occasions. # Proposal My idea is to add a piece of functionality to the append and link operators; A "Run Scripts" bool param, enabled by default, with a tooltip like "Execute scripts which are set to register on file load after appending/linking". Can probably come up with better wording, but I guess you get the idea; Appending or linking(directly or indirectly) a text datablock with the register checkbox enabled(`use_module==True`), will also execute it. If the user has Auto-Run Python Scripts user preference disabled, it should throw up the usual pop-up to request permission to run the script. An example file with a rig and rig UI script, all ready to be linked/appended: [custom_rig_ui.blend](https://archive.blender.org/developer/F10428949/custom_rig_ui.blend) Thoughts? Are there other use cases? Are there any scenarios where this would cause problems?
Author
Member

Added subscribers: @PabloFournier, @Hjalti, @dr.sybren, @Mets

Added subscribers: @PabloFournier, @Hjalti, @dr.sybren, @Mets

Added subscriber: @TheOldBen

Added subscriber: @TheOldBen

Very reasonable proposal. Would love to not have to reload the files every time. It has been a point of confusion for many of my rig users who come to complain about missing rig controls.

Very reasonable proposal. Would love to not have to reload the files every time. It has been a point of confusion for many of my rig users who come to complain about missing rig controls.

Added subscriber: @jpbouza-4

Added subscriber: @jpbouza-4

Hi! Ok, here go my two cents..

I think that anything that makes the scripts work will be welcome, but to me, even the workflow we have right now is a bit obscure to me...

So this is just a crazy idea, but what if we have a new type of object specific property that would let you add scripts to them... Like an object script datablock where each object can have its own scripts... I don't know, just ignore me if it doesn't make sense, hehe.

Hi! Ok, here go my two cents.. I think that anything that makes the scripts work will be welcome, but to me, even the workflow we have right now is a bit obscure to me... So this is just a crazy idea, but what if we have a new type of object specific property that would let you add scripts to them... Like an object script datablock where each object can have its own scripts... I don't know, just ignore me if it doesn't make sense, hehe.
Author
Member

For those not in the know, you can add a custom property referencing a text datablock (or any other datablock) with something like this in the PyConsole:
bpy.context.object['my_script'] = bpy.data.texts['rig_ui.py']

And I agree, it feels like a weird workflow, but I think that's only because there's no way to do this in the UI. Other than that, this feels perfectly appropriate.
The current UI for editing custom properties has fallen behind their expanding functionality, but that's a separate issue.

For those not in the know, you can add a custom property referencing a text datablock (or any other datablock) with something like this in the PyConsole: `bpy.context.object['my_script'] = bpy.data.texts['rig_ui.py']` And I agree, it feels like a weird workflow, but I think that's only because there's no way to do this in the UI. Other than that, this feels perfectly appropriate. The current UI for editing custom properties has fallen behind their expanding functionality, but that's a separate issue.

Cool @Mets ! Yes, that's what I was imagining. So if you have this script referenced within a custom property, does it work when the character is linked?

As you are saying you have to create that property with python, I guess that you need a second script to create it, but once that script runs, does the "custom property script" work automatically in a linked file?

So if we had the text datablock custom property UI, would that solve all of our problems?

Cool @Mets ! Yes, that's what I was imagining. So if you have this script referenced within a custom property, does it work when the character is linked? As you are saying you have to create that property with python, I guess that you need a second script to create it, but once that script runs, does the "custom property script" work automatically in a linked file? So if we had the text datablock custom property UI, would that solve all of our problems?
Author
Member

Edited my previous comment to clarify. The line of code I posted is a perfectly valid line of code in current master. You can try it for yourself. The text datablock will come along with the rig when linking or appending, but it will not be executed until it is done so via the text editor or save and reload. The custom property editing UI is a separate, unrelated issue.

Edited my previous comment to clarify. The line of code I posted is a perfectly valid line of code in current master. You can try it for yourself. The text datablock will come along with the rig when linking or appending, but it will not be executed until it is done so via the text editor or save and reload. The custom property editing UI is a separate, unrelated issue.

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @ZedDB

Added subscriber: @ZedDB
Author
Member

Want to drop a poke here because the nightmare has come true. I now have 8 animators asking me on a semi-daily basis why their rig UI is not showing up. I have made a canned reply and also added it to our animator on-boarding page, but ideally none of that would be necessary, if this idea could just get into master. ;)

This might be a good medium-prority and hopefully simple to implement studio feature request, so maybe a perfect candidate for @ZedDB? ❤️

Want to drop a poke here because the nightmare has come true. I now have 8 animators asking me on a semi-daily basis why their rig UI is not showing up. I have made a canned reply and also added it to our animator on-boarding page, but ideally none of that would be necessary, if this idea could just get into master. ;) This might be a good medium-prority and hopefully simple to implement studio feature request, so maybe a perfect candidate for @ZedDB? :heart:

Oh yes, please!
I have a canned response myself. The day I can delete the video telling animators to save and revert the file will be a happy one indeed!

Oh yes, please! I have a canned response myself. The day I can delete the video telling animators to save and revert the file will be a happy one indeed!

Added subscriber: @ericEDFilms

Added subscriber: @ericEDFilms

Please implement this, it really makes a lot of sense for rigs to come along with their own custom scripts.

  1. Add the bpy.context.object['my_script'] = bpy.data.texts['rig_ui.py'] to the custom properties popup UI, so this is easy to reference a custom script
  2. Linking a collection from a file runs all scripts that come along with the collection.

Boom, easy custom rig UI.

EDIT: Also just thought, some boilerplate code for what some simple rig UI script could look like would really seal the deal.

Please implement this, it really makes a lot of sense for rigs to come along with their own custom scripts. 1. Add the `bpy.context.object['my_script'] = bpy.data.texts['rig_ui.py']` to the custom properties popup UI, so this is easy to reference a custom script 2. Linking a collection from a file runs all scripts that come along with the collection. Boom, easy custom rig UI. EDIT: Also just thought, some boilerplate code for what some simple rig UI script could look like would really seal the deal.
Author
Member

I added a super basic example file with a rig that has a UI script attached, thanks for the suggestion.

I added a super basic example file with a rig that has a UI script attached, thanks for the suggestion.

Added subscriber: @Nils-Lerin

Added subscriber: @Nils-Lerin
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:36:12 +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 project
No Assignees
6 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#78794
No description provided.