Hello all,
I am a little confused with attribute-wrangle and primitives.
I have a scene attached that has 3 objects packed and merged, and I want to get the bounding box size of each of them. Now I solved it with a 'forEach primitive,' however, I am trying this with VEX and I am unable to get the same result, not able to figure out what I am doing wrong. Would really appreciate some advice to point me in the right direction.
Thank you.
Regards,
-G
Loop over Primitive to get BBsize in VEX [new user]
2980 4 1- govindk
- Member
- 13 posts
- Joined: Jan. 2019
- Offline
- animatrix_
- Member
- 4538 posts
- Joined: Feb. 2012
- Offline
Hi,
It's because you are changing the input geometry by changing the first argument in the getbbox_size function. You should use the first input (0), and supply the index to the second argument:
https://www.sidefx.com/docs/houdini/vex/functions/getbbox_size.html [www.sidefx.com]
But because the second argument is a string, you need to convert int to string using the itoa function:
https://www.sidefx.com/docs/houdini/vex/functions/itoa.html [www.sidefx.com]
It's because you are changing the input geometry by changing the first argument in the getbbox_size function. You should use the first input (0), and supply the index to the second argument:
https://www.sidefx.com/docs/houdini/vex/functions/getbbox_size.html [www.sidefx.com]
But because the second argument is a string, you need to convert int to string using the itoa function:
https://www.sidefx.com/docs/houdini/vex/functions/itoa.html [www.sidefx.com]
v@size = getbbox_size ( 0, itoa ( @primnum ) );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- govindk
- Member
- 13 posts
- Joined: Jan. 2019
- Offline
Thank you so much. Appreciate it.
animatrix_I see what messed up. Didn't realise I was changing the geoInput when I was looping.
It's because you are changing the input geometry by changing the first argument in the getbbox_size function. You should use the first input (0), and supply the index to the second argument:
https://www.sidefx.com/docs/houdini/vex/functions/getbbox_size.html [www.sidefx.com]
animatrix_Just to clarify, so even if I did not explicitly create a group, are points and primitives in Houdini already in a group (ptnum & primnum)? I assumed these are reserved attributes.
But because the second argument is a string, you need to convert int to string using the itoa function:
https://www.sidefx.com/docs/houdini/vex/functions/itoa.html [www.sidefx.com]
- tamte
- Member
- 8607 posts
- Joined: July 2007
- Online
govindkwhen iterating over primitives @primnum in wrangle returns current primitive number so (0, 1, 2, ...)
Just to clarify, so even if I did not explicitly create a group, are points and primitives in Houdini already in a group (ptnum & primnum)? I assumed these are reserved attributes.
and numbers are perfectly valid in any group field to represent the actual primitives
what you are essentially doing here is supplying the group name in any form that you can enter in group field as a string
so "0" is valid group and represents primitive 0
same way "1" , etc
so as mentioned the only caveat is that integer @primnum has to be converted to string
it has to be string as you can have "0 1" or "0-10" or named group like "mygroup" or even adhoc group syntax from attribute like "@area>.1", etc. simply any string that normal group fields could resolve
Edited by tamte - Aug. 29, 2021 02:14:18
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- govindk
- Member
- 13 posts
- Joined: Jan. 2019
- Offline
Thank you so much for that explanation Tomas, appreciate it. Coming from other DCC app, I probably went too literal with word 'group.' Before reading through your explanation, to me group meant that I have to explicitly specify a 'group', as in group node, and store values in them. So I was confused as to what if I don't have a group specified.
The example of "@area>.1" made a lot of sense to me - now I see it can be any legal value we can use and in this instance the syntax wants it to be a string.
The example of "@area>.1" made a lot of sense to me - now I see it can be any legal value we can use and in this instance the syntax wants it to be a string.
-
- Quick Links