Attribute name needs to be updated automatically problem

   2926   3   1
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
Consider the following:


So we have one point, attribute ‘attribute1’ added to it,
and the Point surface node in which I put lvar('ATTRIBUTE1').
It is all right and works.But what if you want to change
the attribute name to different one, say ‘abc’.
Then you need also to type manually ‘ABC’ inside lvar(…): lvar('ABC')
in order to update the network. The question is what kind of expression
we need to put inside lvar(…) - lvar(some_expression) - so that there will be no need
to type every time the new name inside lvar(…) and the network
will get updated automatically?
User Avatar
Member
1921 posts
Joined: 11月 2006
Offline
There are several ways you could handle this. The best choice however depends on how many points and possible performance degradation as the count increases.

The most immediate answer to your question is to put a lookup inside the lvar().
lvar(ch(“../attribcreate1/name”).upper())

This will evaluate the attribute name channel for every point then pipe the answer into the expression and give you the result. The evaluating the parameter each cook is what will decrease performance.

There are alternative function calls you can make but they range from the same to worse performance.

Ideally I would do it using hscript expressions, not Python, as that will be faster. Even a point expression doing a chs() for the attribute name is faster than lvar(“ATTRIBUTE1”) straight up. Plane old $ATTRIBUTE1 is the fastest.

Attached is a file with my various tests.

Something you could also try is a VOP SOP with the attrib import attribute name promoted and referenced.

Attachments:
updating_var_names.hipnc (70.8 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
321 posts
Joined: 7月 2005
Offline
or how about setting the local variable to something more constant, e.g. FOO, and then only changing the attribute name?

But really, how often do you run into this? And on top of that, instead of having something nice, simple and obvious like $ATTRIBUTE1, you now have some arcane expression that no-one else will understand and executes way more slowly to boot.

And finally, check out the ‘opchange’ command if you're worried about needing to propagate a name change.
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
Member
20 posts
Joined: 10月 2009
Offline
Thank you guys for quick replies
  • Quick Links