Jump to content

Python Take List


csp

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
Link to comment
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
Link to comment
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
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...