Drivers that use modified namespaces only work after reloading twice blender files with the same internal script #62195

Closed
opened 2019-03-05 00:58:23 +01:00 by iszotic · 9 comments

Operating system: Ubuntu 18.04.1
Graphics card: RX 480

Blender Version
Broken:
blender-2.80-3730d16347a5-2019-03-04, 16:04
Worked:
Open the file twice

Short description of error
Drivers that use modified namespaces only work after reloading twice blender files with the same internal script.

Exact steps for others to reproduce the error
I made an empty with saturation and hue object properties, these properties are later plugged into a light's RGB values using drivers, (in this case, for cycles and eevee), for this purpose a script is used that adds an entry to the driver's namespace to convert hue and saturation into RGB. I make sure this script is registered and that blender auto-runs python files.

Lights sync eevee and cycles.blend

Operating system: Ubuntu 18.04.1 Graphics card: RX 480 Blender Version Broken: blender-2.80-3730d16347a5-2019-03-04, 16:04 Worked: Open the file twice **Short description of error** Drivers that use modified namespaces only work after reloading twice blender files with the same internal script. **Exact steps for others to reproduce the error** I made an empty with saturation and hue object properties, these properties are later plugged into a light's RGB values using drivers, (in this case, for cycles and eevee), for this purpose a script is used that adds an entry to the driver's namespace to convert hue and saturation into RGB. I make sure this script is registered and that blender auto-runs python files. [Lights sync eevee and cycles.blend](https://archive.blender.org/developer/F6762507/Lights_sync_eevee_and_cycles.blend)
Author

Added subscriber: @iszotic

Added subscriber: @iszotic
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

I don't know what to do in this file exactly to see the issue.
Can you create an even simpler example? Maybe just a simple driver on the object location?

I don't know what to do in this file exactly to see the issue. Can you create an even simpler example? Maybe just a simple driver on the object location?
Author

I tried to make it as simply as possible, 3 drivers controlling the RGB channels of one light, with 2 properties in one empty and one script appending a function to the namespace, also appended a video.

Lights sync eevee and cycles.blend
Bug-demo.mkv

I tried to make it as simply as possible, 3 drivers controlling the RGB channels of one light, with 2 properties in one empty and one script appending a function to the namespace, also appended a video. [Lights sync eevee and cycles.blend](https://archive.blender.org/developer/F6766938/Lights_sync_eevee_and_cycles.blend) [Bug-demo.mkv](https://archive.blender.org/developer/F6766925/Bug-demo.mkv)
Member

Added subscriber: @brecht

Added subscriber: @brecht
Member

The problem is that the depsgraph is build before your script executes. Both happens in wm_file_read_post, but in the "wrong" order.

I'm not aware of any non-hacky solution to solve this currently.
The cleanest solution would probably be to make the Register option for text blocks a bit more advanced. For example, allowing to run the script before or after depsgraph evaluation. Even more options like running a script on frame change etc. could be possible. All the event handlers we have basically.

@brecht, can you think of a case when it is useful to run the script after the depsgraph has been build? Setting up e.g. driver namespaces seems to be one of the most important use cases for this auto-run feature.

The problem is that the depsgraph is build before your script executes. Both happens in `wm_file_read_post`, but in the "wrong" order. I'm not aware of any non-hacky solution to solve this currently. The cleanest solution would probably be to make the `Register` option for text blocks a bit more advanced. For example, allowing to run the script before or after depsgraph evaluation. Even more options like running a script on frame change etc. could be possible. All the event handlers we have basically. @brecht, can you think of a case when it is useful to run the script after the depsgraph has been build? Setting up e.g. driver namespaces seems to be one of the most important use cases for this auto-run feature.

This is probably the same as #61063 (Function from Python not being loaded for Driver when project opened),

This is probably the same as #61063 (Function from Python not being loaded for Driver when project opened),

This issue was referenced by d31b2f8549

This issue was referenced by d31b2f854954838fb849b5b0be0011d792eecb43

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
4 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#62195
No description provided.