Optimizing and changing size of Xpresso nodes
-
On 17/11/2017 at 03:02, xxxxxxxx wrote:
Hi guys,
Does anyone know if it's possible to optimize or change sizes of Xpresso nodes in Python? Can't find it in the Python documentation, but did find something related for C++, I think!
Thank you very much!
Andre
-
On 17/11/2017 at 04:21, xxxxxxxx wrote:
Hello don't know about Optimize command if you can acces it or not.
For the size there is no proper c4d wrapper arround it but you can edit it using this (note sure if it's an acceptable way from Maxon, I mean I don't know if it can change in the future or not)import c4d def main() : nodeMaster = doc.GetActiveTag().GetNodeMaster() node = nodeMaster.GetRoot().GetDown() # Set Y size node.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[109] = 50 # Set X size node.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[108] = 100 c4d.EventAdd() # iterate bc maybe you want to modify other thing like position [100] and [101] bc = node.GetDataInstance()[1001][1000] for index, value in bc: try : print "Index: %i, Value: %s" % (index, str(value)) except: pass if __name__=='__main__': main()
Hope it's help !
-
On 17/11/2017 at 08:36, xxxxxxxx wrote:
Hi Graphos,
Many thanks again for your awesome help!
It works, but not with all the nodes that I want. I think it may be related to the IDs, which to be honest not sure how you got it in the first place.I will try and explain my problem in more detail below:
I have an Xgroup parent node which encloses all its child nodes. The code you gave to change it's size unfortunately didn't work for the Xgroup but worked for all it's child nodes. Does this has something to do with the ID?
XGroup (Default)
|_ MainGrp <--- This is the one I want to affect it's size initially
|_ Child_1
|_ Child_2
|_ Child_3If I get the ID by calling the node
.GetOwnerID
() gives me 1001142.The IDs 1001 and 1000 that you gave in your example, where did you get it from and why that specific order please?
node.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[109] = 50
Apologies for the all the questions, but having a hard time understanding it .
Appreciate your awesome effort and thank you again!
Andre
-
On 18/11/2017 at 04:11, xxxxxxxx wrote:
As you may know or not. A node inside xpresso is represented by a c4d.modules.graphview.GvNode wich inherite from a BaseList2D (like all other Object within a scene, like a cube for exemple, which is a BeseObject that inherite from a BaseList2D)
So that mean you can iterate an Xpresso graph (a c4d.modules.graphview.GvNodeMaster) as you iterate an object list. Using GetDown() / GetNext().
When you fully understand it you can now readRecursive hierarchy iteration
[URL-REMOVED] orNon-recursive hierarchy iteration
[URL-REMOVED]So now you can easily affect only the node you want by doing selecting it by name for exemple if obj.GetName() == "_MainGrp()": Do you action. Of course you can use any way you want for select which node you want to resize.
About how I do it. I suggest you to read BaseContainer Manual even if it's in C++ you may learn new things.
So regarding a Node, as said before it's a BaseList2D, so like all BaseList2D it got a function called GetDataInstance which return a BaseContainer of the data. You can then iterate it using Bc iteration.
And here a video that show how I did know the IDs that I have to use, just by testing http://recordit.co/DB7B9qC9nY.Hope it's help !
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 20/11/2017 at 01:06, xxxxxxxx wrote:
Oh WOW! Thank you very much for your explanation and taking the time to make a freaking video.
Will have a look now, but it definitely makes more sense.
-
On 20/11/2017 at 05:13, xxxxxxxx wrote:
Hi,
unfortunately from MAXON's side, there's no officially supported way to achieve what's requested in this thread. gr4ph0s findings may work (actually not questioning this), just be aware, this is not officially recommended and might break anytime in future (e.g. by changed IDs).
While Niklas is a very supportive member of this community and we appreciate him a lot, in this regard we disagree and I can only recommend to use the online docs published by MAXON (e.g. in order not to miss the latest fixes). The link in the first post to GvBodyDefaultSize in official documentation.
Finally gr4ph0s had a link to the old C4D Programming blog. As we are not sure, how long that will be available anymore as it got replaced completely by developers.maxon.net, here's the link to
Recursive Hierarchy Iteration
[URL-REMOVED].No need to feel sorry, nobody did anything wrong, no critique intended, just a few minor annotations and corrections from our side.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 20/11/2017 at 13:42, xxxxxxxx wrote:
Hi Andreas,
Thank you for your input and will keep your advice in mind.
It's a big learning curve that hopefully will get less "curvier".
Cheers!