Jump to content
csp

Python Take List

Recommended Posts

I want, with given the parent take name to get a list of all take children in Python?

The Hscript command is: http://www.sidefx.co...ommands/takels

but unfortunately python version is not yet implemented.

What I want to do is easier for me in python. I could use hou.script("takels") but the result is not clean.

example:

 ('  1\n  2\n  3\n  4\n  5\n  6\n', '') [/CODE]

Let me explain what I am after.

I am building a tool where I want the user to be able to have a parent take and then a list of children with different values on the tool. Then on the DA he will have to select the parent take and hit render.

Pseudocode:

[CODE]
parent = "mainTake"
children = hou.script("takels -p mainTake")
for each children:
create a geoRop and set take parameter
end forloop.
link all geoRops to a mergeRop
[/CODE]

Any idea how to do that? The most tricky part for me is how to get children takes in an array.

Edited by cparliaros

Share this post


Link to post
Share on other sites

You can just call split() on the first string in the result and it will remove all the extraneous whitespace and new line characters. Then, you just need to construct your ROPs.

parent = "mainTake"
childTakes = hou.hscript("takels -p {0}".format(parent))[0].split()

OUT = hou.node("/out")
merge = OUT.createNode("merge")

for takeName in childTakes:
    geo = OUT.createNode("geometry", takeName)
    geo.parm("take").set(takeName)
    geo.moveToGoodPosition()

    merge.setNextInput(geo)

merge.moveToGoodPosition()
merge.render()

  • Like 2

Share this post


Link to post
Share on other sites

thank you very much graham,

I had pretty much the same script as you have above, the only I was missing was your second line:

chilgTakes = hou.hscript("takels -p {0}".format(parent))[0].split()[/CODE]

[/size][/color][/size][/color]

split() does more than I was thinking!

Edited by cparliaros

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×