Wiki, Local variables in python too.

Hi,
It will be really helpful to indicate the Python code of local variables in the wiki.
Now we only have Hscript :
derivative.ca/wiki088/index. … mitive_SOP

Thx !

It should be more clear, you are correct.
If you bring up the Python help for an operator though, you will find any locally defined members and methods:

derivative.ca/wiki088/index. … ss#Members

Cheers

I read python help, but i coun’t find an equivalent.

exemple : How write this expression in python :
rand($PR)
tdu.rand(me.prims) “just discovered”
and
rand($CR) ?

Or complete this sooo helpful page :
derivative.ca/wiki088/index. … _Tips#Time

Cheers

We could extend the Tips page, but unfortunately every operator has its own unique set.
so for rand($CR)

I would first look at the definition of $CR → red primitive color
then look at the Primtive SOP python class members:

inputColor (Read Only) The current primitive color being evaluated or a default if not present, expressed as a 4-tuple.

so:

me.rand(me.inputColor)

In the cases where you can’t find the attribute directly, you could go through the attributes:

me.inputPrim.Cd[0] for example.

Thank you rob !

me.inputPrim.Cd[0] is a good example.

This really help me for the syntax.

Problem:
Why rand($PR) is not equal to tdu.rand(me.prims) ?
In python it takes everything. exemple :
primitivePython.1.toe (4.25 KB)

$PR is a numeric index

me.prims is a python list of all the primitives, so it never changes throughout the cook.
(the list is the list)

You’ll want:

tdu.rand(me.inputPrim.index)

Cheers

Thank you rob !

Everything is clear now.
Cheers