Geometry Node: Changing modifier input values with python no cause update #87006

Closed
opened 2021-03-29 05:12:59 +02:00 by yonghao lv · 60 comments

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.72

Blender Version
Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-03-27 14:01, hash: a9e7d503dd

Short description of error
Changing modifier input values with python no cause update.
By code:

bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Input_1"][0] = 13.8

Value in modifier property was changed. User interface no updated before modifiers panel are not redrawn. Result of modifier didn't updated.

image.png

Exact steps for others to reproduce the error

  • Open attached file
  • Run the code bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Input_7"] = 1.0 in the python console
    The modifier UI may change, but the Viewport does not.
    geom_node_py_bug.blend
**System Information** Operating system: Windows-10-10.0.18362-SP0 64 Bits Graphics card: GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.72 **Blender Version** Broken: version: 2.93.0 Alpha, branch: master, commit date: 2021-03-27 14:01, hash: `a9e7d503dd` **Short description of error** Changing modifier input values with python no cause update. By code: ``` bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Input_1"][0] = 13.8 ``` Value in modifier property was changed. User interface no updated before modifiers panel are not redrawn. Result of modifier didn't updated. ![image.png](https://archive.blender.org/developer/F9912961/image.png) **Exact steps for others to reproduce the error** - Open attached file - Run the code `bpy.data.objects["Cube"].modifiers["GeometryNodes"]["Input_7"] = 1.0` in the python console The modifier UI may change, but the Viewport does not. [geom_node_py_bug.blend](https://archive.blender.org/developer/F9922079/geom_node_py_bug.blend)
Author

Added subscriber: @1029910278

Added subscriber: @1029910278

#88545 was marked as duplicate of this issue

#88545 was marked as duplicate of this issue

#87125 was marked as duplicate of this issue

#87125 was marked as duplicate of this issue
Member

Added subscriber: @filedescriptor

Added subscriber: @filedescriptor
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

@1029910278 Could you add the .blend test file to the report? That would be helpful. Thanks.

@1029910278 Could you add the `.blend` test file to the report? That would be helpful. Thanks.
Author

just record a video for this error. You can see that both the cube and line is not active in viewport. And the cube's property disappear.
2021-03-31 19-58-52.mp4

just record a video for this error. You can see that both the cube and line is not active in viewport. And the cube's property disappear. [2021-03-31 19-58-52.mp4](https://archive.blender.org/developer/F9915769/2021-03-31_19-58-52.mp4)
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'

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

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

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Added subscriber: @Pasang

Added subscriber: @Pasang
Member

Added subscriber: @VDC

Added subscriber: @VDC
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Think the problem here will also be fixed by D11572, once we found a good solution.

Think the problem here will also be fixed by [D11572](https://archive.blender.org/developer/D11572), once we found a good solution.

Added subscriber: @MiroHorvath

Added subscriber: @MiroHorvath

Added subscriber: @petneb

Added subscriber: @petneb
Author

Is there any progress on fixing this problem? Since the field system will not display the attribute, I have to stick to use the old nodes(The only way to control them is to acess the node tree)

Is there any progress on fixing this problem? Since the field system will not display the attribute, I have to stick to use the old nodes(The only way to control them is to acess the node tree)

Added subscriber: @TheJeran

Added subscriber: @TheJeran

Oh no this has been here almost a year?

Oh no this has been here almost a year?

Added subscriber: @JacobMerrill-1

Added subscriber: @JacobMerrill-1

does this require .update_tag() ?

does this require .update_tag() ?

just tested

bpy.data.objects["Cube"].update_tag()

is all that is required*

just tested bpy.data.objects["Cube"].update_tag() is all that is required*

I think this can be closed actually

2022-02-04 15-20-35.mp4

I think this can be closed actually [2022-02-04 15-20-35.mp4](https://archive.blender.org/developer/F12847103/2022-02-04_15-20-35.mp4)

In #87006#1301986, @JacobMerrill-1 wrote:
I think this can be closed actually

The value of Z displayed in the modifier panel seems unchanged?

> In #87006#1301986, @JacobMerrill-1 wrote: > I think this can be closed actually The value of Z displayed in the modifier panel seems unchanged?

For me, update_tag() only works if the frame changes manually again. So when I render out an animation nothing happens.

edit:
bpy.data.objects[name].update_tag()
bpy.data.scenes['Scene'].frame_current = currentFrame+1

This works for me, but it's not really what I want.

For me, update_tag() only works if the frame changes manually again. So when I render out an animation nothing happens. edit: bpy.data.objects[name].update_tag() bpy.data.scenes['Scene'].frame_current = currentFrame+1 This works for me, but it's not really what I want.

yeah I just noted that it appears to be disabled somehow from being used continuously :(

a work around is to use a driver and move a empty and use it's X Y and Z as drivers

false alarm* - I was editing slot 1 which is 'geometry'

I think the main issue is we should able to access these inputs by name*

object.modifiers['GeometryNodes'].input['Name'] = Value

yeah I just noted that it appears to be disabled somehow from being used continuously :( a work around is to use a driver and move a empty and use it's X Y and Z as drivers false alarm* - I was editing slot 1 which is 'geometry' I think the main issue is we should able to access these inputs by name* object.modifiers['GeometryNodes'].input['Name'] = Value

Added subscriber: @stilobique

Added subscriber: @stilobique

In #87006#1301986, @JacobMerrill-1 wrote:
I think this can be closed actually

2022-02-04 15-20-35.mp4

Work to me, not really sure about the 'update_tag' function ; I'm stay here to follow this ticket.

> In #87006#1301986, @JacobMerrill-1 wrote: > I think this can be closed actually > > [2022-02-04 15-20-35.mp4](https://archive.blender.org/developer/F12847103/2022-02-04_15-20-35.mp4) Work to me, not really sure about the 'update_tag' function ; I'm stay here to follow this ticket.

Added subscriber: @Human_Robot

Added subscriber: @Human_Robot

The update_tag() trick doesn't fully work. Yes it will update the modifier once but then it won't dynamically update after that. For example my geometry nodes take a collection as input to drive multiple Set Position. If I change the location of an object in the input collection after running the script that tells blender to use this collection as input, it won't update the geometry nodes output to match the change.

The update_tag() trick doesn't fully work. Yes it will update the modifier once but then it won't dynamically update after that. For example my geometry nodes take a collection as input to drive multiple Set Position. If I change the location of an object in the input collection after running the script that tells blender to use this collection as input, it won't update the geometry nodes output to match the change.

This comment was removed by @Human_Robot

*This comment was removed by @Human_Robot*
[2022-11-15 16-40-27.mp4](https://archive.blender.org/developer/F13917972/2022-11-15_16-40-27.mp4)
Member

Removed subscriber: @filedescriptor

Removed subscriber: @filedescriptor

Added subscriber: @Cake-Lover

Added subscriber: @Cake-Lover

This issue really needs to be fixed!

but meanwhile, you can use obj.data.update() after you've changed the modifier value to display the changes

This issue really needs to be fixed! but meanwhile, you can use `obj.data.update()` after you've changed the modifier value to display the changes

If you watch the video the issue is still the same with obj.data.update().

In my code, adding drop_shadow_obj.data.update() before or after or instead of drop_shadow_obj.update_tag() doesn't change anything.

If you watch the video the issue is still the same with obj.data.update(). In my code, adding drop_shadow_obj.data.update() before or after or instead of drop_shadow_obj.update_tag() doesn't change anything.

Added subscriber: @TestPilot02

Added subscriber: @TestPilot02

+1 for experiencing this problem

+1 for experiencing this problem

Added subscriber: @aisatan.ne

Added subscriber: @aisatan.ne

I noticed, if you set it with the type, for example "1.0" instead of just "1", and .data update after

bpy.context.object.modifiers["TestGNMod"]["Input_2"] = 55.0
bpy.context.object.data.update()

I noticed, if you set it with the type, for example "1.0" instead of just "1", and .data update after bpy.context.object.modifiers["TestGNMod"]["Input_2"] = 55.0 bpy.context.object.data.update()
Member

Added subscribers: @dr.sybren, @lichtwerk

Added subscribers: @dr.sybren, @lichtwerk
Member

Just noting that #63793 (When set value of "custom property" by python , driver not up-date correctly) (which seems to be the same underlying thing) was closed by @dr.sybren back then.

Just noting that #63793 (When set value of "custom property" by python , driver not up-date correctly) (which seems to be the same underlying thing) was closed by @dr.sybren back then.

Added subscriber: @Sparazza

Added subscriber: @Sparazza

Added subscriber: @kioku

Added subscriber: @kioku

Added subscriber: @IihT2cWA9xiP30BsYphz3EiEISNoScoe

Added subscriber: @IihT2cWA9xiP30BsYphz3EiEISNoScoe

bpy.context.object.data.update()

This doesnt work with curve objects since their data doesnt have an update function :(

> bpy.context.object.data.update() This doesnt work with curve objects since their data doesnt have an update function :(
Hans Goudey added
Module
Nodes & Physics
and removed
Module
Animation & Rigging
labels 2023-02-08 14:33:40 +01:00

I think it would make sense to have it the other way around. Update is always made like in other modifiers, but with the possibility to delay the update if multiple properties are to be modified.

Maybe one solution could be to have a defer-function like I've noticed while working on Windows apps, used like this:

using (dataView.DeferRefresh())
{
    // Make multiple changes to the data here
}

but in Python something like:

with node.defer_update():
    node.property1 += 1
    node.property2 -= 1

would first modify both parameters, then update.

I think it would make sense to have it the other way around. Update is always made like in other modifiers, but with the possibility to delay the update if multiple properties are to be modified. Maybe one solution could be to have a defer-function like I've noticed while working on Windows apps, used like this: ``` using (dataView.DeferRefresh()) { // Make multiple changes to the data here } ``` but in Python something like: ``` with node.defer_update(): node.property1 += 1 node.property2 -= 1 ``` would first modify both parameters, then update.
Member

@erik85 While I'm not generally against deferring updates, it something that has to be done with great care because it's a bit against current principles of the RNA/Python API. In this specific case I'm not convinced that it is worth it.

I didn't look into this problem for quite some time now, but please make sure you've seen the discussion in https://archive.blender.org/developer/D11572.

@erik85 While I'm not generally against deferring updates, it something that has to be done with great care because it's a bit against current principles of the RNA/Python API. In this specific case I'm not convinced that it is worth it. I didn't look into this problem for quite some time now, but please make sure you've seen the discussion in https://archive.blender.org/developer/D11572.
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:45:00 +01:00

Short description of error

This report doesn't even describe what's going wrong.+

Can we at least get a description of what we're discussing here?

Ok, there's a video that explains quite a bit more. For the next time, please update the description and put such critical there.

> Short description of error ~~This report doesn't even describe what's going wrong.~~+ ~~Can we at least get a description of what we're discussing here?~~ Ok, there's a video that explains quite a bit more. For the next time, please update the description and put such critical there.
Iliya Katushenock changed title from geo nodes not update immediately with python to Geometry Node: Changing modifier input values with python no cause update 2023-02-10 13:45:56 +01:00

if we try and change values of geometry node inputs, we can't continuously change the inputs only some of the input values appear to be evaluated / trigger depsgraph to remake the evaluated data.

in upbge I had to move to using drivers as inputs as object.modifiers['GoemetryNodes'].inputs['input_2'] proved unreliable

if we try and change values of geometry node inputs, we can't continuously change the inputs only some of the input values appear to be evaluated / trigger depsgraph to remake the evaluated data. in upbge I had to move to using drivers as inputs as object.modifiers['GoemetryNodes'].inputs['input_2'] proved unreliable

Is this the same problem?? Blender 3.4
Switching between NodeTrees, the Input Attribute Toggles in the Geo-Node modifier panel get set to their default values of 1.0000. They somehow forget the assigned Input. In my case, see the two images; I have my two vertex selections: named 'Scatter' for a Density Factor and 'WPaint2' for a Value, they changed back to their default 1.0000 values after browsing another node tree . This can easily be duplicated, with either input (happens not only with vertex selections).

Is this the same problem?? Blender 3.4 Switching between NodeTrees, the Input Attribute Toggles in the Geo-Node modifier panel get set to their default values of 1.0000. They somehow forget the assigned Input. In my case, see the two images; I have my two vertex selections: named 'Scatter' for a Density Factor and 'WPaint2' for a Value, they changed back to their default 1.0000 values after browsing another node tree . This can easily be duplicated, with either input (happens not only with vertex selections).

cc rna_access.cc:

    /* Disclaimer: this logic is not applied consistently, causing some confusing behavior.
     *
     * - When animated (which skips update functions).
     * - When ID-properties are edited via Python (since RNA properties aren't used in this case).
     *
     * Adding updates will add a lot of overhead in the case of animation.
     * For Python it may cause unexpected slow-downs for developers using ID-properties
     * for data storage. Further, the root ID isn't available with nested data-structures.
     *
     * So editing custom properties only causes updates in the UI,
     * keep this exception because it happens to be useful for driving settings.
     * Python developers on the other hand will need to manually 'update_tag', see: #74000. */
cc `rna_access.cc`: ```Cpp /* Disclaimer: this logic is not applied consistently, causing some confusing behavior. * * - When animated (which skips update functions). * - When ID-properties are edited via Python (since RNA properties aren't used in this case). * * Adding updates will add a lot of overhead in the case of animation. * For Python it may cause unexpected slow-downs for developers using ID-properties * for data storage. Further, the root ID isn't available with nested data-structures. * * So editing custom properties only causes updates in the UI, * keep this exception because it happens to be useful for driving settings. * Python developers on the other hand will need to manually 'update_tag', see: #74000. */ ```
Contributor

So what's the more preferred workaround for now?
I've found that either object.updat_tag() or object.data.update() works. Is there any difference between them?

Attached some quick example for tests.

So what's the more preferred workaround for now? I've found that either `object.updat_tag()` or `object.data.update()` works. Is there any difference between them? Attached some quick example for tests.

I also have the same issue.
Using Blender v4 none of the above solutions work. I found a solution that works by running 2 actions:

  1. run a Python script that does an actual change in the Blender file and use the bpy.ops.wm.save_mainfile() to save the file.
  2. run the rendering command again, without the Python script param and the file update and all working.

Because of the non-update action, I had all the Geometry Nodes updated, but the Cloth modifier, that came after, doesn't compute the new geometry animation.

To solve this problem, I added remove all bake commands and re-bake the file.

    bpy.ops.ptcache.free_bake_all()
    bpy.ops.ptcache.bake_all(bake=True)

also, I enabled the bpy.context.object.modifiers["Cloth"].point_cache.use_disk_cache = True for my cloth modifier, and done it before the bake.
I see all the animation working well.

I also have the same issue. Using Blender v4 none of the above solutions work. I found a solution that works by running 2 actions: 1. run a Python script that does an actual change in the Blender file and use the `bpy.ops.wm.save_mainfile()` to save the file. 2. run the rendering command again, without the Python script param and the file update and all working. Because of the non-update action, I had all the Geometry Nodes updated, but the Cloth modifier, that came after, doesn't compute the new geometry animation. To solve this problem, I added remove all bake commands and re-bake the file. ``` bpy.ops.ptcache.free_bake_all() bpy.ops.ptcache.bake_all(bake=True) ``` also, I enabled the `bpy.context.object.modifiers["Cloth"].point_cache.use_disk_cache = True` for my cloth modifier, and done it before the bake. I see all the animation working well.

i found that turning off and on the viewport visibility will also refresh it, and cause the changes to appear

bpy.ops.object.toggle_apply_modifiers_view()
bpy.ops.object.toggle_apply_modifiers_view()

you can do it manually, or use this code to do it automatically

i found that turning off and on the viewport visibility will also refresh it, and cause the changes to appear ``` bpy.ops.object.toggle_apply_modifiers_view() bpy.ops.object.toggle_apply_modifiers_view() ``` you can do it manually, or use this code to do it automatically

Just run mod.node_group.interface_update(context)

Takes care of this issue where the displayed unit is lost too: https://www.youtube.com/watch?v=WMwDZ0NFZ08

I do mode changes in the video bc it's faster then obj.update_tag(), but interface_update() actually gets rid of that need too.

Just run `mod.node_group.interface_update(context)` Takes care of this issue where the displayed unit is lost too: https://www.youtube.com/watch?v=WMwDZ0NFZ08 I do mode changes in the video bc it's faster then `obj.update_tag()`, but `interface_update()` actually gets rid of that need too.

Well, you need to create that reference to your mod of course.

mod = obj.modifiers.get('Smooth by Angle', None)

if mod:
    mod.node_group.interface_update(context)

or

for mod in obj.modifiers:
    if mod.type == 'NODES' and mod.node_group and mod.node_group.name == 'Smooth by Angle':
        mod.node_group.interface_update(context)
Well, you need to create that reference to your mod of course. ``` mod = obj.modifiers.get('Smooth by Angle', None) if mod: mod.node_group.interface_update(context) ``` or ``` for mod in obj.modifiers: if mod.type == 'NODES' and mod.node_group and mod.node_group.name == 'Smooth by Angle': mod.node_group.interface_update(context) ```

@MACHIN3 thanks, im gonna delete this soon so that this page is easier to read

@MACHIN3 thanks, im gonna delete this soon so that this page is easier to read
Author

@MACHIN3 seem this new api work.

@MACHIN3 seem this new api work.

seem this new api work.

In that case I'll close this report. Thanks for the solution @MACHIN3 !

> seem this new api work. In that case I'll close this report. Thanks for [the solution](https://projects.blender.org/blender/blender/issues/87006#issuecomment-1140113) @MACHIN3 !
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2024-03-18 12:32:30 +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
28 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#87006
No description provided.