On 23/06/2015 at 07:13, xxxxxxxx wrote:
As the title says, but specifically I need to mention, I create the cloner from a python script, and change it to grid array in the same script.. Then later in the same script I make an xpresso node from that same object, and try to create the output ports for Size.X Size.Y , which are attributes only available in Grid Array style.. and they don't show up. :[ If I run the same code to add the ports from a python tag after the python script has run. it will work!! strange...
I'm hoping it will suffice to post a small portion of my source code :
# Create cloner node
xnode_cloner = nodemaster2.CreateNode(nodemaster2.GetRoot(),c4d.ID_OPERATOR_OBJECT,None,600,100)
xnode_cloner[c4d.GV_OBJECT_OBJECT_ID] = cloner
# Add In Ports Size.X Size.Y
print xnode_cloner
xnode_cloner_IN_SizeX = xnode_cloner.AddPort(c4d.GV_PORT_INPUT, \n c4d.DescID(c4d.DescLevel(c4d.MG_GRID_SIZE), c4d.DescLevel(c4d.VECTOR_X)), message=True)
xnode_cloner_IN_SizeY = xnode_cloner.AddPort(c4d.GV_PORT_INPUT, \n c4d.DescID(c4d.DescLevel(c4d.MG_GRID_SIZE), c4d.DescLevel(c4d.VECTOR_Y)), message=True)
The strange thing is that the node does not produce the ports.. HOWEVER, if I create a Python tag and then run find the node and run the above commands, then I succeed. So I imagine the problem is that running a python script does not allow the GUI to update the state machine or something?? Because I change the cloner to grid array from inside the python script before trying the above.. and I have the feeling that C4D does not "realize" this has happened...
I've encountered another instance where from inside a python script I cannot do real-time interaction with C4D objects / properties. I think this is related.. If you're wondering what I was trying to do in this other case, it was when I was trying to do Mograph selection from Python. If I tried updating the Mograph Selection Xpresso node inputs from the python script (index, select), it would not update properly, only the last index/select value would be written.. In this instance, I averted my problem by instead doing this from a Python Xpresso node itself, meaning that I created a Python Xpresso Node from my Python script (tedious). But I can't imagine having to go that far just yet for this problem too.. Something's wrong about my approach.
So basically, how can I make this work?? In all fairness, I'm not even sure I've identified the problem.
I imagine someone will say migrating from a script to a plugin will help make this work.. Well I need some guidance as this is my first day / 2nd day in C4D with python. And about 3 weeks in with C4D. Right now I've created a python script that creates a bunch of "stuff" (object, cloner, several effectors) .. And now I'm planning on creating a User Data on the top-most-parent Null object, along with XPresso tag to have the user data control parts of the system I have created.. I'm almost there too, although I have not yet learned to create all of the different user data, such as InExclude. But, that's neither here nor there.
I just run into the roadblock of the cloner Xpresso node not creating the ports, and I believe (starting to re-iterate) done.