Jump to content

Python - Correct Me If I'm Wrong


Tamis

Recommended Posts

object has no attribute setPosition

This means only that python cannot find "setPosition" name in object's dictionary. "attribute misleads here. Python doesn't care if this a method or attribute...

As Hammy already figured out, another problem comes from variable type expected by setPosition method. Look on function's declaration. It expects one sequence of floats (vector, tuple etc) not three floats.

Which example you're trying to mimic?

Edited by SYmek
Link to comment
Share on other sites

thnx hammy that works ! how did you know: "hou.pwd().geometry().points()" was a array ?

SYmek:

i was tryng to mimic your litle code:

geo = hou.pwd().geometry()

for pt in geo.points():

pos = pt.position()

pt.setPosition([pos[0]+2, pos[1], pos[2]])

btw do you guys know if there is like a Module browser aplication out there for python to brows moduals(in a grhapical way) ?

that would sure make life easyr because if i say dir(hou) i already become dissy because of the amount of tekst the console prints out.

Link to comment
Share on other sites

I think this code is not mine but anyway...

points() returns list (not an array) because it's called points not point - so there will be many of them ;)

Seriously you should use "print" statement for debugging purposes. If you open python shell, houdini will sent python stdout there. So you can use "print" inside Python SOP to see what is happening there.

HOM's help is not very handy. I think something more like a python's doc server would be better. I just don't know how to force it to see hou modules... specially under Windows. In Linux it's enough to add houdini path to python path I suppose.

Edited by SYmek
Link to comment
Share on other sites

you mean make python see hou under windows ?

enviorment variable:

PYTHONPATH

C:\Program Files\Side Effects Software\Houdini 9.0.794\houdini\scripts\python

sadly it needs a .dll or something so you won't be able to use it in the Python Shell but you can use the path brouwser witch is kinda cool.

Link to comment
Share on other sites

you mean make python see hou under windows ?

enviorment variable:

PYTHONPATH

C:\Program Files\Side Effects Software\Houdini 9.0.794\houdini\scripts\python

sadly it needs a .dll or something so you won't be able to use it in the Python Shell but you can use the path brouwser witch is kinda cool.

ye, that is what I was meant. I went through this path ;). I also asked SESI on the very beginning of HOM to prepare HOM help in similar way, so you can see all objects methods on one page with one look - this is crucial for a programming. Nice method listing in current help simply doesn't work. That's funny somehow that such a small issue can make a whole HOM Help unusable. Personally I use exclusively dir(object) way.

cheers,

sy.

Link to comment
Share on other sites

It seems like findClosestPoint() is not being implemented yet. In such a case you can use hscript command with hou.hscriptExpression() method.

You could also simple loop through points to find smallest distance. This would be the slowest solution in terms of computation but it's even interesting comparison between hscript command (HOM in future) and pure python computation. I suspect this wouldn't be very efficient when it came to heave geometry.

Anyway I'm pretty sure VEX would leave behind the rest of competitors here.

Edited by SYmek
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...