m0rtezaaghili Posted May 22, 2013 Share Posted May 22, 2013 i have one function called HDways. i wrote it from tutorial and on the tutorial is working good but for me not I'm confused, why not working pointsIDs = [] points = [] pointsIDs.append(int(node.getAttribute('id'))) points.append(point) def HDways(xmlData): ways = xmlData.getElementsByTagName('way') for way in ways: wayPoints = [] nodes = way.getElementsByTagName('nd') for node in nodes: ref = int(node.getAttribute('ref')) try: index = pointsIDs.index(ref) except ValueError: index = -1 if (index != -1): wayPoints = append(points[index]) poly = geo.createPolygon() for point in wayPoints: poly.addVertex(point)[/CODE] Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted May 22, 2013 Share Posted May 22, 2013 (edited) i have one function called HDways. i wrote it from tutorial and on the tutorial is working good but for me not I'm confused, why not working node.getAttribute('id')[/CODE] There is no getAttribute() method in HOU. Try findPointAttrib(), findPrimAttrib(), findGlobalAttrib(), findVertexAttrib() or even better, read this book because it looks that you don't have any experience with programming.Good luck!PS.There may be other issues with the code too. Can't check it without the scene. Edited May 22, 2013 by mantragora 1 Quote Link to comment Share on other sites More sharing options...
MarcelK Posted May 22, 2013 Share Posted May 22, 2013 (edited) Wouldn't it be better to advice him a book for Python 2.x? A byte of python (the one for python 2) is good or check out the course at MIT OpenCourseWare. Edited May 22, 2013 by MarcelK Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted May 22, 2013 Share Posted May 22, 2013 (edited) Wouldn't it be better to advice him a book for Python 2.x? Nope. Why? Because there are multiple bad practices that will stop working when Houdini will get upgrade to Python3. For example, usage of "%d" % foo vs "{0}".format(foo) or print() function working without braces in Py2 while in Py3 requires them always. PS. @m0rtezaaghili, link to your portfolio doesn't work Edited May 22, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
m0rtezaaghili Posted May 22, 2013 Author Share Posted May 22, 2013 (edited) thanks guys. i'm newcomer in houdini and does't know anything about it! so i watching the tutorials and then coding. i upload the scene here and hope you help me to fix this error just unzip Map2.rar and set in Map File. thanks PS: @ mantragora : why not? its working for me dude! try this url project.zip Edited May 22, 2013 by m0rtezaaghili Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted May 22, 2013 Share Posted May 22, 2013 (edited) PS: @ mantragora : why not? its working for me dude! try this url This works. As for the code, getAttribute() is for XML and it indeed should work but there are some name clashes, so your code breaks. For example: nodes = xmlData.getElementsByTagName('node') for node in nodes: You use here node variable in for loop but it clashes with default node = hou.pwd() variable specified on begin of pythonSOP. And Houdini nodes are not XML nodes. Fixed.zip Edited May 22, 2013 by mantragora 1 Quote Link to comment Share on other sites More sharing options...
m0rtezaaghili Posted May 22, 2013 Author Share Posted May 22, 2013 (edited) This works. As for the code, getAttribute() is for XML and it indeed should work but there are some name clashes so your code breaks. For example: You use here node variable in for loop but it clashes with default variable specified on begin of pythonSOP. And Houdini nodes are not XML nodes. Thanks mantragora Tomas is helped me to fix this error i was wrote on this code " = " Rather than " . " here : wayPoints = append(points[index])[/CODE]thanks all Edited May 22, 2013 by m0rtezaaghili 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.