wandersonp Posted January 15, 2015 Share Posted January 15, 2015 (edited) How can I get a custom prim attribute value? like this fragment of code GA_RWAttributeRef prNum = gdp->findFloatTuple(GA_ATTRIB_PRIMITIVE, "prNum"); GA_RWHandleF prNumHandle(prNum.getAttribute()); GA_FOR_ALL_PRIMITIVES(gdp, prim) { if (prNumHandle.isValid()) { //here how can I get the prNum value like prNum == 12 for example? { gdp->deletePrimitive(*prim, 0); } } } Edited January 15, 2015 by Wanderson Pereira Quote Link to comment Share on other sites More sharing options...
edward Posted January 15, 2015 Share Posted January 15, 2015 prNumHandle.set(prim->getMapOffset(), ... ) Quote Link to comment Share on other sites More sharing options...
wandersonp Posted January 16, 2015 Author Share Posted January 16, 2015 Thanks a lot edward, works perfectly here is the complete cook function with corrections. OP_ERROR MyClass::cookMySop(OP_Context &context) { if (lockInputs(context) >= UT_ERROR_ABORT) return error(); duplicateSource(0, context); GEO_Primitive *prim; const GA_RWAttributeRef prNum = gdp->findFloatTuple(GA_ATTRIB_PRIMITIVE, "prNum"); GA_RWHandleF prNumHandle(prNum); if (prNumHandle.isValid()) { GA_FOR_ALL_PRIMITIVES(gdp, prim) { if (prNumHandle.get(prim->getMapOffset()) == 12.0) { gdp->deletePrimitive(*prim, 0); } } } unlockInputs(); return error(); } Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted January 16, 2015 Share Posted January 16, 2015 (edited) It's more straightforward if you use GA_Iterator. GA_FOR_ALL_PRIMITIVES is still using some GB compatibility and on top of it GEO, so you are losing everything that the new GA library brings to the table. Also, we got OP_AutoLockInputs in H13 and H14, so instead of locking and unlocking manually, use it. auto Foo::cookMySop(Context& context) -> OP_ERROR { OP_AutoLockInputs autolock; auto wasSuccess = autolock.lock(*this, context); if (wasSuccess < UT_ERROR_WARNING && error() < UT_ERROR_WARNING or whatever you want to test along the way ) { // your code } return error(); } I got one in my base class, so it's available in every method that may need it. Edited January 16, 2015 by mantragora 2 Quote Link to comment Share on other sites More sharing options...
wandersonp Posted January 16, 2015 Author Share Posted January 16, 2015 thanks mantragora 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.