Exemple #1
0
def frameRate_set(arg):
    _str_func = 'frameRate_set'
    log.debug(cgmGEN.logString_start(_str_func))

    if VALID.valueArg(arg):
        _arg = '{0}fps'.format(arg)

    else:
        d_validArgs = {
            'ntsc': ['n', 'ntsc'],
            'pal': ['p', 'pal'],
            'film': ['f', 'film'],
            'game': ['g', 'game'],
            'ntscf': ['ntscf']
        }

        _arg = VALID.kw_fromDict(arg,
                                 d_validArgs,
                                 calledFrom=_str_func,
                                 noneValid=True)

    if not _arg:
        _arg = arg

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(time=_arg)
def defaultTangents_set(arg, inTangent=True, outTangent=True):
    _str_func = 'defaultTangents_set'
    log.debug(cgmGEN.logString_start(_str_func))

    d_validArgs = {
        'linear': ['ln', 'linear'],
        'spline': ['sp', 'spline'],
        'clamped': ['cl', 'clamped'],
        'flat': ['fl', 'flat'],
        'plateau': ['pl', 'plateau'],
        'auto': ['au', 'auto']
    }
    _arg = VALID.kw_fromDict(arg, d_validArgs, calledFrom=_str_func)

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    #Couldn't use True for setting the Tangent type had to use _arg

    _d = {'g': 1}
    if inTangent:
        _d['itt'] = _arg
    if outTangent:
        _d['ott'] = _arg

    mc.keyTangent(**_d)
def sceneUp_set(arg):
    _str_func = 'sceneUp_set'
    log.debug(cgmGEN.logString_start(_str_func))

    d_validArgs = {'y': ['y'], 'z': ['z']}

    _arg = VALID.kw_fromDict(arg, d_validArgs, calledFrom=_str_func)

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.upAxis(ax=_arg, rv=1)
def angularUnit_set(arg):
    _str_func = 'angularUnit_set'
    log.debug(cgmGEN.logString_start(_str_func))

    d_validArgs = {
        'deg': ['deg', 'degree', 'degrees'],
        'rad': ['rad', 'radian']
    }

    _arg = VALID.kw_fromDict(arg, d_validArgs, calledFrom=_str_func)

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(angle=_arg)
def frameRate_set(arg, fixFractionalSlider=True):
    _str_func = 'frameRate_set'
    log.debug(cgmGEN.logString_start(_str_func))

    if VALID.valueArg(arg):
        _arg = '{0}fps'.format(arg)

    else:
        d_validArgs = {
            'ntsc': ['n', 'ntsc'],
            'pal': ['p', 'pal'],
            'film': ['f', 'film'],
            'game': ['g', 'game'],
            'ntscf': ['ntscf']
        }

        _arg = VALID.kw_fromDict(arg,
                                 d_validArgs,
                                 calledFrom=_str_func,
                                 noneValid=True)

    if not _arg:
        _arg = arg

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(time=_arg)

    if fixFractionalSlider:
        log.debug(cgmGEN.logString_msg(_str_func, 'fixFractionalSlider...'))
        _current = mc.currentTime(q=True)
        mc.playbackOptions(
            animationStartTime=int(
                mc.playbackOptions(q=True, animationStartTime=True)),
            animationEndTime=int(
                mc.playbackOptions(q=True, animationEndTime=True)),
            max=int(mc.playbackOptions(q=True, max=True)),
            min=int(mc.playbackOptions(q=True, min=True)),
        )
        mc.currentTime(int(_current))
def distanceUnit_set(arg):
    _str_func = 'distanceUnit_set'
    log.debug(cgmGEN.logString_start(_str_func))

    d_validArgs = {
        'm': ['meter', 'metre'],
        'cm': ['centimeter', 'centi'],
        'mm': ['milimeter', 'mili'],
        'yd': ['yard'],
        'in': ['inch', 'inches'],
        'ft': ['feet', 'foot']
    }

    _arg = VALID.kw_fromDict(arg, d_validArgs, calledFrom=_str_func)

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(linear=_arg)
Exemple #7
0
def get_by_dist(source=None,
                targets=None,
                mode='close',
                resMode='point',
                sourcePivot='rp',
                targetPivot='rp'):
    """
    Get the the closest return based on a source and target and variable modes
    
    :parameters:
        :source(str): Our base object to measure from
        :targets(list): List of object types
        :mode(str):What mode are we checking data from
            close
            far
        :resMode(str):
            object -- return the [closest] target
            point -- return the [closest] point
            #component -- return [the closest] base component
            pointOnSurface -- [closest] point on the target shape(s)
            pointOnSurfaceLoc -- [closest] point on target shape(s) Loc'd
            shape -- gets closest point on every shape, returns closest
        resMode(str)
    :returns
        [res,distance]
    """
    def get_fromTargets(sourcePos, targets, targetPivot, resMode, mode):
        _l_distances = []
        _l_pos = []
        for t in targets:
            _tarPos = POS.get(t, targetPivot, space='world')
            _l_pos.append(_tarPos)
            _d = get_distance_between_points(sourcePos, _tarPos)
            log.debug(
                "|{0}| >> target: {1} | pivot: {4} | dist: {3} | pos: {2}...| mode: {5}"
                .format(_str_func, t, _tarPos, _d, targetPivot, mode))
            _l_distances.append(_d)
        if mode == 'close':
            _minDist = min(_l_distances)
            _minIdx = _l_distances.index(_minDist)
            if resMode == 'point': return _l_pos[_minIdx], _minDist
            return targets[_minIdx], _minDist
        else:
            _maxDist = max(_l_distances)
            _maxIdx = _l_distances.index(_maxDist)
            if resMode == 'point': return _l_pos[_maxIdx], _maxDist
            return targets[_maxIdx], _maxDist

    _d_by_dist_modes = {
        'close': ['closest', 'c', 'near'],
        'far': ['furthest', 'long']
    }

    _str_func = 'get_by_dist'
    _source = VALID.objString(source,
                              noneValid=False,
                              calledFrom=__name__ + _str_func +
                              ">> validate targets")
    _mode = VALID.kw_fromDict(mode,
                              _d_by_dist_modes,
                              noneValid=False,
                              calledFrom=__name__ + _str_func +
                              ">> validate mode")
    _resMode = resMode
    _l_targets = VALID.objStringList(targets,
                                     noneValid=False,
                                     calledFrom=__name__ + _str_func +
                                     ">> validate targets")

    _sourcePivot = VALID.kw_fromDict(sourcePivot,
                                     SHARED._d_pivotArgs,
                                     noneValid=False,
                                     calledFrom=__name__ + _str_func +
                                     ">> validate sourcePivot")
    _targetPivot = VALID.kw_fromDict(targetPivot,
                                     SHARED._d_pivotArgs,
                                     noneValid=False,
                                     calledFrom=__name__ + _str_func +
                                     ">> validate targetPivot")

    log.debug("|{0}| >> source: {1} | mode:{2} | resMode:{3}".format(
        _str_func, _source, _mode, _resMode))

    #Source==============================================================
    _sourcePos = POS.get(_source, _sourcePivot, space='ws')
    log.debug("|{0}| >> Source pos({2}): {1}...".format(
        _str_func, _sourcePos, _sourcePivot))

    #Modes
    if _resMode in ['object', 'point']:
        log.debug("|{0}| >> object resMode...".format(_str_func))
        mc.select(cl=True)

        _res = get_fromTargets(_sourcePos, _l_targets, _targetPivot, _resMode,
                               _mode)
        if resMode == 'object':
            mc.select(_res[0])
            return _res[0]
        return _res[0]
    elif _resMode == 'component':
        raise NotImplementedError, "component mode"
    elif _resMode in ['pointOnSurface', 'shape', 'pointOnSurfaceLoc']:
        log.debug("|{0}| >> Shape processing...".format(_str_func))
        #Targets=============================================================
        log.debug("|{0}| >> Targets processing...".format(_str_func))
        _d_targetTypes = {}
        _l_pos = []
        _l_dist = []
        _l_shapes = []
        """for t in _l_targets:
            _t = t
            _bfr_component = VALID.get_component(t)
            if _bfr_component:
                _t = _bfr_component[1]#...shape
            _type = VALID.get_mayaType(_t)
            if _type not in _d_targetTypes.keys():
                _d_targetTypes[_type] = [_t]
            else:
                _d_targetTypes[_type].append(_t)
            log.debug("|{0}| >> obj: {1} | type: {2}".format(_str_func,t,_type))"""
        #cgmGen.log_info_dict(_d_targetTypes,'Targets to type')

        for t in _l_targets:
            res = get_closest_point(_sourcePos, t)
            if not res:
                log.error("|{0}| >> {1} -- failed".format(_str_func, t))
            else:
                log.debug("|{0}| >> {1}: {2}".format(_str_func, t, res))
                _l_pos.append(res[0])
                _l_dist.append(res[1])
                _l_shapes.append(res[2])

        if not _l_dist:
            log.error("|{0}| >> Failed to find any points".format(_str_func))
            return False
        closest = min(_l_dist)
        _idx = _l_dist.index(closest)

        if _resMode == 'pointOnSurfaceLoc':
            _loc = mc.spaceLocator(n='get_by_dist_loc')[0]
            POS.set(_loc, _l_pos[_idx])
            return _loc
        if _resMode == 'shape':
            mc.select(_l_shapes[_idx])
            return _l_shapes[_idx]
        return _l_pos[_idx]
Exemple #8
0
def get_special_pos(targets=None, arg='rp', mode=None, mark=False):
    """
    This had to move here for import loop considerations

    :parameters:
        obj(str): Object to modify
        target(str): Object to snap to
        sourceObject(str): object to copy from
        arg
            rp
            sp
            boundingBoxEach
            boundingBoxAll - all targets bounding box cumulative
            axisBox
            castFar
            castNear
            groundPos
        mode - Relative to 
            center
            front
            x

    :returns
        success(bool)
    """
    try:
        _str_func = 'get_special_pos'
        _sel = mc.ls(sl=True) or []

        targets = VALID.listArg(targets)
        _targets = VALID.mNodeStringList(targets)

        if not _targets:
            raise ValueError, "Must have targets!"

        _arg = VALID.kw_fromDict(arg,
                                 SHARED._d_pivotArgs,
                                 noneValid=True,
                                 calledFrom=__name__ + _str_func +
                                 ">> validate pivot")
        if _arg is None:
            _arg = arg

        if _arg == 'cast':
            _arg = 'castNear'

        if mode is None:
            if _arg in ['boundingBox']:
                mode = 'center'
            else:
                mode = 'z+'

        l_nameBuild = ['_'.join([NAMES.get_base(o) for o in _targets]), _arg]
        if mode:
            l_nameBuild.append(mode)
        l_res = []
        if _arg in ['rp', 'sp']:
            for t in _targets:
                l_res.append(POS.get(t, _arg, 'world'))
        elif _arg == 'boundingBox':
            l_res.append(POS.get_bb_pos(_targets, False, mode))
        elif _arg == 'boundingBoxShapes':
            l_res.append(POS.get_bb_pos(_targets, True, mode))
        elif _arg == 'boundingBoxEach':
            for t in _targets:
                l_res.append(POS.get_bb_pos(t, False, mode))
        elif _arg == 'boundingBoxEachShapes':
            for t in _targets:
                l_res.append(POS.get_bb_pos(t, True, mode))
        elif _arg == 'groundPos':
            for t in targets:
                pos = TRANS.position_get(t)
                l_res.append([pos[0], 0.0, pos[2]])
        elif _arg.startswith('castAll'):
            _type = _arg.split('castAll')[-1].lower()
            log.debug("|{0}| >> castAll mode: {1} | {2}".format(
                _str_func, mode, _type))
            pos = RAYS.get_cast_pos(_targets[0],
                                    mode,
                                    _type,
                                    None,
                                    mark=False,
                                    maxDistance=100000)
            l_res.append(pos)
        elif _arg.startswith('cast'):
            _type = _arg.split('cast')[-1].lower()
            log.debug("|{0}| >> cast mode: {1} | {2}".format(
                _str_func, mode, _type))
            if len(_targets) > 1:
                log.debug("|{0}| >> more than one target...".format(_str_func))
                pos = RAYS.get_cast_pos(_targets[0],
                                        mode,
                                        _type,
                                        _targets[1:],
                                        mark=False,
                                        maxDistance=100000)
            else:
                pos = RAYS.get_cast_pos(_targets[0],
                                        mode,
                                        _type,
                                        _targets,
                                        mark=False,
                                        maxDistance=100000)
            if not pos:
                return False
            l_res.append(pos)
        elif _arg == 'axisBox':
            log.warning("|{0}| >> axisBox mode is still wip".format(_str_func))
            if not targets:
                raise ValueError, "No targets in axisBox cast!"
            for t in targets:
                log.debug("|{0}| >> AxisBox cast: {1} ".format(_str_func, t))
                _proxy = CORERIG.create_axisProxy(t)
                #Start point is bb center because rp can sometimes be in odd places and we care about the axisBox
                pos = RAYS.get_cast_pos(t,
                                        mode,
                                        'near',
                                        _proxy,
                                        startPoint=POS.get(_proxy, 'bb'),
                                        mark=False,
                                        maxDistance=100000)

                log.debug("|{0}| >> AxisBox dat: {1}".format(_str_func, pos))
                #if not pos:
                #    pprint.pprint(vars())
                l_res.append(pos)
                mc.delete(_proxy)
        else:
            raise ValueError, "|{0}| >> Unknown mode: {1}".format(
                _str_func, _arg)

        #cgmGEN.func_snapShot(vars())

        if len(l_res) > 1:
            _res = DIST.get_average_position(l_res)
        else:
            _res = l_res[0]

        if mark:
            _loc = mc.spaceLocator()[0]
            mc.move(_res[0], _res[1], _res[2], _loc, ws=True)
            mc.rename(_loc, '{0}_loc'.format('_'.join(l_nameBuild)))
        if _sel and not mark:
            mc.select(_sel)
        return _res
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Exemple #9
0
def snap(obj=None,
         targets=None,
         position=True,
         rotation=True,
         rotateAxis=False,
         rotateOrder=False,
         rotatePivot=False,
         scalePivot=False,
         objPivot='rp',
         objMode=None,
         objLoc=False,
         targetPivot='rp',
         targetMode=None,
         targetLoc=False,
         queryMode=False,
         space='w',
         mark=False,
         **kws):
    """
    Core snap functionality.


    :parameters:
        obj(str): Object to modify
        target(str): Objects to snap to
        objPivot
        targetPivot
        objMode =
        targetMode

        position
        rotation
        rotateAxis
        rotateOrder
        scalePivot
        space
        mark


    :returns
        success(bool)
    """
    try:
        _str_func = 'snap'

        try:
            obj = obj.mNode
        except:
            pass

        _obj = VALID.mNodeString(obj)
        if targets is None:
            log.debug("|{0}| >> self target... ".format(_str_func))
            _targets = [_obj]
        else:
            _targets = VALID.mNodeStringList(targets)
        reload(VALID)
        _pivotObj = VALID.kw_fromDict(objPivot,
                                      SHARED._d_pivotArgs,
                                      noneValid=True)
        _pivotTar = VALID.kw_fromDict(targetPivot,
                                      SHARED._d_pivotArgs,
                                      noneValid=True)

        _space = VALID.kw_fromDict(space,
                                   SHARED._d_spaceArgs,
                                   noneValid=False,
                                   calledFrom=__name__ + _str_func +
                                   ">> validate space")
        log.debug(
            "|{0}| >> obj: {1}({2}-{3}) | target:({4}-{5})({6}) | space: {7}".
            format(_str_func, _obj, _pivotObj, objMode, _pivotTar, targetMode,
                   _targets, _space))
        log.debug(
            "|{0}| >> position: {1} | rotation:{2} | rotateAxis: {3} | rotateOrder: {4}"
            .format(_str_func, position, rotation, rotateAxis, rotateOrder))

        kws_xform = {'ws': False, 'os': False}
        if _space == 'world':
            kws_xform['ws'] = True
        else:
            kws_xform['os'] = True

        #Mode type defaults...
        if objMode is None:
            if _pivotObj is 'boundingBox':
                objMode = 'center'
            elif _pivotObj in ['castCenter', 'castFar', 'castNear', 'axisBox']:
                objMode = 'z+'
        if targetMode is None:
            if _pivotTar is 'boundingBox':
                targetMode = 'center'
            elif _pivotTar in ['castCenter', 'castFar', 'castNear', 'axisBox']:
                targetMode = 'z+'

        if _pivotTar in ['castFar', 'castAllFar', 'castNear', 'castAllNear']:
            if targetMode == 'center':
                log.debug(
                    "|{0}| >> Center target mode invalid with {1}. Changing to 'z+' "
                    .format(_str_func, _pivotTar))
                targetMode = 'z+'

        #cgmGEN.func_snapShot(vars())

        if position or objLoc or targetLoc or rotatePivot or scalePivot:
            kws_xform_move = copy.copy(kws_xform)
            if _pivotTar == 'sp':
                kws_xform_move['spr'] = True
            else:
                kws_xform_move['rpr'] = True

            #>>>Target pos ------------------------------------------------------------------------------
            log.debug(
                "|{0}| >> Position True. Getting target pivot pos {1} ".format(
                    _str_func, _pivotTar))
            l_nameBuild = [
                '_'.join([NAMES.get_base(o) for o in _targets]), _pivotTar
            ]
            if targetMode and _pivotTar not in [
                    'sp', 'rp', 'closestPoint', 'groundPos'
            ]:
                l_nameBuild.append(targetMode)

            l_pos = []
            if _pivotTar in ['sp', 'rp']:
                log.debug("|{0}| >> xform query... ".format(_str_func))
                for t in _targets:
                    l_pos.append(POS.get(t, _pivotTar, _space))
                pos_target = DIST.get_average_position(l_pos)
            elif _pivotTar == 'closestPoint':
                log.debug("|{0}|...closestPoint...".format(_str_func))
                pos_target = DIST.get_by_dist(_obj,
                                              _targets,
                                              resMode='pointOnSurface')
            else:
                log.debug("|{0}| >> special query... ".format(_str_func))
                _targetsSpecial = copy.copy(_targets)
                if _pivotTar not in [
                        'axisBox', 'groundPos', 'castCenter', 'boundingBox'
                ]:
                    _targetsSpecial.insert(0, _obj)
                pos_target = get_special_pos(_targetsSpecial, _pivotTar,
                                             targetMode)

            if not pos_target:
                return log.error("No position detected")
            if targetLoc:
                _loc = mc.spaceLocator()[0]
                mc.move(pos_target[0],
                        pos_target[1],
                        pos_target[2],
                        _loc,
                        ws=True)
                mc.rename(_loc, '{0}_loc'.format('_'.join(l_nameBuild)))

            log.debug("|{0}| >> Target pivot: {1}".format(
                _str_func, pos_target))

            #>>>Obj piv ------------------------------------------------------------------------------
            log.debug("|{0}| >> Getting obj pivot pos {1} ".format(
                _str_func, _pivotObj))
            l_nameBuild = [NAMES.get_base(_obj), _pivotObj]
            if objMode and _pivotObj not in [
                    'sp', 'rp', 'closestPoint', 'groundPos'
            ]:
                l_nameBuild.append(objMode)

            l_pos = []
            if _pivotObj in ['sp', 'rp']:
                log.debug("|{0}| >> xform query... ".format(_str_func))
                pos_obj = POS.get(_obj, _pivotObj, _space)
            elif _pivotObj == 'closestPoint':
                log.debug("|{0}|...closestPoint...".format(_str_func))
                pos_obj = DIST.get_by_dist(_targets[0],
                                           _obj,
                                           resMode='pointOnSurface')
            else:
                log.debug("|{0}| >> special query... ".format(_str_func))
                pos_obj = get_special_pos(_obj, _pivotObj, objMode)

            if objLoc:
                _loc = mc.spaceLocator()[0]
                mc.move(pos_obj[0], pos_obj[1], pos_obj[2], _loc, ws=True)
                mc.rename(_loc, '{0}_loc'.format('_'.join(l_nameBuild)))

            log.debug("|{0}| >> Obj pivot: {1}".format(_str_func, pos_obj))

            if queryMode:
                pprint.pprint(vars())
                log.warning("|{0}| >> Query mode. No snap".format(_str_func))
                mc.select([_obj] + _targets)
                return True

            #>>>Obj piv ------------------------------------------------------------------------------
            if position:
                log.debug("|{0}| >> Positioning... ".format(_str_func))
                if _pivotObj == 'rp':
                    TRANS.position_set(obj, pos_target)
                    #POS.set(_obj, pos_target)
                else:
                    p_start = TRANS.position_get(_obj)
                    _vector_to_objPivot = COREMATH.get_vector_of_two_points(
                        p_start, pos_obj)
                    _dist_base = DIST.get_distance_between_points(
                        p_start, pos_obj)  #...get our base distance
                    p_result = DIST.get_pos_by_vec_dist(
                        pos_target, _vector_to_objPivot, -_dist_base)

                    cgmGEN.func_snapShot(vars())
                    POS.set(_obj, p_result)

        if rotateAxis:
            log.debug("|{0}|...rotateAxis...".format(_str_func))
            mc.xform(obj,
                     ra=mc.xform(_targets[0], q=True, ra=True, **kws_xform),
                     p=True,
                     **kws_xform)
        if rotateOrder:
            log.debug("|{0}|...rotateOrder...".format(_str_func))
            mc.xform(obj, roo=mc.xform(_targets[0], q=True, roo=True), p=True)
        if rotation:
            log.debug("|{0}|...rotation...".format(_str_func))
            _t_ro = ATTR.get_enumValueString(_targets[0], 'rotateOrder')
            _obj_ro = ATTR.get_enumValueString(obj, 'rotateOrder')
            if _t_ro != _obj_ro:
                #Creating a loc to get our target space rotateOrder into new space
                log.debug(
                    "|{0}|...rotateOrders don't match...".format(_str_func))
                _loc = mc.spaceLocator(n='tmp_roTranslation')[0]
                ATTR.set(_loc, 'rotateOrder', _t_ro)
                rot = mc.xform(_targets[0], q=True, ro=True, **kws_xform)
                mc.xform(_loc, ro=rot, **kws_xform)
                mc.xform(_loc, roo=_obj_ro, p=True)
                rot = mc.xform(_loc, q=True, ro=True, **kws_xform)
                mc.delete(_loc)
            else:
                rot = mc.xform(_targets[0], q=True, ro=True, **kws_xform)
            mc.xform(_obj, ro=rot, **kws_xform)
        if rotatePivot:
            log.debug("|{0}|...rotatePivot...".format(_str_func))
            mc.xform(obj, rp=pos_target, p=True, **kws_xform)
        if scalePivot:
            log.debug("|{0}|...scalePivot...".format(_str_func))
            mc.xform(obj, sp=pos_target, p=True, **kws_xform)
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Exemple #10
0
def go(obj = None, target = None,
       position = True, rotation = True, rotateAxis = False,rotateOrder = False, scalePivot = False,
       pivot = 'rp', space = 'w', mode = 'xform'):
    """
    Core snap functionality. We're moving an object by it's rp to move it around. The scale pivot may be snapped as well
    
    :parameters:
        obj(str): Object to modify
        target(str): Object to snap to
        sourceObject(str): object to copy from

    :returns
        success(bool)
    """   
    _str_func = 'go'
    
    try:obj = obj.mNode
    except:pass    
    
    _obj = VALID.mNodeString(obj)
    _target = VALID.mNodeString(target)
    
    _pivot = VALID.kw_fromDict(pivot, SHARED._d_pivotArgs, noneValid=False,calledFrom= __name__ + _str_func + ">> validate pivot")
    _space = VALID.kw_fromDict(space,SHARED._d_spaceArgs,noneValid=False,calledFrom= __name__ + _str_func + ">> validate space")  
    #_mode = VALID.kw_fromDict(mode,_d_pos_modes,noneValid=False,calledFrom= __name__ + _str_func + ">> validate mode")
    _mode = mode
    log.debug("|{0}| >> obj: {1} | target:{2} | pivot: {5} | space: {3} | mode: {4}".format(_str_func,_obj,_target,_space,_mode,_pivot))             
    log.debug("|{0}| >> position: {1} | rotation:{2} | rotateAxis: {3} | rotateOrder: {4}".format(_str_func,position,rotation,rotateAxis,rotateOrder))             
    
    kws = {'ws':False,'os':False}
    if _space == 'world':
        kws['ws']=True
    else:kws['os']=True  
    
    #cgmGEN.walk_dat(kws)
    
    if position:
        kws_move = copy.copy(kws)
        if _pivot == 'sp':
            kws_move['spr'] = True
        else:
            kws_move['rpr'] = True
            
        if _pivot == 'closestPoint':
            log.debug("|{0}|...closestPoint...".format(_str_func))        
            _targetType = SEARCH.get_mayaType(_target)
            p = DIST.get_by_dist(_obj,_target,resMode='pointOnSurface')
            POS.set(_obj,p)
                
        else:
            log.debug("|{0}|...postion...".format(_str_func))
            pos = POS.get(target,_pivot,_space,_mode)
            #log.debug(pos)
            #cgmGEN.print_dict(kws,'move kws','snap.go')
            mc.move (pos[0],pos[1],pos[2], _obj, **kws_move)
            #log.debug(POS.get(_obj))
    if rotateAxis:
        log.debug("|{0}|...rotateAxis...".format(_str_func))        
        mc.xform(obj,ra = mc.xform(_target, q=True, ra=True, **kws), p=True, **kws)    
    if rotateOrder:
        log.debug("|{0}|...rotateOrder...".format(_str_func))
        mc.xform(obj,roo = mc.xform(_target, q=True, roo=True), p=True)
    if rotation:
        log.debug("|{0}|...rotation...".format(_str_func))
        _t_ro = ATTR.get_enumValueString(_target,'rotateOrder')
        _obj_ro = ATTR.get_enumValueString(obj,'rotateOrder')
        
        if _t_ro != _obj_ro:
            #Creating a loc to get our target space rotateOrder into new space
            log.debug("|{0}|...rotateOrders don't match...".format(_str_func))
            _loc = mc.spaceLocator(n='tmp_roTranslation')[0]
            ATTR.set(_loc,'rotateOrder',_t_ro)
            rot = mc.xform (_target, q=True, ro=True, **kws )   
            mc.xform(_loc, ro = rot, **kws)
            mc.xform(_loc, roo = _obj_ro, p=True)
            rot = mc.xform (_loc, q=True, ro=True, **kws )   
            mc.delete(_loc)
        else:
            rot = mc.xform (_target, q=True, ro=True, **kws )
        mc.xform(_obj, ro = rot, **kws)
    
    if scalePivot:
        log.debug("|{0}|...scalePivot...".format(_str_func))
        mc.xform(obj,sp = mc.xform(_target, q=True, sp=True,**kws), p=True, **kws)
        

    return
    pos = infoDict['position']
    
    mc.move (pos[0],pos[1],pos[2], _target, ws=True)
    mc.xform(_target, roo=infoDict['rotateOrder'],p=True)
    mc.xform(_target, ro=infoDict['rotation'], ws = True)
    mc.xform(_target, ra=infoDict['rotateAxis'],p=True)
    
    #mTarget = r9Meta.getMObject(target)
    mc.xform(_target, rp=infoDict['position'], ws = True, p=True)        
    mc.xform(_target, sp=infoDict['scalePivot'], ws = True, p=True)    
def get(obj=None,
        pivot='rp',
        space='ws',
        targets=None,
        mode='xform',
        asEuclid=False):
    """
    General call for querying position data in maya.
    Note -- pivot and space are ingored in boundingBox mode which returns the center pivot in worldSpace
    
    :parameters:
        obj(str): Object to check
            Transform, components supported
        pivot(str): Which pivot to use. (rotate,scale,boundingBox)
            rotatePivot
            scalePivot
            boundingBox -- Returns the calculated center pivot position based on bounding box
        space(str): World,Object,Local
        mode(str):
            xform -- Utilizes tranditional checking with xForm or pointPosition for components
        asEuclid(bool) - whether to return as Vector or not
    :returns
        success(bool)
    """
    try:
        _str_func = 'get_pos'
        _obj = VALID.mNodeString(obj)
        _pivot = VALID.kw_fromDict(pivot,
                                   SHARED._d_pivotArgs,
                                   noneValid=False,
                                   calledFrom=_str_func)
        _targets = VALID.stringListArg(targets,
                                       noneValid=True,
                                       calledFrom=_str_func)
        _space = VALID.kw_fromDict(space,
                                   SHARED._d_spaceArgs,
                                   noneValid=False,
                                   calledFrom=_str_func)
        _mode = VALID.kw_fromDict(mode,
                                  _d_pos_modes,
                                  noneValid=False,
                                  calledFrom=_str_func)
        _res = False

        if _pivot == 'boundingBox':
            log.debug("|{0}|...boundingBox pivot...".format(_str_func))
            _res = get_bb_center(_obj)
            if MATH.is_vector_equivalent(
                    _res, [0, 0, 0]) and not mc.listRelatives(_obj, s=True):
                _pivot = 'rp'
                log.warning(
                    "|{0}|...boundingBox pivot is zero, using rp....".format(
                        _str_func))

        if '[' in _obj:
            log.debug("|{0}| >> component mode...".format(_str_func))
            if ":" in _obj.split('[')[-1]:
                raise ValueError, "|{0}| >>Please specify one obj. Component list found: {1}".format(
                    _str_func, _obj)
            #_cType = VALID.get_mayaType(_obj)
            _l_comp = VALID.get_component(_obj)
            _root = _l_comp[1]
            _cType = _l_comp[3]
            if not VALID.is_shape(_root):
                _shapes = mc.listRelatives(_root, s=True, fullPath=True) or []
                if len(_shapes) > 1:
                    log.warning(
                        "|{0}| >>More than one shape found. To be more accurate, specify: {1} | shapes: {2}"
                        .format(_str_func, _obj, _shapes))
                _root = _shapes[0]

            _OBJ = '.'.join([_root, _l_comp[0]])

            log.debug(
                "|{0}| >> obj: {1}({6}) | type: {2} | pivot: {3} | space: {4} | mode: {5}"
                .format(_str_func, _OBJ, _cType, _pivot, _space, _mode, _obj))

            kws_pp = {'world': False, 'local': False}
            if _space == 'world': kws_pp['world'] = True
            else: kws_pp['local'] = True

            if _cType == 'polyVertex':
                _res = mc.pointPosition(_OBJ, **kws_pp)
            elif _cType == 'polyEdge':
                mc.select(cl=True)
                mc.select(_OBJ)
                mel.eval("PolySelectConvert 3")
                edgeVerts = mc.ls(sl=True, fl=True)
                posList = []
                for vert in edgeVerts:
                    posList.append(mc.pointPosition(vert, **kws_pp))
                _res = MATH.get_average_pos(posList)
            elif _cType == 'polyFace':
                mc.select(cl=True)
                mc.select(_OBJ)
                mel.eval("PolySelectConvert 3")
                edgeVerts = mc.ls(sl=True, fl=True)
                posList = []
                for vert in edgeVerts:
                    posList.append(mc.pointPosition(vert, **kws_pp))
                _res = MATH.get_average_pos(posList)
            elif _cType in [
                    'surfaceCV', 'curveCV', 'editPoint', 'surfacePoint',
                    'curvePoint', 'cv', 'bezierCurve'
            ]:
                _res = mc.pointPosition(_OBJ, **kws_pp)
                #_res =  mc.pointPosition(_OBJ)
            else:
                raise RuntimeError, "|{0}| >> Shouldn't have gotten here. Need another check for component type. '{1}'".format(
                    _str_func, _cType)

        else:
            log.debug(
                "|{0}| >> obj: {1} | pivot: {2} | space: {3} | mode: {4} | asEuclid: {5}"
                .format(_str_func, _obj, _pivot, _space, _mode, asEuclid))
            if _space == 'local' or _pivot == 'local':
                _res = ATTR.get(_obj, 'translate')
            #elif _pivot == 'local':
            #if _space == 'world':
            #    _res = mc.xform(_obj, q=True, rp = True, ws=True )
            #else:
            #    _res = ATTR.get(_obj,'translate')
            else:
                kws = {
                    'q': True,
                    'rp': False,
                    'sp': False,
                    'os': False,
                    'ws': False
                }
                if _pivot == 'rp': kws['rp'] = True
                else: kws['sp'] = True

                if _space == 'object': kws['os'] = True
                else: kws['ws'] = True

                log.debug("|{0}| >> xform kws: {1}".format(_str_func, kws))

                _res = mc.xform(_obj, **kws)

        if _res is not None:
            if asEuclid:
                log.debug("|{0}| >> asEuclid...".format(_str_func))
                return EUCLID.Vector3(_res[0], _res[1], _res[2])
            return _res
        raise RuntimeError, "|{0}| >> Shouldn't have gotten here: obj: {1}".format(
            _str_func, _obj)
    except Exception, err:
        cgmGen.cgmExceptCB(Exception, err)
def set(obj=None, pos=None, pivot='rp', space='ws', relative=False):
    """
    General call for querying position data in maya.
    Note -- pivot and space are ingored in boundingBox mode which returns the center pivot in worldSpace
    
    :parameters:
        obj(str): Object to check
            Transform, components supported
        pivot(str): Which pivot to use to base movement from (rotate,scale)
        space(str): World,Object
    :returns
        success(bool)
    """
    try:
        _str_func = 'set_pos'
        _obj = VALID.mNodeString(obj)
        _pivot = VALID.kw_fromDict(pivot,
                                   SHARED._d_pivotArgs,
                                   noneValid=False,
                                   calledFrom=_str_func)
        _space = VALID.kw_fromDict(space,
                                   SHARED._d_spaceArgs,
                                   noneValid=False,
                                   calledFrom=_str_func)

        try:
            pos = [pos.x, pos.y, pos.z]
        except:
            pass
        _pos = pos

        if VALID.is_component(_obj):
            kws = {'ws': False, 'os': False, 'r': relative}
            if _space == 'object':
                kws['os'] = True
                #kws['rpr'] = False
            else:
                kws['ws'] = True

            log.debug("|{0}| >> xform kws: {1}".format(_str_func, kws))

            return mc.move(_pos[0], _pos[1], _pos[2], _obj,
                           **kws)  #mc.xform(_obj,**kws )
        else:
            log.debug("|{0}| >> obj: {1} | pos: {4} | pivot: {2} | space: {3}".
                      format(_str_func, _obj, _pivot, _space, _pos))
            if _space == 'local' or _pivot == 'local':
                ATTR.set(_obj, 'translate', pos)
            else:
                kws = {
                    'rpr': False,
                    'spr': False,
                    'os': False,
                    'ws': False,
                    'r': relative
                }

                if _pivot == 'rp': kws['rpr'] = True
                else: kws['spr'] = True

                if _space == 'object':
                    kws['os'] = True
                    kws['rpr'] = False
                else:
                    kws['ws'] = True

                log.debug("|{0}| >> xform kws: {1}".format(_str_func, kws))

                return mc.move(_pos[0], _pos[1], _pos[2], _obj,
                               **kws)  #mc.xform(_obj,**kws )
    except Exception, err:
        cgmGen.cgmExceptCB(Exception, err)