Python node in Xpresso [SOLVED]
-
On 18/12/2014 at 12:55, xxxxxxxx wrote:
Hi, I hope someone can help. I have a Python node in Xpresso. It has 2 input ports: Count (from a cloner) and Iteration (from an iterator). I am trying to enable and disable 100 Tracer objects based on the count in the cloner. I am using this code in the Python node but nothing is happening. (The list of tracers goes from cord Tracer_01 to cord Tracer_100)
import c4d from c4d import utils from c4d import documents mydoc = documents.GetActiveDocument() ctl = doc.SearchObject('cord Tracer') bc = c4d.BaseContainer() print ctl def main() : if Count <= Iteration: ctl[c4d.ID_BASEOBJECT_GENERATOR_FLAG == 1] else: ctl[c4d.ID_BASEOBJECT_GENERATOR_FLAG == 0] c4d.EventAdd() if __name__=='__main__': main()
Any help would be greatly appreciated. Thanks.
-
On 23/12/2014 at 04:45, xxxxxxxx wrote:
From the C4D Help:
There are some limitations with regard to what Python does within a Python Node. Python Nodes are not allowed to directly access the CINEMA 4D project document or objects in the scene via Python. If, for example, you want to ascertain an object's current position within Python you can use XPresso Nodes to do this and pass this information via Ports to Python.
The Python Node is better suited for processing mathematical calculations and simple program structures, e.g., if-then-else. More complex Python applications should be executed via Python scripts in the Python Script Manager.
_
_
So I guess that's the problem. You are searching objects from within Python -
On 23/12/2014 at 05:11, xxxxxxxx wrote:
Here's a VERY simple XPresso setup that Enables or Disables Everything in the List.
Just select the Constant and enable - disable the "Value" button
-
On 23/12/2014 at 06:00, xxxxxxxx wrote:
Thank-you for your reply. I've decided to go with another, sleeker solution.
PS Cool talk you gave at Siggraph 2013.
-
On 23/12/2014 at 07:03, xxxxxxxx wrote:
Thanks for the compliment
Torontonian?
Where abouts? -
On 23/12/2014 at 07:46, xxxxxxxx wrote:
Hi Thanassis!
Nice to see you show your nose here at the Plugin Cafe
-
On 23/12/2014 at 10:42, xxxxxxxx wrote:
Royal York and the Queensway.
-
On 25/12/2014 at 08:50, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Hi Thanassis!
Nice to see you show your nose here at the Plugin CafeHey Yannick! Sticking it wherever I can
Originally posted by xxxxxxxx
Royal York and the Queensway.
this is uncanny. I'm Park Lawn and Lakeshore... haha 5 minutes away.
We are moving to Oakville next month. Let's grab a coffee or beer sometime.
email me:
noseman [at] noseman [dot] orgMerry Christmas and happy new year!
-
On 05/01/2015 at 04:53, xxxxxxxx wrote:
Hi,
I'm glad this has already been solved.
I was working on this and got held up by Christmas vacation...
But as I came up with an example, I thought I post it nevertheless."Activate Simple Control" is a NULL object with three User Data values: Change Max (integer), Enable (Bool) and Link (a link field).
The Python code in "Python Activate Simple" is quite simple:
import c4d def main() : if not(doc) or not(Object) : return flagSelect = (Index < Max) or (Max < 0) # activate all on negative values Object[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = flagSelect
-
On 05/01/2015 at 05:50, xxxxxxxx wrote:
Thanks for taking the time to come up with this elegant solution! I really appreciate it.