Jump to content
peppino3d

Accessing attributes and variables in expressions

Recommended Posts

Hello,

I'm reading the forum about accessing variables and attributes in expressions.

I think I understand the difference and the use of both (thanks to this thread),

but I'm still a little confused on how to access both in expressions:

How do I access the first value of a vector attribute in an expression?

And how do I access a the first value of a vector variable instead ? In fact coming from other script languages I could think of $VX, $V[0], $V0, $V.x etc. etc. :)

Are there other ways of accessing the data (maybe if they're variables brought by a varmap attribute) ?

Thanks!

Peppino

Share this post


Link to post
Share on other sites

It depends on what attribute and/or variable. If it's local like Normals, you use $NX, $NY, $NZ. The Point SOP has some of the defaults or standard variables that's commonly used. Also, you should check out the Point SOP's help page for more information.

If the attribute is created with an AttribCreate SOP, for floats, you do $FOO1, $FOO2 etc. For vectors, $FOOX, $FOOY etc. Again, please check the help page of the SOP.

To access the first value of a vector, you do $FOO[0], for example though it's quite rare.

This help page is also pretty useful: http://localhost:48626/expressions/

Hope the above helps!

Cheers!

steven

Share this post


Link to post
Share on other sites

- $VX

- well, the mapping between local variable and attribute name is determined by the varmap attribute.

Share this post


Link to post
Share on other sites

The varmap method isn't always available. For example, when you are accessing the attribute from another network so you can substitute the point, vertex, prim or detail expressions instead something like this:

point("/obj/geo/sop",0,"v",0)

Share this post


Link to post
Share on other sites

Could I access a point attribute from another network let's say by using point("/obj/geo/sop",$PT,"v",0) ?

Also I can easily access local and global variables, but as far as attributes go I'm still a bit confused: does the varmap detail attribute preserve local variables outside of the sop operator? if so how does it do it?

Thanks

peppino

The varmap method isn't always available. For example, when you are accessing the attribute from another network so you can substitute the point, vertex, prim or detail expressions instead something like this:

Share this post


Link to post
Share on other sites
Could I access a point attribute from another network let's say by using point("/obj/geo/sop",$PT,"v",0) ?

You can use $PT but as it is a local variable it will evaluate in the local SOP not the SOP that is referenced in the expression. That may or may not be what you want.

Share this post


Link to post
Share on other sites

Thanks, but this leads to a new question:

Let's say I want to access a pop attribute (randpp) from a copy sop. If I plug the popnet into the right plug of a copy sop and middle click randpp is not there anymore.

How can I access this per point pop attribute from the copy sop?

I was thinking of retrieving it using an exp like point("../popnet1","randpp",$ID,0) in the copy1/val1 field.

Thanks

Peppino

Share this post


Link to post
Share on other sites
Guest Swann
Thanks, but this leads to a new question:

Let's say I want to access a pop attribute (randpp) from a copy sop. If I plug the popnet into the right plug of a copy sop and middle click randpp is not there anymore.

How can I access this per point pop attribute from the copy sop?

I was thinking of retrieving it using an exp like point("../popnet1","randpp",$ID,0) in the copy1/val1 field.

Thanks

Peppino

Try turning on Use template Point attributes in copySop Attribute TAB

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×