Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi all. I've installed the trial version of R21 (I'm looking to upgrade at some point anyway). However, I'm still struggling to get some python code that successfully adds ports to a GV node and then connects them.
Any help would be massively appreciated.
Jamie
Hi @zipit - Thanks again for all your help and guidance with this.
That last code you sent was really beneficial in helping me get a better understanding of how Python Generators work. I've got my Python Generator code working now just as I intended.
Also, creating python tags rather than xpresso is a much more elegant way to achieve what I'm trying to do. I'm guessing that Python Generators might not be the best way to introduce yourself to Python in C4D?
Having used AE for years and utilising Javascript expressions, I'm really excited about what python can open up to me with regards to C4D work.
Hi all.
I have created a Python Generator that looks at the hierarchy of it's children and generates a spline through them all. This part all works fin.
However, when I create a Spline Wrap object and set the Python Generator as it's spline, nothing happens. Is there a way I can get a Spline Wrap object to use a spline created by a Python Generator?
Thanks, Jamie
Thanks @Cairyn
I tried searching for that post, but I couldn't find it.
I'm trying a slightly different approach now by using a python tag on a spline object. It's almost working but I'm having update issues.
@zipit Ah I did wonder if the behaviour was slightly different due to it being a Python Generator.
I think I understand most of what you have said there, but being new to Python (and coding really) it can be quite tricky for me grasp. From the sounds of it, I might be trying to do TOO MUCH of it within a Python Generator? I'm open to better/alternative pipelines.
Here is a bit more detail about what I'm trying to to achieve overall:
So overall, what I would like to have is a Python Generator which allows me to change certain User Data values so that it generates the correct hierarchy of Cloners, Objects and Deformers. (This all works fine) , but then what I would also like is the Python Generator to create an Xpresso tag that dynamically links certain attributes to the root object's User Data so that even after I have collapsed the Python Generator into the hierarchy, I can still change the User Data on the root object (The Connect object) and Deformer objects within the hierarchy will change accordingly.
I hope that makes sense?
Does this sound like something that is possible?
Cheers, Jamie
Thanks again @zipit
To make things a bit clearer, here is what I am trying to do:
Use a Python Generator to:
I'm afraid I've got so confused with trying to get this right, that my code has become really messy with lots of things commented out as I try to figure what is working and what isn't.
So I've created a new Python Generator with this code which is pretty much where I'm up to:
def main(): # Create Connector Object and insert an Xpresso tag to it connector_obj = c4d.BaseObject(c4d.Oconnector) tag_xpresso = c4d.BaseTag(c4d.Texpresso) connector_obj.InsertTag(tag_xpresso) # Get the node master and the root noode of that graphview. gvNode_master = tag_xpresso.GetNodeMaster() gvNode_root = gvNode_master.GetRoot() # Create a GV Node in the node Master gvNode_controller = gvNode_master.CreateNode(gvNode_root, c4d.ID_OPERATOR_OBJECT) # Add port to GV Node USERDATA_NUMBER = 1 gvNode_controller.AddPort(c4d.GV_PORT_OUTPUT, c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(USERDATA_NUMBER)), message=True) return connector_obj
From the link you sent it looks like it's fixed for R21. So I'm downloading the trial version now to see if I can get it working.
Thanks @zipit - that's helped me get a better understanding for connecting ports (please forgive me, I'm still very new to python). However, I'm still stuck with trying to add a 'User Data' port to the node.
The Node I have created is c4d.ID_OPERATOR_OBJECT and then I use the following code to make sure it's referring to the right object:
c4d.ID_OPERATOR_OBJECT
parentNode[c4d.GV_OBJECT_PATH_TYPE] = 0 parentNode[c4d.GV_OBJECT_START_TYPE_ID] = 1
But then I try and use the AddPort function to add an output port to the node but I can't get it working.
I’m wanting to use a python generator to create an xpresso tag that then links user data to an object’s attribute.
I’ve got as far as being able to add the xpresso tag and have added the object node in the xpresso tag, but I’m having no joy with adding ports and linking them.
Could anyone show me a simple example that does this?
Many thanks, Jamie
@mp5gosu
Ah brilliant. Thanks for that!
And apologies for being such a noob at this.