adamvanner Posted July 12, 2014 Share Posted July 12, 2014 I have a python SOP otl im converting to VEX using the PointWrangle SOP - the OTL processes attribs that may or may not be present; I'd need to keep this behaviour. But.. I noticed that: vector orient; if(isbound("my_attrib")) { import("my_attrib", orient, 0); orient = some_blah(orient); v@my_attrib = orient; // CREATES the attrib even if isbound() is false } will create @my_attrib, even if it doesnt exist. I tried this: if(isbound("my_attrib")) { import("my_attrib", orient, 0); orient = some_blah(orient); setpointattrib(geoself(), "my_attrib", @ptnum, orient); // Doesnt create, but doesnt work either } But, maybe a limitation of PointWrangle, this does nothing. Any other ways of setting this attrib? Thanks! Quote Link to comment Share on other sites More sharing options...
MENOZ Posted July 12, 2014 Share Posted July 12, 2014 (edited) I'm not super expert in vex, but shouldn't you use addattribute instead of setpointattr ? http://www.sidefx.com/docs/houdini13.0/vex/functions/addattribute EDIT: i'm not sure what you want to do, but if you want to check if you have an attribute you can use "haspointattrib" function. in a pointWrangle, this works for me. if(haspointattrib(0,"my_attribute")) { addattribute("newAttrib",5); }; I don't know how to create an attribute in an attributeWrangle.It doesn't seem to recognise the addattribute function. I can Set an existing attribute but not create one, without using the @ syntax Edited July 12, 2014 by MENOZ Quote Link to comment Share on other sites More sharing options...
adamvanner Posted July 12, 2014 Author Share Posted July 12, 2014 ahh that looks like a much more appropriate function thank you!,.. shame it still doesnt seem to set the value (it does when I use @my_attrib) Ive tried this and this: addattribute("my_attrib", orient); addattribute("my_attrib", orient, "type", "vector"); so to sum up: This works (but always adds the attrib, even when I dont want it to) v@my_attrib = orient; This doesnt addattribute("my_attrib", orient); which seems odd? Quote Link to comment Share on other sites More sharing options...
MENOZ Posted July 13, 2014 Share Posted July 13, 2014 I didn't tried this yet, but to set an attribute you should use a separate function like setpointattrib. http://www.sidefx.com/docs/houdini13.0/vex/functions/setpointattrib the reason why @ always is executed is in another thread: http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=151709#151709 hey Adam, I've just read your name, is it you from dneg? Quote Link to comment Share on other sites More sharing options...
anim Posted July 13, 2014 Share Posted July 13, 2014 just to be clear not all VEX function work in all VEX contexts so pointwrangle has import(), addattribute() and no setattrib() attribwrangle has setattrib() functions and no inport(), addattribute() those 2 functions are similar but not equivalent, for your case though they both should do what you want @ syntax always creates the attribute as it's mapped to export variable, unless you exclude attribute's name from exporting, in that case @ would only read so if you want to avoid @ syntax in pointwrangle use: vector attr = 0; if ( import("my_attrib", attr, 0) ) { attr += {1,1,1}; addattribute("my_attrib", attr); } for attribwrangle: vector attr = 0; if ( haspointattrib(0, "my_attrib") ) { attr = point(0, "my_attrib", @ptnum) * {2,2,2} + {1,0,0} ; setpointattrib(0, "my_attrib", @ptnum, attr, "set"); } 1 Quote Link to comment Share on other sites More sharing options...
adamvanner Posted July 13, 2014 Author Share Posted July 13, 2014 in pointwrangle use: vector attr = 0; if ( import("my_attrib", attr, 0) ) { attr += {1,1,1}; addattribute("my_attrib", attr); } Thanks Thomas, yes I tried exactly this in PointWrangle but even in a very simple case - literally as you have but a different attrib name, assigning using @ works fine, but with addattribute does nothing.. its odd- I dont see what Im doing wrong - could run this in the VOPSOP instead, but this should work? hey Adam, I've just read your name, is it you from dneg? Hey Andrea! Ha yes I should have just waited until tomorrow to ask you about this in rounds, eh?! Quote Link to comment Share on other sites More sharing options...
anim Posted July 14, 2014 Share Posted July 14, 2014 not sure what doesn't work for you do you have non-working example? here is an example which modifies attribute only if exists (both point and attribwrangle) , if it doesn't it will not create one created in H13 modify_attr_only_if_exists.hip Quote Link to comment Share on other sites More sharing options...
adamvanner Posted July 14, 2014 Author Share Posted July 14, 2014 (edited) ahh great - yes so looks like it was the use of isbound() - I guess that is detecting attribs bound using @ notation rather than being present in the inputs.. all working perfectly with haspointattrib(), import() and addattribute() .. thanks a million! Edited July 14, 2014 by adamvanner 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.