How to understand GraphModelInterface.AddChild().
-
Hi community!
I want to add some nodes for redshift node material. and I find some problem with I think I just make it work but not fully understand this function.
self.graph.AddChild(childId=maxon.Id(), nodeId=nodeId, args=maxon.DataDictionary())
Problem:
I found if I modify the graph and then insert material, the node will be well positioned, aka it will aligned perfectly.
But if I modify the existing materials , like create a node tree , the node will add to the same position in the graph with not recognizable wires connection.
If I try call the
c4d.CallCommand(465002363) # Arrange All Nodes
It will arranges all my nodes and break old nodes position. for now my solution is select new created nodes and call theArrange Selected Nodes
to position them.But I think I didn't use or understand the
args=maxon.DataDictionary()
arg, I wonder if I can set the position or something for the node .Question:
- Can I or how can I add nodes to exist graph with a reasonable position
- How to understand the
maxon.DataDictionary()
and what this use for
Cheers~
DunHou -
Hi @Dunhou
-
This is for the moment not possible the auto-layouter should do it's work in your case it's seems not. Is it something 100% reproducible? Could you share with us a script that produce such output so we can fix the bug? Moreover for moment this is not possible to define the node position on a graph node. I forwarded this request to the responsible development team, but there is no guarantee that this will be implemented.
-
The data dictionary can be used to define default parameters value by passing a NodePath before it's creation but the semantic is a bit complex in Python so I would advice you to use
SetDefaultValue
once a port is created as demonstrated in Modify Node Graph Example.
Cheers,
Maxime. -
-
Hi @m_adam
I sent an e-mail with some part of the code and it is 100% reproducible at least for my PC . I didn't know if it is a bug or my wrong coding, thanks for your help.Cheers~
DunHou. -
Hi @m_adam, how is it going? Is it a bug or my code mistakes? check it if you forgot this
-
Hi @dunhou, as said in my last email the code you provided is not executable on my end, and due to the current development phase we are internally at Maxon, I do not have that much time right now to look at it, to try to debug it. So for the moment it's on hold until bugfixing time come into our development phase so I would have more time to look into it.
I totally understand for you extracting all this to a simple example, that I can copy-paste to the script manager and that reproduce the issue without your own wrapper is a big task, but that will help a lot.
Cheers,
Maxime. -
Hi @m_adam ! I recently added some functionality to Dunhou's Redshift material API, so I think I might be of help here.
What @Dunhou mentions: try putting the c4d.callcommand to arrange the nodes outside of the transaction such that the added nodes get commited to the graph before it tries to arrange itself; that way it should work.
Still, I have no idea how the arranging of nodes works. Is it for all selected materials? Is it only for the one that is currently opened in the node editor? Can I send all selected materials there to be arranged? Would love to find out how it works internally.
Secondly, there is not really a way to add an AddUndo() to the callcommand, so if one is editing a lot of materials at once via a script, every undo is just one of the arrange nodes instead of undoing all of it at once.Lastly, I'd also like to find out how to come to conclusions more quickly. I'm working my way though the SDK docs when I need it, however I've tried finding out for a few hours if I can edit a Node's position; is it an attribute? How would I know? Struggling with that a lot hahah.
Thanks in advance and hope this was a little bit of help,
- Jerome
-
Hey @HerzogVonWiesel
Hey many thanks your works! I had write a new helper temporary named
RenderEngine
. It contains Octane/Redshift/Arnold stuffs , It is a bare-bone of it. I will put it on my Github, but I wonder redshift is own by Maxon now, will an offical sdk will be publish soon . Now the Octane one is almost there , Redshift and Arnold can work but I wonder if it's ok to pay attention on it right now.
But anyway, maybe I will post a topic in General Talk. And welcome to improve it.About arrange, for now I set the node selection active and callcommand the arrange selection. utill a solution there.
Cheers~
DunHou -
Hi @Dunhou, regarding the release of a Redshift SDK, sadly this is nothing we can communicate about. May I ask what would be your expectation about a Redshift SDK if it there is one?
In any case I have the feeling that your utility classes will be greatly appreciated and useful for a lot of people, since I wrote C4D_RedshiftWrapper_API which only support xpresso redshift graph. It is really outdated by now, but there is still many people using it, so I'm sure a newer version using new node would be welcome !
Cheers,
Maxime. -
Hi @m_adam ,I am working on control aovs/materials or something like that , now we have a
import redshift
but all I know is that use help function,but seems it is only few funtions, can I or where can I find all the funtions and docs in redshift class?And yes, the old one of my redshift node gragh api is now some people use it ,now I am working on the new render engine api , hope it will help someone, especially I am an amateur habbit-coder.
-
Sadly there is no documentation for the Python redshift API, this is still something maintained by the redshift team, so best bet would be to reach the redshift guy on their forums.
Cheers,
Maxime. -
Hi @m_adam , I have ask what are main functions in redshift do in redshift forum, but get no reply for week. and the
help(redshift)
also give me an ambiguous result.But anyway, I have something here, I will update it and publish when I have free times.
-