Jump to content

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

Link to comment
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

Link to comment
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:
Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...