Accessing attribute from another Geometry

   5514   6   3
User Avatar
Member
12 posts
Joined: Nov. 2018
Offline
Hi!

that's probably a trivial question but I can't get this to work. Basically I've created a sphere and done some calculation in an AttributeWrangle node, the results of my calculation are two values which I'm storing as detail attributes: MinElevation and MaxElevation. If I look at my geometry spreadsheet I can see my two new attributes with the right values.

Now I'd like to create another sphere in the same network and set it's radius to the MinElevation value. I've tried the following without success:
* Setting the Radius field value of the new sphere to :
detail("../sphere1" , "MaxElevation", 0);
Not working.
* Testing the following code in another attributeWrangle node placed under the new sphere:
float value = detail("../sphere1/attribwrangle1" , "MaxElevation", 0);
float value;
getattribute("../sphere1", value, "detail", "MaxElevation", 0, 0);
getattribute("../attribwrangle1", value, "detail", "MaxElevation", 0, 0);




Thanks a lot!
Edited by Lucas_6666 - Nov. 21, 2018 12:00:19

Attachments:
houdini_attribute.png (34.7 KB)

User Avatar
Member
149 posts
Joined: Oct. 2015
Offline
Hello
You should provide some hip file
if you have done your calculation in attributewrangle1 (set to run on detail so it create a detail attribute)
you should be able to access those attribute in attributewrangle2 with something like
float myvalue=detail(“../attributewrangle1”,“MaxElevation”,0);

but , for example , the first path : detail(“../sphere1” , “MaxElevation”, 0);
is refering to a node where the attribute shouldn't exist yet ….if you check info on this node there's no MaxElevation…
again it's hard to say without the hip file ….

Benjamin
User Avatar
Member
12 posts
Joined: Nov. 2018
Offline
Hi Benjamain, thanks for the answer. Yes my first guess was that the attribute would only be available starting at the attribwrangle1 node. I just tried again and it does not work… I'm attaching the hip file, you can check the NOT_WORKING node.

thanks!

Image Not Found

Attachments:
AttributePb.hip (639.9 KB)

User Avatar
Member
149 posts
Joined: Oct. 2015
Offline
Hi Lucas
Yes indeed , i think it access it but with a zero value
I think it must have to do with the order of computation…
if you do something like this it force the system to compute the first attribute wrangle before the second.
Maybe someone better than me could explain why…
But as Houdini cook from top to bottom …

Attachments:
Clipboard02.png (240.8 KB)

User Avatar
Member
9407 posts
Joined: July 2007
Online
if you are accessing geometry of an operator in VEX not by input but by path you have to use op: prefix
if you don't have op: prefix it'll assume you want to access geometry from a file

so this should work
float MaxElevation = detail("op:../attribwrangle1", "MaxElevation", 0);

(also the last 0 argument is optional and you don't have to specify it unlike in hscript version)
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
12 posts
Joined: Nov. 2018
Offline
Thanks a lot for your responses, tamte this worked perfectly!

I also noticed that if setting an attribute in an attributeWrangle node it does not seem to be available before the next node, this probably makes sense the way houdini computes the nodes.

For example:
setdetailattrib(0, "test", 5);
float test = detail(0, "test");
printf("test %f\n", test);
This will output 0 and not five while I can see the detail attribute being 5 on the geometry spreadsheet with the node selected.
User Avatar
Member
8178 posts
Joined: Sept. 2011
Offline
Lucas_6666
Thanks a lot for your responses, tamte this worked perfectly!

I also noticed that if setting an attribute in an attributeWrangle node it does not seem to be available before the next node, this probably makes sense the way houdini computes the nodes.

For example:
setdetailattrib(0, "test", 5);
float test = detail(0, "test");
printf("test %f\n", test);
This will output 0 and not five while I can see the detail attribute being 5 on the geometry spreadsheet with the node selected.

Yes, because the ‘set’ actually happens after all the code is done running on your geometry.
  • Quick Links