本文整理汇总了Python中maya.cmds.setToolTo函数的典型用法代码示例。如果您正苦于以下问题:Python setToolTo函数的具体用法?Python setToolTo怎么用?Python setToolTo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setToolTo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: selectTool
def selectTool(self):
selectAttributes = [ ('Normal', 'options = 4'), ('Reflection', '.options = 4') ]
paintAttributes = [ ('Select', 'options = 4'), ('Soft Select', '.options = 4'), ('Brush Size', '.options = 4') ]
try:
if Cache.keyOffset == 0:
cmds.selectContext('mySelect', edit = True)
Cache.currentContext = 'mySelect'
self.setAttributes ( selectAttributes )
elif Cache.keyOffset == 1:
cmds.artSelectCtx('myPaintSelect', edit = True)
Cache.currentContext = 'myPaintSelect'
self.setAttributes ( paintAttributes )
elif Cache.keyOffset == 2:
Cache.currentContext = 'selectDragger'
self.primitiveTool()
except:
if Cache.keyOffset == 0:
cmds.selectContext ( 'mySelect' )
Cache.currentContext = 'mySelect'
self.setAttributes ( selectAttributes )
elif Cache.keyOffset == 1:
cmds.artSelectCtx ( 'myPaintSelect' )
Cache.currentContext = 'myPaintSelect'
self.setAttributes ( paintAttributes )
elif Cache.keyOffset == 2:
Cache.currentContext = 'selectDragger'
self.primitiveTool()
if Cache.currentContext != 'selectDragger':
cmds.setToolTo( Cache.currentContext )
开发者ID:jricker,项目名称:JR_Maya,代码行数:29,代码来源:JR_tool_class.py
示例2: stateFromFileInfo
def stateFromFileInfo():
from fnmatch import fnmatch
selInfo = m.fileInfo('onSaveSelection', q=1)
if len(selInfo) != 0:
sel = []
for i in selInfo[0].split('?'):
if m.objExists(i):
sel.append(i)
if len(sel):
m.select(sel)
hilite = []
c1 = ['f[*','e[*','map[*','vtx[*','vtxFace[*']
c2 = ['facet','edge','puv','vertex','pvf']
for x in sel:
if x.count('.'):
parts = x.split('.')
for i in range(5):
if fnmatch(parts[1],c1[i]) and parts[0] not in hilite:
hilite.append(parts[0])
mel.eval('doMenuComponentSelection("' + parts[0] + '", "' + c2[i] + '");')
ctxInfo = m.fileInfo('onSaveCtx', q=1)
if len(ctxInfo) != 0:
print ('ctxInfo: ' + str(ctxInfo))
try:
m.setToolTo(ctxInfo[0])
except:
print 'could not set "' + ctxInfo[0] + '"!'
开发者ID:ewerybody,项目名称:melDrop,代码行数:29,代码来源:scene.py
示例3: installModule
def installModule(self, module, *arg):
basename = 'instance_'
cmds.namespace(setNamespace=":")
namespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
for i in range(len(namespaces)):
if namespaces[i].find('__') != -1:
namespaces[i] = namespaces[i].partition('__')[2]
newSuffix = utils.findHighestTrailingNumber(namespaces, basename) + 1
userSpecName = basename + str(newSuffix)
hookObj = self.findHookObjectFromSelection()
mod = __import__('Blueprint.'+ module,{},{},[module])
reload(mod)
moduleClass = getattr(mod, mod.CLASS_NAME)
moduleInstance = moduleClass(userSpecName, hookObj)
moduleInstance.install()
#this is to make sure move tool is selected by default
moduleTransform = mod.CLASS_NAME + '__' + userSpecName + ':module_transform'
cmds.select(moduleTransform, replace=True)
cmds.setToolTo('moveSuperContext')
开发者ID:pouyaz123,项目名称:Python-character-pipeline,代码行数:27,代码来源:blueprint_UI.py
示例4: OnStartRotate
def OnStartRotate( self, *args ):
if ( self.ButtonIsStart ):
self.ObjectsToRotate = [ ]
cmds.makeIdentity( self.DummyNode, rotate = True );
# nos quedamos con los objetos seleccionados
if ( self.SelectedObjects is not None ):
for i in range( 0, len( self.SelectedObjects ) ):
newObject = MTRotatorObject( self.SelectedObjects[ i ] )
# se lleva el pivote a la posicion origen de rotacion
newObject.StartRotation( self.RotatePosition )
self.ObjectsToRotate.append( newObject )
# se addea el nodo dummy a la lista de seleccionados
MTUSetPosition( self.DummyNode, self.RotatePosition )
self.IgnoreSelectionChangeEvent = True
cmds.select( self.DummyNode, add = True )
cmds.setToolTo( self.ManipRotate )
# ..
self.SetStartButtonState( False, True )
else: # stop
self.EndRotation( False, False )
开发者ID:malandrin,项目名称:maya-scripts,代码行数:25,代码来源:MTRotator.py
示例5: snapTemplateToPivot
def snapTemplateToPivot():
# Get selection
selection = cmds.ls (sl=True)
length = len(selection)
# If statement to see if enough things were selected
if length < 2:
print "Not enough things selected to run script."
else:
# First thing selected is controller
thingA = selection[0]
# Second thing selected is the object/component you want to snap template to
thingB = selection[1]
# Get position of thingB
cmds.select (thingB, r=True)
cmds.setToolTo('moveSuperContext')
tempLOC = cmds.spaceLocator(p=cmds.manipMoveContext('Move', q=True, p=True), a=True)
cmds.xform(cp=True)
locPos = cmds.xform (tempLOC, q=True, rp=True, ws=True)
# put thing A in the position of thing B
cmds.move (locPos[0], locPos[1], locPos[2], thingA, a=True, ws=True, rpr=True)
# Delete temporary locator
cmds.delete (tempLOC)
开发者ID:AndresMWeber,项目名称:aw,代码行数:28,代码来源:ko_MPCCar.py
示例6: install_module
def install_module(self,module,*args):
basename = "instance_"
cmds.namespace(setNamespace =":")
namespaces = cmds.namespaceInfo(listOnlyNamespaces=True)
for i in range(len(namespaces)):
if namespaces[i].find("__") != -1:
namespaces[i] = namespaces[i].partition("__")[2]
new_suffix = utils.find_highest_trailing_number(namespaces, basename)+1
user_specified_name = basename+str(new_suffix)
hook_obj = self.find_hook_obj_from_selection()
mod = __import__("blueprint."+module, {}, {}, [module])
reload(mod)
module_class = getattr(mod, mod.CLASS_NAME)
module_instance = module_class(user_specified_name, hook_obj)
module_instance.install()
module_trans = mod.CLASS_NAME+"__"+user_specified_name+":module_transform"
cmds.select(module_trans,replace=True)
cmds.setToolTo("moveSuperContext")
开发者ID:firstPeterParker,项目名称:mlRig,代码行数:29,代码来源:blueprint_ui.py
示例7: primitiveActions
def primitiveActions(self, toolName, createCommand):
if 'Ctx' in toolName or 'Context' in toolName:
if self.getType(0) == 'None':
cmds.setToolTo(toolName)
else:
if len(self.getSelection()) == 1:
location = self.getMiddle()[0]
exec createCommand
cmds.xform(t = location)
else:
items = []
for i in self.getSelection():
cmds.select(i)
location = self.getMiddle()[0]
exec createCommand
items.append(cmds.ls(selection=True))
cmds.xform(t = location)
cmds.select(clear = 1)
for i in items:
cmds.select(i, add = 1)
elif 'cmds' in toolName:
# execute the first command
if self.getType(0) == 'None':
exec toolName
else:
exec createCommand
cmds.warning('section action when something is selected not yet implimented')
开发者ID:jricker,项目名称:JR_Maya,代码行数:27,代码来源:JR_hud_class.py
示例8: exit_tool_and_mask
def exit_tool_and_mask():
"""Exit current tool or toggle selection mode.
When working with other contexts in maya use this function to exit the current
context and return to selection context; if you are using base tools ('select',
move, rotate, scale) toggle selection mode instead.
Usage:
tool_select()
"""
# base_tools = ['{}SuperContext'.format(i) for i in ('select', 'move', 'rotate', 'scale')]
if not cmds.currentCtx() == 'selectSuperContext':
cmds.setToolTo('selectSuperContext')
else:
if cmds.selectMode(q=True, object=True):
hilited = mampy.daglist(hl=True)
if hilited:
cmds.hilite(hilited.cmdslist(), toggle=True)
cmds.select(hilited.cmdslist())
else:
cmds.selectMode(component=True)
else:
cmds.selectMode(object=True)
开发者ID:arubertoson,项目名称:maya-mamselect,代码行数:25,代码来源:masks.py
示例9: editPivotHandle
def editPivotHandle(self):
qt_maya_window.installEventFilter(self.keypressFilter)
#create transform
self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
mc.setAttr(self.pivotHandle+'.rotate', lock=True)
mc.setAttr(self.pivotHandle+'.rx', keyable=False)
mc.setAttr(self.pivotHandle+'.ry', keyable=False)
mc.setAttr(self.pivotHandle+'.rz', keyable=False)
mc.setAttr(self.pivotHandle+'.scale', lock=True)
mc.setAttr(self.pivotHandle+'.sx', keyable=False)
mc.setAttr(self.pivotHandle+'.sy', keyable=False)
mc.setAttr(self.pivotHandle+'.sz', keyable=False)
mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
mc.setAttr(self.pivotHandle+'.displayHandle', True)
self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]
mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)
#set initial position
mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])
#lock it so you don't delete it or something.
mc.lockNode(self.pivotHandle, lock=True)
self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)
mc.setToolTo('Move')
mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True)
开发者ID:liudger,项目名称:ml_tools,代码行数:32,代码来源:ml_pivot.py
示例10: softSelectionClusterWeights
def softSelectionClusterWeights(*args):
sel = mc.ls(sl=True, o=True)
if not sel:
raise RuntimeError('Please select some vertices.')
weights = getSoftSelectionWeights()
if not weights:
raise RuntimeError('Please select some vertices.')
#get manipulator position for pivot
mc.setToolTo('Move')
moveMode = mc.manipMoveContext('Move', query=True, mode=True)
mc.manipMoveContext('Move', edit=True, mode=0)
position = mc.manipMoveContext('Move', query=True, position=True)
mc.manipMoveContext('Move', edit=True, mode=moveMode)
clusterNode, clusterHandle = mc.cluster(sel[0])
for vert in mc.ls(sel[0]+'.vtx[*]', fl=True, l=True):
weight = 0.0
if vert in weights.keys():
weight = weights[vert]
mc.percent(clusterNode, vert, v=weight)
#set cluster pivot
mc.xform(clusterHandle, a=True, ws=True, piv=(position[0], position[1], position[2]))
clusterShape = mc.listRelatives(clusterHandle, c=True, s=True)
mc.setAttr(clusterShape[0] + '.origin', position[0], position[1], position[2])
开发者ID:liudger,项目名称:ml_tools,代码行数:31,代码来源:ml_softWeights.py
示例11: setTool_putObjectOnGround
def setTool_putObjectOnGround( evt=0 ):
if not cmds.pluginInfo( 'sgPutObjectOnGround', q=1, l=1 ):
appendPluginPath()
cmds.loadPlugin( 'sgPutObjectOnGround' )
cmds.setToolTo( 'sgPutObjectOnGroundContext1' )
cmds.select( d=1 )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:7,代码来源:__init__.py
示例12: autoMembershipCmd
def autoMembershipCmd():
geo = _getGeoFromUI()
rbsNode = geo and _getRbs(geo)
if not rbsNode:
raise Exception, 'No %s found' % _rbsNodeName
# orig shape coords
origShape = [s for s in cmds.listRelatives(geo, s=True, pa=True) if cmds.getAttr('%s.intermediateObject' % s)][0]
origCoords = cmds.xform('%s.vtx[*]' % origShape, q=True, os=True, t=True)
vtxCount = cmds.polyEvaluate(origShape, v=True)
tidxList = _getEyeIdxList(rbsNode)
shapeList = []
deleteList = []
# get connected shapes or regen them if absent
for tidx in tidxList:
for i in [0, 1]:
attr = '%s.it[%d].%s' % (rbsNode, tidx, _targetAttrs[i])
connList = cmds.listConnections(attr, d=False)
if connList:
shapeList.append(connList[0])
elif cmds.getAttr(attr, type=True):
obj = regenCmd(rbsNode, tidx, i == 1)
shapeList.append(obj)
deleteList.append(obj)
modIdxSet = set()
for shape in shapeList:
targetCoords = cmds.xform('%s.vtx[*]' % shape, q=True, os=True, t=True)
for idx in xrange(vtxCount):
i = idx*3
if (abs(targetCoords[i]-origCoords[i]) > _autoMembTolerance) or (abs(targetCoords[i+1]-origCoords[i+1]) > _autoMembTolerance) or (abs(targetCoords[i+2]-origCoords[i+2]) > _autoMembTolerance):
modIdxSet.add(idx)
# delete any shape I created
if deleteList:
cmds.delete(deleteList)
if len(modIdxSet) == 0:
cmds.warning('No shape deltas found in %s. No point will be removed.' % geo)
return
# fill the set
objSetNode = _getMembershipSet(rbsNode)
cmds.sets('%s.vtx[*]' % geo, add=objSetNode)
# remove from the set
idxToRemSet = set(range(vtxCount)) - modIdxSet
pListToRemove = ['%s.vtx[%d]' % (geo, idx) for idx in idxToRemSet]
cmds.sets(pListToRemove, rm=objSetNode)
# membership tool
cmds.select(rbsNode)
cmds.setToolTo('setEditContext')
cmds.confirmDialog(t='Auto membership', m='Optimization complete.\nUsing %d of %d points.' % (len(modIdxSet), vtxCount))
开发者ID:Bumpybox,项目名称:Tapp,代码行数:59,代码来源:ZvRadialBlendShape.py
示例13: buildUI
def buildUI(self) :
self.resetExternalContext()
self.window = cmds.window("autorigging_ui", title="Auto-rigging (BB, EL, TP)", w=self.width, h=self.height)
# Title
cmds.columnLayout(w=self.width, h=self.height)
cmds.separator(h=10)
cmds.text(label="Autorigging", w=self.width,h=20, backgroundColor=[0.15,0.15,0.15])
cmds.separator(h=10)
# Mesh selector
self.meshSelector = cmds.optionMenu(w=self.width,h=30,label="Choisissez un Mesh :")
for m in cmds.ls(type="transform"):
cmds.menuItem(label=str(m))
cmds.separator(h=40)
# Point buttons
cmds.scrollLayout(w=self.width)
self.definePointButtons()
# Action buttons (enter mode)
cmds.setParent("..")
cmds.setParent("..") # Here to exit scrollLayout
cmds.separator(h=10)
cmds.rowLayout(numberOfColumns=3)
self.activateButton = cmds.button("activetaBtn",
label="Activer",
w=self.width/3 - 10,
h=self.pointButtonHeight,
command=self.onActivateButtonClick
)
self.generateButton = cmds.button("generateBtn",
label="Generer",
w=self.width/3 - 10,
h=self.pointButtonHeight,
command=self.onGenerateButtonClick
)
self.autoGenerateButton = cmds.button("generateAutoRigBtn",
label="AutoGenerer",
w=self.width/3 - 10,
h=self.pointButtonHeight,
command=self.onAutoRigButtonClick
)
# Console
cmds.setParent("..")
cmds.columnLayout()
cmds.separator(h=10)
self.consoleText = cmds.text(label="Auto-rigging non-actif", width=self.width, height=50, backgroundColor=[0.3,0.3,0.3])
cmds.showWindow(self.window)
cmds.draggerContext("riggingContext", space="world", pressCommand=self.on3DSceneClick)
# Registring context ?
cmds.setToolTo("riggingContext")
开发者ID:LecomteEmerick,项目名称:MayaProject,代码行数:59,代码来源:autoriggin_ui.py
示例14: makeLocOnSel
def makeLocOnSel(self):
tool = cmds.currentCtx()
cmds.setToolTo( 'moveSuperContext' )
pos = cmds.manipMoveContext( 'Move', q=True, p=True )
startLoc = cmds.spaceLocator (n = ('skinWrangler_jointBboxLocator'))[0]
cmds.move(pos[0] ,pos[1] ,pos[2] ,startLoc, ws = 1 , a =1)
cmds.setToolTo(tool)
return startLoc
开发者ID:chrisevans3d,项目名称:skinWrangler,代码行数:8,代码来源:skinWrangler.py
示例15: bufMoveRelease
def bufMoveRelease():
"""release the Buf move vertex mode"""
activePanel = cmds.getPanel(withFocus=True)
cmds.modelEditor(activePanel, e=True, manipulators=True)
cmds.setToolTo('moveSuperContext')
cmds.selectPref(clickDrag=False)
cmds.selectMode(component=True)
cmds.selectMode(object=True)
开发者ID:manymax21,项目名称:dmptools,代码行数:8,代码来源:mayaCommands.py
示例16: doIt
def doIt(self, args):
# Parse the arguments.
argData = OpenMaya.MArgDatabase(syntaxCreator(), args)
self.SOURCE = argData.commandArgumentString(0)
if argData.isFlagSet(kRotationFlag) is True:
self.ROTATION = argData.flagArgumentBool(kRotationFlag, 0)
cmds.setToolTo(self.setupDragger())
开发者ID:jonnybrowo,项目名称:miMayaUtils,代码行数:9,代码来源:duplicateOverSurface.py
示例17: forceSceneUpdate
def forceSceneUpdate():
cmds.setToolTo('moveSuperContext')
nodes = cmds.ls()
for node in nodes:
cmds.select(node,replace=True)
cmds.select(clear=True)
cmds.setToolTo('selectSuperContext')
开发者ID:pouyaz123,项目名称:Python-character-pipeline,代码行数:10,代码来源:utils.py
示例18: force_scene_update
def force_scene_update():
cmds.setToolTo("moveSuperContext")
nodes = cmds.ls()
for node in nodes:
cmds.select(node, replace=True)
cmds.select(clear=True)
cmds.setToolTo("selectSuperContext")
开发者ID:firstPeterParker,项目名称:mlRig,代码行数:10,代码来源:utils.py
示例19: show_UI
def show_UI(self):
self.findSelectionToGroup()
if len(self.objectsToGroup) == 0:
return
self.UIElements = {}
if cmds.window("groupSelected_UI_window", exists=True):
cmds.deleteUI("groupSelected_UI_window")
windowWidth = 300
windowHeight = 180
self.UIElements["window"] = cmds.window("groupSelected_UI_window", width=windowWidth, height=windowHeight, title="Group Selected", sizeable=False)
self.UIElements["topLevelColumn"] = cmds.columnLayout(adj=True, columnAlign="center", rs=3)
# Sets up a text field for naming the group
self.UIElements["groupName_rowColumn"] = cmds.rowColumnLayout(nc=2, columnAttach=(1, "right", 0), columnWidth=[(1, 80), (2,windowWidth-90)])
cmds.text(label="Group Name :")
self.UIElements["groupName"] = cmds.textField(text="group")
cmds.setParent(self.UIElements["topLevelColumn"])
self.UIElements["createAt_rowColumn"] = cmds.rowColumnLayout(numberOfColumns=3, columnAttach=(1, "right", 0), columnWidth=[(1, 80), (2, windowWidth-170), (3, 80)])
cmds.text(label="Position at :")
cmds.text(label="")
cmds.text(label="")
cmds.text(label="")
self.UIElements["createAt_lastSelected"] = cmds.button(label="Last Selected", c=self.createAtLastSelected)
cmds.text(label="")
cmds.text(label="")
self.UIElements["createAt_averagePosition"] = cmds.button(label="Average Position", c=self.createAtAveragePosition)
cmds.text(label="")
cmds.setParent(self.UIElements["topLevelColumn"])
cmds.separator()
columnWidth = (windowWidth/2) - 5
self.UIElements["button_row"] = cmds.rowLayout(nc=2, columnWidth=[(1, columnWidth), (2, columnWidth)], cat=[(1, "both", 10), (2, "both", 10)], columnAlign=[(1, "center"), (2, "center")])
cmds.button(label="Accept", c=self.acceptWindow )
cmds.button(label="Cancel", c=self.cancelWindow)
cmds.showWindow(self.UIElements["window"])
# 063
self.createTemporaryGroupRepresentation()
self.createAtLastSelected()
# Select new translate control
cmds.select(self.tempGroupTransform)
cmds.setToolTo("moveSuperContext")
开发者ID:griffinanimator,项目名称:MPR,代码行数:55,代码来源:groupSelected.py
示例20: getManipulatorPosition
def getManipulatorPosition():
"""
Returns:
list
"""
cmds.setToolTo('Move')
currentMoveMode = cmds.manipMoveContext('Move', q=True, m=True)
cmds.manipMoveContext('Move', e=True, m=0)
pos = cmds.manipMoveContext('Move', q=True, p=True)
cmds.manipMoveContext('Move', e=True, m=currentMoveMode)
return pos
开发者ID:jonike,项目名称:SoftClusterEX,代码行数:11,代码来源:scUtil.py
注:本文中的maya.cmds.setToolTo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论