Jump to content

error in running Function


m0rtezaaghili

Recommended Posts

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 :mellow:


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]

:wub:

Link to comment
Share on other sites

Guest mantragora

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 :mellow:


node.getAttribute('id')
[/CODE]

:wub:

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 by mantragora
  • Like 1
Link to comment
Share on other sites

Guest mantragora

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 by mantragora
Link to comment
Share on other sites

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 by m0rtezaaghili
Link to comment
Share on other sites

Guest mantragora

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.

post-7494-0-53639700-1369257529_thumb.jp

Fixed.zip

Edited by mantragora
  • Like 1
Link to comment
Share on other sites

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 :wub:

Edited by m0rtezaaghili
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...