Atom Posted April 13, 2015 Share Posted April 13, 2015 (edited) Hi All, I am looking for a way to use a python node to fetch the UV coordinates for a given Primitive. I can get the uv attribute but I m not sure how to gain access to the coordinates. Does anyone have any tips or examples? Thanks Edited April 13, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
symek Posted April 13, 2015 Share Posted April 13, 2015 You mean uvs of the vertices' primitive? for prim in geo.prims(): for vertex in prim.vertices(): coord = vertex.attribValue("uv") vertex.setAttribValue("uv", hou.Vector3(coord) * 0.5) Quote Link to comment Share on other sites More sharing options...
Atom Posted April 13, 2015 Author Share Posted April 13, 2015 (edited) Thank you, I think that will do it. Your above example scales all UV coordinates in half. So I am still a bit unclear about the return values from Houdini functions. coord = vertex.attribValue("uv") The return value, coord is a tuple, I think. Is that why you need to convert explicitly to a Vector3 on the next line? When fetching attribValues is it expected to test for type of return value before assuming the variable contents? Edited April 13, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
symek Posted April 14, 2015 Share Posted April 14, 2015 I didn't check it, but since tuple is immutable I assumed that I can't do algebra on it, but hou.Vector3 will handle it. When it comes to return values in general, I think that idea was to make hou modue as fast as possible without making it annoying at the same time. So, if I'm not mistaken, many if not most attributes' functions return tuples, because this is the most efficient way of dealing with conversion from C++ to Python types. There are even more bizarre things like returning all attribute values in byte string which is good for efficiency when you pipe this data further to c++/numerical modules (like numpy). On the other side, linear algebra stuff (matrices, transforms, space conversions etc), returns native hou types, since they don't usually compute a lot - so conversion cost isn't that much. 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.