1

I’m starting as a programmer and currently working on a project but got stuck + have a bit of a brain fart(sorry).

I need to write a tool that will:

1 - set character rig by selecting character in the scene and set script to remember selection.

2 - evaluate whether selected character rig has a namespace or not (depending on that the next step takes different root)

if there is a namespace:

3 - find control in the character rig [namespace] + [side L\R] + [Ctrl]

4 - select target loc and snap one to another then bake animation

if there is no namespace: 3 - find control in the character rig [side L\R] + [Ctrl]

4 - select target loc and snap one to another then bake animation

I wrote parts of the script but don’t know how to put it together because I don’t know how to word this condition in the script.

Can anyone help me to put my brain back in order?

CH = pm.ls(sl=True, fl=True)

for c in CH:
    if pm.referenceQuery(c, isNodeReferenced=True):
        nameSpace = c.split(':')[0] + ':'
        nameS.append(nameSpace)
        name = nameSpace + 'L' + '_Weapon_ctrl'
        print name
        else:
        name = 'L' + '_Weapon_ctrl'
        print name
    
def bakeToObj():
    Target = pm.ls(sl=True, fl=True)[0]
    
    pm.cutKey(Weapon)
    par = pm.parentConstraint([Target] + [Weapon], mo=False)
    
    startTime = pm.playbackOptions(query=True, minTime=True)
    endTime = pm.playbackOptions(query=True, maxTime=True)
    
    pm.bakeResults(Weapon, simulation=True, t=(startTime, endTime))
    
    pm.showHidden(above=True)
    
    pm.delete(par)
    return bakeToObj

    

1 Answers1

0

I recommend to continue where you started. The list ist a very good start. Now you can create a script with all functions you need for the list of tasks and one function to call them all, e.g.:

def getSelectedCharacterRig():
    sel = pm.ls(sl=True, fl=True)
    return sel

def getCtrlName(rig):
    ....
    return ctrlName

def findCtrl(ctrlName):
    ...
    return ctrl

def selectTargetLoc(ctrl):
    ...

def bake(someObject):
    return bakedObject

def doIt():
    selection = getSelectedCharacterRig()
    ctrlName = getCtrlName(selection)
    ...

This way you can see what you need an how to do it. And you will see if a function is not needed at all.

haggi krey
  • 1,885
  • 1
  • 7
  • 9