Ejemplo n.º 1
0
def getControlsFromObjs( control ):
	'''
	attempts to retrieve the pole vector control, the ik handle and all fk controls given an ik rig control.  The
	information is returned in a 3 tuple containing:

	ikHandle, poleControl, fkControls
	'''
	errorValue = None, None, None, None

	try:
		part = rigPrimitives.RigPart.InitFromItem( control )

		return part.getControl( 'control' ), part.getIkHandle(), part.getControl( 'poleControl' ), part.getFkControls()
	except rigPrimitives.RigPartError: pass

	#so if the control we've been given isn't a rig primitive, lets try to extract whatever information we can from right click commands - if any exist
	trigger = Trigger( ikControl )
	switchCmdStr = None
	for n, cmdName, cmdStr in trigger.iterMenus():
		if cmdName.lower() == _IK_CMD_NAME:
			switchCmdStr = trigger.resolve( cmdStr )
			break

	if switchCmdStr is None:
		printWarningStr( "Cannot find the %s command - aborting!" % _IK_CMD_NAME )
		return errorValue

	#extract the control handle from the switch command - it may or may not exist, depending on which
	rexStr = re.compile( '-ikHandle \%([a-ZA-Z0-9_:|]+)', re.IGNORECASE | re.MULTILINE )
	match = rexStr.search( switchCmdStr )
	if not match:
		if match.groups()[0]:
			control = match.groups()[0]

	#extract the ik handle from the switch command
	rexStr = re.compile( '-ikHandle \%([a-ZA-Z0-9_:|]+)', re.IGNORECASE | re.MULTILINE )
	match = rexStr.search( switchCmdStr )
	if not match:
		printWarningStr( "Could not determine the ik handle from the given control" )
		return errorValue

	handle = match.groups()[0]
	if handle is None:
		printWarningStr( "Could not find the ik handle at the given connect index!" )
		return errorValue

	#now extract the pole control from the switch command
	rexStr = re.compile( '-pole \%([a-ZA-Z0-9_:|]+)', re.IGNORECASE | re.MULTILINE )
	match = rexStr.search( switchCmdStr )
	if not match:
		printWarningStr( "Could not determine the pole vector control from the given control" )
		return errorValue

	poleControl = match.groups()[0]
	if poleControl is None:
		printWarningStr( "Could not find the ik handle at the given connect index!" )
		return errorValue

	return control, poleControl, handle, getJointsFromIkHandle( handle )
def findSpaceAttrNode(obj):
    '''
	returns the node that contains the parent attribute for the space switch
	'''
    parentAttrOn = ""
    trigger = Trigger(obj)

    for slotIdx, slotName, slotCmd in trigger.iterMenus():
        if slotName.startswith('parent to '):
            cmdStrObj = ChangeSpaceCmd(slotCmd)
            connectToken = cmdStrObj.getConnectToken()

            return trigger.resolve(connectToken)
Ejemplo n.º 3
0
def findSpaceAttrNode( obj ):
	'''
	returns the node that contains the parent attribute for the space switch
	'''
	parentAttrOn = "";
	trigger = Trigger( obj )

	for slotIdx, slotName, slotCmd in trigger.iterMenus():
		if slotName.startswith( 'parent to ' ):
			cmdStrObj = ChangeSpaceCmd( slotCmd )
			connectToken = cmdStrObj.getConnectToken()

			return trigger.resolve( connectToken )
Ejemplo n.º 4
0
def getControlsFromObjs(control):
    '''
	attempts to retrieve the pole vector control, the ik handle and all fk controls given an ik rig control.  The
	information is returned in a 3 tuple containing:

	ikHandle, poleControl, fkControls
	'''
    errorValue = None, None, None, None

    try:
        part = rigPrimitives.RigPart.InitFromItem(control)

        return part.getControl('control'), part.getIkHandle(), part.getControl(
            'poleControl'), part.getFkControls()
    except rigPrimitives.RigPartError:
        pass

    #so if the control we've been given isn't a rig primitive, lets try to extract whatever information we can from right click commands - if any exist
    trigger = Trigger(ikControl)
    switchCmdStr = None
    for n, cmdName, cmdStr in trigger.iterMenus():
        if cmdName.lower() == _IK_CMD_NAME:
            switchCmdStr = trigger.resolve(cmdStr)
            break

    if switchCmdStr is None:
        printWarningStr("Cannot find the %s command - aborting!" %
                        _IK_CMD_NAME)
        return errorValue

    #extract the control handle from the switch command - it may or may not exist, depending on which
    rexStr = re.compile('-ikHandle \%([a-ZA-Z0-9_:|]+)',
                        re.IGNORECASE | re.MULTILINE)
    match = rexStr.search(switchCmdStr)
    if not match:
        if match.groups()[0]:
            control = match.groups()[0]

    #extract the ik handle from the switch command
    rexStr = re.compile('-ikHandle \%([a-ZA-Z0-9_:|]+)',
                        re.IGNORECASE | re.MULTILINE)
    match = rexStr.search(switchCmdStr)
    if not match:
        printWarningStr(
            "Could not determine the ik handle from the given control")
        return errorValue

    handle = match.groups()[0]
    if handle is None:
        printWarningStr(
            "Could not find the ik handle at the given connect index!")
        return errorValue

    #now extract the pole control from the switch command
    rexStr = re.compile('-pole \%([a-ZA-Z0-9_:|]+)',
                        re.IGNORECASE | re.MULTILINE)
    match = rexStr.search(switchCmdStr)
    if not match:
        printWarningStr(
            "Could not determine the pole vector control from the given control"
        )
        return errorValue

    poleControl = match.groups()[0]
    if poleControl is None:
        printWarningStr(
            "Could not find the ik handle at the given connect index!")
        return errorValue

    return control, poleControl, handle, getJointsFromIkHandle(handle)