Primitive created in Attribwrangle not showing up in group

   1585   3   1
User Avatar
Member
2 posts
Joined: July 2021
Offline
Hello everyone,

I am a bit stuck with my VEX code, as I am trying to use only VEX in one Attrib Wrangle (Primitives) to do this whole process. Meaning using other SOPs is not an option. I am not a full beginner but not an expert either, so please bear with me.
I am getting a polyline in input, so a prim with points. I created in VEX a sphere prim that would need to be checked for intersection with the polyline, by going through all its segments using
intersect
in a while loop. That means that I need to use a group to point to only the sphere in
intersect
. Otherwise it will always return that there is an intersection happening, between the polyline and itself since it uses its points to calculate the origins and directions of the intersecting ray. Imagine a sort of a boolean goal logic between the sphere and the polyline.


int origin = addpoint(0,origin_pos);
int sphere = addprim(0, "sphere", origin);
setprimintrinsic(0, "transform", sphere, radius * matrix3(ident()));
string s_group = "s_group";
setprimgroup(0, s_group, sphere, 1, "set");

My sphere is behaving correctly when referencing its primnum to change its radius or its origin point to move it later on. The thing is, when I check if the sphere prim is in the group with
int test = inprimgroup(0, "s_group", sphere)
, it says no. When checking with other methods such as
nprimitivesgroup(0, "s_group")
, it doesn't return anything either. However, in the Geometry spreadsheet, it does say in the primitives that the sphere's primnum has an attrib value of 1 in the attrib column "group:s_group", contrarily to the other primitives.

Then of course, it returns -1 when I try to use "s_group" as a string group name in the
intersect
function:

int intersect = intersect(0, "s_group", pt_origin, dir, pos, uv);

So I am wondering what I did wrong or if there is another way to do this whole process?

Thank you so much!
User Avatar
Member
2659 posts
Joined: June 2008
Offline
That's the nature of VEX and wrangles. You have to exit the wrangle for some of your manipulations to become "live". Try following up your test in a second primitive wrangle to see it it worked. You may have to split your code across two wrangles.
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
User Avatar
Member
2 posts
Joined: July 2021
Offline
I see, thank you for your help! I'm trying to use only one wrangle as a constraint so I'll try another method. Thanks again!
  • Quick Links