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)
def specialSnap(obj=None, targets=None, arg='axisBox', mode='center', castOffset=False): """ Special snap functionality :parameters: obj(str): Object to modify target(str): Object to snap to sourceObject(str): object to copy from :returns success(bool) """ try: _str_func = 'specialSnap' _obj = VALID.mNodeString(obj) _targets = VALID.listArg(targets) if not _targets: _targets = [_obj] if arg not in ['axisBox']: _targets.insert(0, _obj) p = get_special_pos(_targets, arg, mode, False) if castOffset: p_start = TRANS.position_get(_obj) _vector_to_hit = COREMATH.get_vector_of_two_points(p_start, p) _vector_to_start = COREMATH.get_vector_of_two_points(p, p_start) _cast = RAYS.cast(startPoint=p_start, vector=_vector_to_hit) _hit = _cast.get('near') _dist_base = DIST.get_distance_between_points( p_start, p) #...get our base distance _dist_to_hit = DIST.get_distance_between_points( p_start, _hit) #...get our base distance p_result = DIST.get_pos_by_vec_dist(p_start, _vector_to_hit, (_dist_base + _dist_to_hit)) #_cast = RayCast.cast(self.l_mesh, startPoint=_pos_obj,vector=_vec_obj) #_nearHit = _cast['near'] #_dist_firstHit = DIST.get_distance_between_points(_pos_obj,_nearHit) #log.debug("baseDist: {0}".format(_dist_base)) #log.debug("firstHit: {0}".format(_dist_firstHit)) """ if not _m_normal: if self.mode == 'far': _dist_new = _dist_base + _dist_firstHit else: _dist_new = _dist_base - _dist_firstHit _offsetPos = DIST.get_pos_by_vec_dist(_pos_obj,_vec_obj,(_dist_new)) else: log.debug("|{0}| >> mesh normal offset!".format(_str_funcName)) _offsetPos = DIST.get_pos_by_vec_dist(_pos_base,_m_normal,(_dist_firstHit))""" #cgmGEN.func_snapShot(vars()) POS.set(_obj, p_result) return POS.set(_obj, p) except Exception, err: cgmGEN.cgmExceptCB(Exception, err, msg=vars())
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' ]: _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)
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 aim_atPoint(obj=None, position=[0, 0, 0], aimAxis="z+", upAxis="y+", mode='local', vectorUp=None, ignoreAimAttrs=True): """ Aim functionality. :parameters: obj(str): Object to modify position(array): object to copy from aimAxis(str): axis that is pointing forward upAxis(str): axis that is pointing up mode(str): 'local'-- use standard maya aiming with local axis 'world' -- use standard maya aiming with world axis 'matrix' -- use Bokser's fancy method 'vector' -- maya standard with vector up axis 'object' -- maya standard with object ignoreAimAttrs(bool) -- whether to ignore the aim attribute on the control or look for them :returns success(bool) """ try: _str_func = 'aimAtPoint' _loc = False _obj = VALID.objString(obj, noneValid=False, calledFrom=__name__ + _str_func + ">> validate obj") try: position = position.x, position.y, position.z except: pass try: vectorUp = vectorUp.x, vectorUp.y, vectorUp.z except: pass log.debug("|{0}| >> obj: {1} | position:{2} | mode: {3}".format( _str_func, _obj, position, mode)) if not ignoreAimAttrs: _d_aim = ATTR.validate_arg(_obj, 'axisAim') _d_up = ATTR.validate_arg(_obj, 'axisUp') if ATTR.has_attr(_d_aim) and ATTR.has_attr(_d_up): aimAxis = ATTR.get_enumValueString(_d_aim) upAxis = ATTR.get_enumValueString(_d_up) log.debug( "|{0}| >> obj: {1} aimable from attrs. aim: {2} | up: {3}". format(_str_func, _obj, aimAxis, upAxis)) if mode == 'matrix': '''Rotate transform based on look vector''' # get source and target vectors objPos = POS.get(_obj, asEuclid=True) targetPos = MATH.Vector3.Create(position) aim = (targetPos - objPos).normalized() if not vectorUp: upVector = MATH.Vector3.up() if upAxis == "y-": upVector = MATH.Vector3.down() elif upAxis == "z+": upVector = MATH.Vector3.forward() elif upAxis == "z-": upVector = MATH.Vector3.back() elif upAxis == "x+": upVector = MATH.Vector3.right() elif upAxis == "x-": upVector = MATH.Vector3.left() else: upVector = MATH.Vector3.up() vectorUp = MATH.transform_direction(_obj, upVector) wantedAim, wantedUp = MATH.convert_aim_vectors_to_different_axis( aim, vectorUp, aimAxis, upAxis) xformPos = mc.xform(_obj, q=True, matrix=True, ws=True) pos = MATH.Vector3(xformPos[12], xformPos[13], xformPos[14]) rot_matrix = EUCLID.Matrix4.new_look_at(MATH.Vector3.zero(), -wantedAim, wantedUp) s = MATH.Vector3.Create(mc.xform(_obj, q=True, ws=True, s=True)) scale_matrix = EUCLID.Matrix4() scale_matrix.a = s.x scale_matrix.f = s.y scale_matrix.k = s.z scale_matrix.p = 1 result_matrix = rot_matrix * scale_matrix transform_matrix = result_matrix[0:12] + [pos.x, pos.y, pos.z, 1.0] mc.xform(_obj, matrix=transform_matrix, roo="xyz", ws=True) """elif mode == 'world': _loc = mc.spaceLocator()[0] mc.move (position[0],position[1],position[2], _loc, ws=True) mAxis_aim = VALID.simpleAxis(aimAxis) mAxis_up = VALID.simpleAxis(upAxis) _constraint = mc.aimConstraint(_loc,_obj, maintainOffset = False, aimVector = mAxis_aim.p_vector, upVector = mAxis_up.p_vector, worldUpType = 'scene',) mc.delete(_constraint + [_loc])""" elif mode in ['local', 'world', 'vector', 'object']: _loc = mc.spaceLocator(name='test')[0] _loc_snap = POS.create_loc(_obj) mc.move(position[0], position[1], position[2], _loc, ws=True) mAxis_aim = VALID.simpleAxis(aimAxis) mAxis_up = VALID.simpleAxis(upAxis) if mode == 'world': _constraint = mc.aimConstraint( _loc, _loc_snap, maintainOffset=False, aimVector=mAxis_aim.p_vector, upVector=mAxis_up.p_vector, worldUpType='scene', ) elif mode == 'object': vectorUp = VALID.mNodeString(vectorUp) _constraint = mc.aimConstraint(_loc, _loc_snap, maintainOffset=False, aimVector=mAxis_aim.p_vector, upVector=mAxis_up.p_vector, worldUpType='object', worldUpObject=vectorUp) #worldUpVector = _vUp) else: if mode == 'vector': _vUp = vectorUp else: _vUp = MATH.get_obj_vector(_obj, upAxis) _constraint = mc.aimConstraint(_loc, _loc_snap, maintainOffset=False, aimVector=mAxis_aim.p_vector, upVector=mAxis_up.p_vector, worldUpType='vector', worldUpVector=_vUp) go(obj, _loc_snap) mc.delete(_constraint, _loc_snap) else: raise NotImplementedError, "mode: {0}".format(mode) if _loc: mc.delete(_loc) return True except Exception, err: try: mc.delete(_loc) except: pass log.error("aim_atPoint | obj: {0} | err: {1}".format(obj, err))