majikal Posted January 25, 2010 Share Posted January 25, 2010 Hi! if geo.findVertexAttrib("uv") == (): uv_attrib = geo.addAttrib(hou.attribType.Vertex, "uv" , vertPos ) else: uv_attrib = geo.findVertexAttrib("uv") It say that findVertexAttrib return None if attribute doesnt exist. I tried to compare it to () and "None" but nothing works. To what should i compare return of findVertexAttrib to see if it exist. What is None? Empty touple? ty Quote Link to comment Share on other sites More sharing options...
graham Posted January 25, 2010 Share Posted January 25, 2010 (edited) Comparing to () will definitely not give you the correct result because an empty tuple is not equal to None. Comparing to None should work no problem; it always has for me. >>> geo.findVertexAttrib("asdf") is None True >>> geo.findVertexAttrib("asdf") == None True >>> geo.findVertexAttrib("asdf") == () False >>> geo.findVertexAttrib("uv") <hou.Attrib Vertex 'uv' (3 Floats) of geometry in /obj/geo1/texture1> If you want to test for an attribute and if not create it then your code should work fine. I personally always use this since it's slightly less work. uv_attr = geo.findVertexAttrib("uv") if uv_attr is None: geo.addAttrib(hou.attribType.Vertex, "uv", (0.0, 0.0, 0.0)) Edited January 25, 2010 by graham Quote Link to comment Share on other sites More sharing options...
majikal Posted January 25, 2010 Author Share Posted January 25, 2010 thank you... it works.. i looked it up and saw that none is type. is it possible to solve the same problem with try except something like this: try: uv_attrib = geo.addAttrib(hou.attribType.Vertex, "uv" , vertPos ) except hou.OperationFailed: uv_attrib = geo.findVertexAttrib("uv") 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.