def setup_hotKey(self): self.validate_hotkeySet() _press = '' if self._valid_cmdPress: #_press = mc.nameCommand( self._valid_cmdPress + 'COMMAND', annotation=self._valid_cmdPress, command=self._valid_cmdPress) _press = self._valid_cmdPress _release = '' if self._valid_cmdRelease: #_release = mc.nameCommand( self._valid_cmdRelease + 'COMMAND', annotation=self._valid_cmdRelease, command=self._valid_cmdRelease) _release = self._valid_cmdRelease _d = { 'keyShortcut': self._d_fromUI.get('hotkey', self._d_kws['hotkey']), 'name': _press, 'releaseName': _release, 'altModifier': False, 'ctrlModifier': False, 'shiftModifier': False } _l_order = ['keyShortcut'] _modifer = self.validateModifier() if _modifer and _modifer + 'Modifier' in _d.keys(): _d[_modifer + 'Modifier'] = True if mayaVersion < 2016: _d.pop('shiftModifier') if _modifer == 'shift': log.error( "The shiftModifer was added in Maya 2016. Cannot setup.") return cgmGeneral.log_info_dict(_d, 'hotkey args') _k = _d.get('keyShortcut') log.info(_k) log.info(_d) mc.hotkey(_k, **_d) #...run it mc.savePrefs( hk=True) #...have to save prefs after setup or it won't keep
def setup_hotKey(self): self.validate_hotkeySet() _press = '' if self._valid_cmdPress: #_press = mc.nameCommand( self._valid_cmdPress + 'COMMAND', annotation=self._valid_cmdPress, command=self._valid_cmdPress) _press = self._valid_cmdPress _release = '' if self._valid_cmdRelease: #_release = mc.nameCommand( self._valid_cmdRelease + 'COMMAND', annotation=self._valid_cmdRelease, command=self._valid_cmdRelease) _release = self._valid_cmdRelease _d = {'keyShortcut':self._d_fromUI.get('hotkey', self._d_kws['hotkey']), 'name':_press, 'releaseName':_release, 'altModifier':False, 'ctrlModifier':False, 'shiftModifier':False} _l_order = ['keyShortcut'] _modifer = self.validateModifier() if _modifer and _modifer+'Modifier' in _d.keys(): _d[_modifer+'Modifier'] = True if mayaVersion < 2016: _d.pop('shiftModifier') if _modifer == 'shift': log.error("The shiftModifer was added in Maya 2016. Cannot setup.") return cgmGeneral.log_info_dict(_d,'hotkey args') _k = _d.get('keyShortcut') log.info(_k) log.info(_d) mc.hotkey(_k,**_d)#...run it mc.savePrefs(hk = True)#...have to save prefs after setup or it won't keep
def raySnap_start(targets=[], create=None, drag=False, snap=True, aim=False): _str_func = 'raySnap_start' _toSnap = False _toAim = False if not targets: targets = mc.ls(sl=True) if snap: if not create or create == 'duplicate': #targets = mc.ls(sl=True)#...to use g to do again?... _toSnap = targets log.debug("|{0}| | targets: {1}".format(_str_func, _toSnap)) if not _toSnap: if create == 'duplicate': log.error( "|{0}| >> Must have targets to duplicate!".format( _str_func)) return if aim: _toAim = targets var_rayCastMode = cgmMeta.cgmOptionVar('cgmVar_rayCastMode', defaultValue=0) var_rayCastOffsetMode = cgmMeta.cgmOptionVar('cgmVar_rayCastOffsetMode', defaultValue=0) var_rayCastOffsetDist = cgmMeta.cgmOptionVar('cgmVar_rayCastOffsetDist', defaultValue=1.0) var_rayCastTargetsBuffer = cgmMeta.cgmOptionVar( 'cgmVar_rayCastTargetsBuffer', defaultValue=['']) var_rayCastOrientMode = cgmMeta.cgmOptionVar('cgmVar_rayCastOrientMode', defaultValue=0) var_objDefaultAimAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultAimAxis', defaultValue=2) var_objDefaultUpAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultUpAxis', defaultValue=1) var_objDefaultOutAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultOutAxis', defaultValue=0) var_rayCastDragInterval = cgmMeta.cgmOptionVar( 'cgmVar_rayCastDragInterval', defaultValue=.2) var_aimMode = cgmMeta.cgmOptionVar('cgmVar_aimMode', defaultValue='world') _rayCastMode = var_rayCastMode.value _rayCastOffsetMode = var_rayCastOffsetMode.value _rayCastTargetsBuffer = var_rayCastTargetsBuffer.value _rayCastOrientMode = var_rayCastOrientMode.value _objDefaultAimAxis = var_objDefaultAimAxis.value _objDefaultUpAxis = var_objDefaultUpAxis.value _objDefaultOutAxis = var_objDefaultOutAxis.value _rayCastDragInterval = var_rayCastDragInterval.value log.debug("|{0}| >> Mode: {1}".format(_str_func, _rayCastMode)) log.debug("|{0}| >> offsetMode: {1}".format(_str_func, _rayCastOffsetMode)) kws = { 'mode': 'surface', 'mesh': None, 'closestOnly': True, 'create': 'locator', 'dragStore': False, 'orientMode': None, 'objAimAxis': SHARED._l_axis_by_string[_objDefaultAimAxis], 'objUpAxis': SHARED._l_axis_by_string[_objDefaultUpAxis], 'objOutAxis': SHARED._l_axis_by_string[_objDefaultOutAxis], 'aimMode': var_aimMode.value, 'timeDelay': .1, 'offsetMode': None, 'dragInterval': _rayCastDragInterval, 'offsetDistance': var_rayCastOffsetDist.value } #var_rayCastOffsetDist.value if _rayCastTargetsBuffer: log.debug("|{0}| >> Casting at buffer {1}".format( _str_func, _rayCastMode)) kws['mesh'] = _rayCastTargetsBuffer if _toSnap: kws['toSnap'] = _toSnap elif create: kws['create'] = create if _toAim: kws['toAim'] = _toAim if _rayCastOrientMode == 1: kws['orientMode'] = 'normal' if create == 'duplicate': kws['toDuplicate'] = _toSnap if _toSnap: kws['toSnap'] = False else: log.error("|{0}| >> Must have target with duplicate mode!".format( _str_func)) cgmGEN.log_info_dict(kws, "RayCast args") return if drag: kws['dragStore'] = drag if _rayCastMode == 1: kws['mode'] = 'midPoint' elif _rayCastMode == 2: kws['mode'] = 'far' elif _rayCastMode == 3: kws['mode'] = 'surface' kws['closestOnly'] = False elif _rayCastMode == 4: kws['mode'] = 'planeX' elif _rayCastMode == 5: kws['mode'] = 'planeY' elif _rayCastMode == 6: kws['mode'] = 'planeZ' elif _rayCastMode != 0: log.warning("|{0}| >> Unknown rayCast mode: {1}!".format( _str_func, _rayCastMode)) if _rayCastOffsetMode == 1: kws['offsetMode'] = 'distance' elif _rayCastOffsetMode == 2: kws['offsetMode'] = 'snapCast' elif _rayCastOffsetMode != 0: log.warning("|{0}| >> Unknown rayCast offset mode: {1}!".format( _str_func, _rayCastOffsetMode)) cgmGEN.log_info_dict(kws, "RayCast args") cgmDrag.clickMesh(**kws) return
def getAndMove(loc, targets=None, mode=None, forceBBCenter=False): log.debug("|{0}| >> mode: {1} | targets: {2}".format( _str_func, mode, targets)) if not targets: raise ValueError, "Must have targets" _kws = {'target': loc, 'move': True, 'rotate': True} if mode == 'fromTarget': _d = POS.get_info(targets[0]) _kws['infoDict'] = _d elif mode == 'midPoint': if len(targets) == 1: _d = POS.get_info(targets[0], boundingBox=True) _kws['infoDict'] = _d elif not len(targets) >= 2: raise ValueError, "midPoint mode must have at least two targets" else: _d = get_midPointDict(targets, forceBBCenter) _kws['infoDict'] = _d elif mode == 'closestPoint': if not len(targets) >= 2: raise ValueError, "midPoint mode must have at least two targets" _d = { 'position': DIST.get_by_dist(targets[0], targets[1:], resMode='pointOnSurface') } _kws['infoDict'] = _d _kws['rotate'] = False elif mode == 'closestTarget': if not len(targets) >= 3: raise ValueError, "midPoint mode must have at least three targets" _d = POS.get_info( DIST.get_by_dist(targets[0], targets[1:], resMode='object')) _d['rotateOrder'] = False _d['rotateAxis'] = False _kws['infoDict'] = _d elif mode == 'rayCast': _dbuffer = r9Meta.MetaClass(_loc).cgmLocDat _d = {} _p = POS.get_uv_position(_target[0], _dbuffer['uv']) if _dbuffer.get('offsetDist'): _v = POS.get_uv_normal(_target[0], _dbuffer['uv']) _dist = _dbuffer.get('offsetDist') _p = DIST.get_pos_by_vec_dist(_p, _v, _dist) _d['position'] = _p _kws['infoDict'] = _d _kws['rotate'] = False else: log.error("|{0}| >> unknown mode: {1}".format(_str_func, _mode)) return False try: return position(**_kws) except Exception, err: log.error("|{0}| >> loc: {1}".format(_str_func, loc)) cgmGeneral.log_info_dict(_kws['infoDict'], "{0} >> {1}".format(_str_func, mode)) log.error("|{0}| >> err: {1}".format(_str_func, _err)) return False
except Exception, e: for arg in e.args: log.error(arg) raise RuntimeError, "Stop" _l_pyc = [] if mode == 1: log.info(cgmGEN._str_subLine) log.info("|{0}| >> Found {1} pyc files under: {2}".format( _str_func, len(_l_pyc), path)) for m in _l_pyc: print(m) return _l_pyc if _b_debug: cgmGEN.log_info_dict(_d_files, "Files") cgmGEN.log_info_dict(_d_names, "Imports") if _l_duplicates: log.debug(cgmGEN._str_subLine) log.error("|{0}| >> DUPLICATE MODULES....") for m in _l_duplicates: if _b_debug: print(m) log.debug("|{0}| >> Found {1} modules under: {2}".format( _str_func, len(_d_files.keys()), path)) log.debug(cgmGEN._str_subLine) log.debug("|{0}| >> Ordered MODULES....".format(_str_func)) for k in _l_ordered_list: if _b_debug: print(k)
if not cgmMeta.cgmAttr(mObj, 'mirrorSide').getDriver(): mObj.doStore('mirrorSide', _setMirrorSide) #mObj.mirrorSide = _setMirrorSide #log.info("{0} mirrorSide set to: {1}".format(mObj.p_nameShort,_setMirrorSide)) else: pass #log.info("{0} mirrorSide driven".format(mObj.p_nameShort)) #append the control to our lists to process md_culling_controlLists[mObj.getEnumValueString( 'mirrorSide')].append(mObj) ml_processed.append(mi_module) #...append cgmGEN.log_info_dict(md_culling_controlLists, "Culling lists") #...Map... _d_mapping = { 'Centre': { 'ml': md_culling_controlLists['Centre'], 'startIdx': max(d_runningSideIdxes['Centre']) + 1 }, 'Sides': { 'Left': { 'ml': md_culling_controlLists['Left'], 'startIdx': max(d_runningSideIdxes['Left']) + 1 }, 'Right': { 'ml': md_culling_controlLists['Right'], 'startIdx': max(d_runningSideIdxes['Right']) + 1