j00ey Posted July 13, 2013 Share Posted July 13, 2013 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 Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted July 13, 2013 Share Posted July 13, 2013 (edited) 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 July 13, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
j00ey Posted July 13, 2013 Author Share Posted July 13, 2013 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 Quote Link to comment Share on other sites More sharing options...
anim Posted July 13, 2013 Share Posted July 13, 2013 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] Quote Link to comment Share on other sites More sharing options...
j00ey Posted July 13, 2013 Author Share Posted July 13, 2013 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 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.