Page MenuHome

When set value of "custom property" by python , driver not up-date correctly
Closed, ArchivedPublicKNOWN ISSUE

Description

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: GeForce GTX 980 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 419.67

Blender Version
Broken: version: 2.80 (sub 58), branch: master, commit date: 2019-04-21 20:30, hash: rB797539e76ccf

Short description of error
[Please fill out a short description of the error here]
When set custom property value by script (use console, or code), it not up-date pose-bone driven value. To up-date it, need to toggle pose-mode,
or need to clcik "Update Dependencies" of driver editor.

Exact steps for others to reproduce the error

  1. load attached blend file for 2.8 or current 2.7 beta build

  1. Select armature (if not), then goto properties editor>object>Custom properties
  2. change "prop" value to 1.0
  3. It move "Bone" to (1.0, 0, 0) by driver
  4. Open python console, and input, C.object["prop"] = 0.00
  5. it change "prop" value to 0.00 (properties editor>object>Customproperties >prop value)

7 but it not update 3d view bone location.
8 toggle mode to object, or toggle mode to pose, bone move correctly to (0, 0, 0)
9 or need to use driver editor> "Update Dependencies" then bone locate correctly (driver up-date)

And there seems no good way to force up-date , without change mode.
"update dependencies" can not access by python.

I know there are already some reports for driver up-date (or dependency graph), but could not find about this specific case.

so just reported. Though I offer most simple case, but plug in often change "rig custom property values" from UI.
When direct input and change value , it up-date correctly., but if use function, (eg reset value of all proeprties) with UI button, it not up-date correctly.
Then I hope to know way to force up-date . (at current I toggle object pose-mode by python, then force up-date, but it is not good way I think)

if it is already reported , merge and close this please.

Event Timeline

Sebastian Parborg (zeddb) lowered the priority of this task from 90 to 50.

Even though it will not be solved soon,, Is not there good way to force up-date from add-on(script) side?
which method or function, I can use ?

for 2.7 " toggle edit mode" only work. ( toggle-pose-mode work for 2.8)
But about Proxy rig, we can not use toggle edit mode (for rig obj ID properties) ,to up-date driver dependency graph, I think.

I expected if recent depthgraph change solve this issue,
but it seems not work still.

after step 5
I tried to update depthgraph by console

depth = C.evaluated_depsgraph_get()
depth.update()

but it do nothing for this case. the custom property of armature actually get value as 0.5
then it should drive bone location (X) but not adapted untill I toggle mode, or change seleciton etc.
Is not there more better way to up-date with dependency?

Same problem with driver on generic props (scale, node value etc...).
I've script with UI and custom prop attached to driver.
When I use the UI, the custom prop change the driver value.
When I use console or python script to change the custom prop, the driver value not change.

Yes it seems not only about pose bone. when script change "custom-prop" which drive other properties, manually change value can up-date driver, but change value by python, driver not work. There were many up-date about dependency graph, So if there is method to force it. but I can not find it.

I hope developer solve this issue, or offer way for bpy, if there were already simple solution, teach us please. Or for each case, we need many try and erroer and add un-necessary step, just up-date driver.

takeshi funahashi (waitinfuture) renamed this task from When set value of "custom property" by python , driver not up-date correctly (for posed bone) to When set value of "custom property" by python , driver not up-date correctly.Jul 4 2019, 10:23 AM
Sybren A. Stüvel (sybren) changed the subtype of this task from "Report" to "Bug".Jan 9 2020, 4:50 PM

@Sergey Sharybin (sergey) @Campbell Barton (campbellbarton) do you know of any reason why setting a custom property via Python wouldn't trigger a depsgraph update?

This is the same issue as T74000. The issue is that an object is not "tagged for update" in the dependency graph when a custom property is changed by Python. "Tagged for update" means that Blender understands that the object (and everything that depends on it) should be updated. This is done for a few reasons:

  1. Tagging the object for update requires a reference to that object. This is available for simple cases like some_ob["prop"], but not for nested cases like some_ob["complex_prop"][3]["something"].
  2. Updating an object could mean recalculating its constraints and modifiers, which can be expensive. This may not even be necessary for that particular custom property, but when exactly this is or is not necessary can be hard to determine. As a result, this could make Blender slower than necessary.

After setting the custom property, call C.object.update_tag(). This should take care of the updates not "being seen" by dependencies. It won't trigger a full redraw of Blender's UI, though, so until that happens things on screen may still show the old status.

Sybren A. Stüvel (sybren) claimed this task.
Sybren A. Stüvel (sybren) changed the subtype of this task from "Bug" to "Known Issue".