UNSOLVED Python CallCommands Are Not Executed When Using Nodes?

Hi,

Since there are no relevant APIs on the node editor commands, I'm trying to use the CallCommands. But they don't seem work with using nodes.

Script below. Creates a node. Selects it. And hopefully rearranges it/layouts it.
I included it four times. But when I execute it. It doesn't rearrange the nodes at all.

Is there a way around this?

import c4d
import maxon
from maxon import GraphModelHelper
import os

def main():
    doc = c4d.documents.GetActiveDocument()
    mat = doc.GetActiveMaterial()
    nodeMaterial = mat.GetNodeMaterialReference()
    nodespaceId = c4d.GetActiveNodeSpaceId()
    nimbusRef = mat.GetNimbusRef(nodespaceId)
    graph = nimbusRef.GetGraph()


    with graph.BeginTransaction() as transaction:

        GraphModelHelper.DeselectAll(graph, maxon.NODE_KIND.ALL_MASK)
        node_01 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.standardmaterial", maxon.DataDictionary())
        node_02 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
        node_03 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
        

        maxon.GraphModelHelper.SelectNode(node_01)
        maxon.GraphModelHelper.SelectNode(node_02)
        maxon.GraphModelHelper.SelectNode(node_03)

        c4d.CallCommand(465002363) # Arrange All Nodes

        transaction.Commit()
        c4d.CallCommand(465002363) # Arrange All Nodes


    c4d.CallCommand(465002363) # Arrange All Nodes
    c4d.EventAdd()
    c4d.CallCommand(465002363) # Arrange All Nodes

if __name__ == "__main__":
    main()

hi,

you need to have the node editor opened yes; the command will be executed on the active node editor.

There are lots of places to improvement our API so "basic" functionalities are accessible by external developers.

Cheers,
Manuel

Hi @Manuel

Thanks for the response.

Yep yep. I have the node editor opened from the get go.
Still doesn't execute.

Here you can see in the demonstration below.
I have to manually execute the arrange command.

2022-12-14_23-51-16.gif

hi,

It doesn't work on R25 but after r26, it does. Many things have change with the r26 and the node editor.

Cheers,
Manuel

@manuel
ah I'm using 2023 above. you can verify it since I'm using the GraphModeler methods which were not available in R25. It's also in the tag of this thread/post.

hi,

because of that small animation i was thinking it was working. I will have a better look tomorrow to understand a bit more what is going on.
My eyes will be fully opened as it seems that i am blind today >.<
"Its just one of those days" as Limp Bizkit would say.

Cheers,
Manuel

No worries. Have a great day ahead! 🙂

hi,
If i run your script on an empty graph, the command (arrange all node) does not see any nodes. There is some caches that need to be updated. I asked the question to the dev. Let's see.

Cheers,
Manuel