Jump to content

Gb_primitivegroup


Recommended Posts

Hi all,

How do you loop through the members of a GB_PrimitiveGroup and access the elements stored within it.

I can see lots of methods for adding, removing, toggling, jumping to next and previous in the list but how do you actually get the value for an element?

I'm assuming everything is stored as GB_Elements and I just want to be able to access them.... can't see any obvious methods for reading the data.

Any ideas?

Link to comment
Share on other sites

FOR_ALL_GROUP_PRIMITIVES: loops through all the primitives in a group, you have to supply a valid group pointer or it will crash.

FOR_SAFE_GROUP_PRIMITIVES: This one keeps track of the current primitive and the next primitive after that. The idea is that if you wanted to delete the current primitive you're on, you already have the next prim in hand... otherwise you would try to grab the next primitive from a primitive you just deleted.

FOR_ALL_OPT_GROUP_PRIMITIVES: This one is like FOR_ALL_GROUP_PRIMITIVES, except that you can pass it a NULL as a group, in which case it will loop through all primitives.

FOR_MASK_PRIMITIVES: Loops through all the primitives of a given mask. The masks are defined in GEO_PrimType.h

Hope that helps,

George.

Link to comment
Share on other sites

FOR_SAFE_GROUP_PRIMITIVES: This one keeps track of the current primitive and the next primitive after that.  The idea is that if you wanted to delete the current primitive you're on, you already have the next prim in hand... otherwise you would try to grab the next primitive from a primitive you just deleted.

Oh the irony!

I spent an hour today trying to figure out why my

FOR_ALL_PRIMITIVES(gdp,prim) {

gdp->deletePrimitive(prim);

}

was deleting every other primitive. =P

Finally I came upon the FOR_SAFE_PRIMITIVES.....if only i had been more lazy and read the forums sooner. :)

On another note GB_ExtraMacros.h is full of macro love.

Link to comment
Share on other sites

So cool, just what I need, saves me writing two routines one for group one for none. Good stuff.

Thanks again George.

19934[/snapback]

Yeah, that one comes in handy a lot... it gives you the default behaviour of most Houdini SOPs where if the Group field is empty it operates on everything -- without having ugly if's all over the place :)

Cheers,

George.

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...