Jump to content

trying to get relative path outside an HDA with python{


Recommended Posts

Hi

I'm fairly new to Houdini, and have very little python experience too so excuse me if this is a bit dumb.

I have an HDA with 2 inputs, one is for a high res geometry that's come from a 3D scanner, the other is for a bounding box geometry to cull the scan geo. Inside the HDA is a delete SOP that's set to delete non-selected and I want to get the bouding box size and center from the box input. In Hscript it works like this :

ch(strcat(opinputpath("..",1),"/sizex"))

and so on... but I am totally stumped trying to convert this to python. The reason I want to do that is so that I can eventually write a multi line expression that will say something along the line of :

If input 1 has a connection return size x, else return 10

Can someone give me a help starting?

Thanks very much in advance

Link to comment
Share on other sites

Guest mantragora

You can write mult-line expressions with hscript too.

EDIT: ups, you want path outside HDA, that means you want to find parent of the node you are asking from and ask it for the parameter. Modified python example in file.

example.hip

Edited by mantragora
Link to comment
Share on other sites

Hi

Thank you very much, I didn't know that. I thought it was a good opportunity to learn some python but also good to know I can do it in Hscript too. I guess I can write an if statement in there too..?

I just got it to work in python but it looks pretty clumsy to me :

n=hou.node(".")

p=n.node("..")

ins=p.inputs()

num = len(ins)

if (num>1):

bbox=ins[1]

x=bbox.parm("sizex").eval()

else :

x=100

return x

Link to comment
Share on other sites

I guess you can rather get bbox information from geometry than relaying on the input node to have sizex parameter

like

if(opexist(opinputpath("..",1)), bbox(opinputpath("..",1), D_XSIZE),10 )[/CODE]

or in Python

[CODE]
hda = pwd().parent()
inputs = hda.inputs()
if len(inputs)>1:
return inputs[1].geometry().boundingBox().sizevec()[0]
return 10[/CODE]

Link to comment
Share on other sites

That's great! Thanks Tomas.

Good point about the bounding box, it's just a tool for my own use and I'm plugging a box in to cull the mesh [just so I can visualise the bounding area] so sizex will work in this case but it would make it more robust to do it your way.

Thanks again

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...