sibarrick Posted July 26, 2005 Share Posted July 26, 2005 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? Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 26, 2005 Author Share Posted July 26, 2005 It's ok I found this FOR_ALL_GROUP_PRIMITIVES(gdp, grp, prim) what's the difference between that and FOR_SAFE_GROUP_PRIMITIVES and FOR_ALL_OPT_GROUP_PRIMITIVES and FOR_MASK_PRIMITIVES Quote Link to comment Share on other sites More sharing options...
George Posted July 27, 2005 Share Posted July 27, 2005 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. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted July 27, 2005 Share Posted July 27, 2005 Ah... very useful! Thank you George!!! Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted July 27, 2005 Share Posted July 27, 2005 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. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 27, 2005 Author Share Posted July 27, 2005 FOR_ALL_OPT_GROUP_PRIMITIVES 19923[/snapback] So cool, just what I need, saves me writing two routines one for group one for none. Good stuff. Thanks again George. Quote Link to comment Share on other sites More sharing options...
George Posted July 27, 2005 Share Posted July 27, 2005 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.