Jump to content

resolve takes into main


Recommended Posts

Hi there, I've used takes to help setup a simulation. Now that I have the sim the way I want, I would like to just get rid of all the extra takes, but resolve the take parameters for a particular take into the main scene take. Does that make any sense?

I know I can just copy over the parameters manually, but there's gotta be a quicker way, and without missing a parameter.

I don't see a way to do this in the take manager, unless im missing something ;)

Thanks!

Link to comment
Share on other sites

  • 3 years later...

Hi, I must be missing something very simple in the syntax:

Trying to merge take1 to main.

/ -> takemerge main take1
Unable to find destination take main

After that, I figured it must be the capitalization of Main..

/ -> takemerge Main take1
Couldn't merge source take take1

But still not working..

I tried looking for examples from other take commands that requires a <take> as an argument.. closest I got was for takename.

/ -> takename take1 take1b

That one works.

As a semi-workaround. I created a new take under Main, and renamed it "master".

/ -> takemerge master take1

Now the takemerge works.. but only for sibling takes.

Is it possible to merge a take to Main using takemerge?

On 8/6/2013 at 2:21 AM, substep said:

hmmm, this doesnt seem to work for merging things into the "Main" take.

edit: nm, it seems the destination take must be the active take when merging.

Were you able to merge it to the Main? If so, what syntax did you use? :)

Link to comment
Share on other sites

  • 5 months later...

I got a python code working (so far). This collects the parameters set by the takes, then transfers those to the Main take.

Simply set to a take you want to resolve to main, then run the code.

mTake = hou.takes.rootTake()
cTake = hou.takes.currentTake()
if mTake.name == cTake.name:
    hou.ui.displayMessage('Please set to a Take other than the \'Main\' take.')
else:
    tParms = cTake.parmTuples()
    nodes, parms, value = [], [], []
    for p in tParms:
        nodes.append(p.node())
        parms.append(p.name())
        value.append(p.eval())
    hou.takes.setCurrentTake(mTake)
    for i in range(len(nodes)):
        nodes[i].parm(parms[i]).set(value[i][0])

Current limitation is that this will not include parent takes. I'll try and add recursion on my next free time.

Link to comment
Share on other sites

  • 1 year later...

Hi Galagast, thanks for your take merge snippet. Unfortunately I had some issues with it, but I could fix it:

main_take = hou.takes.rootTake()
current_take = hou.takes.currentTake()
if main_take.name == current_take.name:
    hou.ui.displayMessage('Please set to a Take other than the \'Main\' take.')
else:
    parameter_tuples = current_take.parmTuples()
    parameter_value_dict = {}
    for parameter_tuple in parameter_tuples:
        for parameter_tuple in parameter_tuples:
            for parameter in  parameter_tuple:
                parameter_value_dict[parameter.path()] = parameter.eval()
    hou.takes.setCurrentTake(main_take)
    for key, value in parameter_value_dict.items():
        print 'setting current parameter %s == %s' % ( key, value)
        hou.parm( key ).set( value )
    print 'merged %s Take into Main' % current_take.name()


I was also to lazy to make it recursive, so it doesn't takes care of parent takes.

 

Link to comment
Share on other sites

  • 1 year later...

After some time has passed I figured out that Houdini offers a very handy solution to merge a take in to the main take. It's the addParmTuplesFromTake function:
 

main_take = hou.takes.rootTake()
current_take = hou.takes.currentTake()
if main_take.name == current_take.name:
    hou.ui.displayMessage('Please set to a Take other than the \'Main\' take.')
else:
    hou.takes.setCurrentTake( main_take )
    main_take.addParmTuplesFromTake(current_take)
    print 'merged %s Take into Main' % current_take.name()

The only thing that I couldn't figure out was a solution to also merge the display, render and bypass flags into the main take.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Here a script that takes also display-,render- and bypass-flags into account:
 

main_take = hou.takes.rootTake()
current_take = hou.takes.currentTake()

def getAllFlagStates():
    flags_dict = {}
    for node in hou.node('/').allSubChildren():
        flags_dict[ node.path() ] = {}
        flags_dict[ node.path() ]['Display'] = node.isGenericFlagSet(hou.nodeFlag.Display)
        flags_dict[ node.path() ]['Render'] = node.isGenericFlagSet(hou.nodeFlag.Render)
        flags_dict[ node.path() ]['Bypass'] = node.isGenericFlagSet(hou.nodeFlag.Bypass)
    return flags_dict

if main_take.name == current_take.name:
    hou.ui.displayMessage('Please set to a Take other than the \'Main\' take.')
else:
    flags_dict = getAllFlagStates()
    hou.takes.setCurrentTake( main_take )
    main_take.addParmTuplesFromTake(current_take)
    
    for node_path in flags_dict:
        node = hou.node( node_path )
        if node.isGenericFlagSet( hou.nodeFlag.Display ) != flags_dict[ node_path ]['Display']:
            node.setGenericFlag( hou.nodeFlag.Display, flags_dict[ node_path ]['Display'] )
        if node.isGenericFlagSet( hou.nodeFlag.Render ) != flags_dict[ node_path ]['Render']:
            node.setGenericFlag( hou.nodeFlag.Render, flags_dict[ node_path ]['Render'] )
        if node.isGenericFlagSet( hou.nodeFlag.Bypass ) != flags_dict[ node_path ]['Bypass']:
            node.setGenericFlag( hou.nodeFlag.Bypass, flags_dict[ node_path ]['Bypass'] )
    print 'merged %s Take into Main' % current_take.name()

 

  • Like 1
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...