本文整理汇总了Python中maya.cmds.move函数的典型用法代码示例。如果您正苦于以下问题:Python move函数的具体用法?Python move怎么用?Python move使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了move函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
def postProcessControl ( _control, _function, _controlled ): # <<< string, string, list
lockHideAttributes ( _control )
if (cmds.objExists('anim_control_set') == False): cmds.createNode('objectSet',name='anim_control_set',skipSelect=True)
cmds.sets ( _control, addElement = 'anim_control_set' )
cmds.toggle ( localAxis = 1 )
if len ( _controlled ) == 0:
_control = cmds.rename ( '_' + _function + '_control' )
_control = cmds.group ( world = 1, name = '_' + _function + '_control_offSet' )
cmds.move ( 0, 0, 0, _control + '.rotatePivot', _control + '.scalePivot' )
lockHideAttributes ( _control )
else:
_k = _controlled[0].rfind ( '|' )
_control = _controlled[0][_k+1:]
cmds.rename ( _control + '_' + _function + '_control' )
_control = cmds.group ( world = 1, name = _control + '_' + _function + '_control_offSet' )
cmds.move ( 0, 0, 0, _control + '.rotatePivot', _control + '.scalePivot' )
lockHideAttributes ( _control )
cmds.select ( _controlled[0], toggle = True )
cmds.parent ()
cmds.xform ( translation = ( 0, 0, 0 ), rotation = ( 0, 0, 0 ) )
cmds.parent ( world = 1 )
cmds.pickWalk ( direction = "down" )
示例2: moveMirrorPosObj
def moveMirrorPosObj(obj,targetObj):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
Attempts to mirror an objects position and rotation
ARGUMENTS:
obj(string)
targetObj(string)
RETURNS:
Nothin
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
objTrans = mc.xform (targetObj, q=True, ws=True, sp=True)
actualName = mc.spaceLocator ()
if objTrans[0] > 0:
mc.xform (actualName[0],translation = [-objTrans[0],objTrans[1],objTrans[2]], ws=True)
objTrans = mc.xform (actualName[0], q=True, ws=True, sp=True)
mc.move (objTrans[0],objTrans[1],objTrans[2], [obj])
else:
mc.xform (actualName[0],translation = [objTrans[0],objTrans[1],objTrans[2]], a=True)
objTrans = mc.xform (actualName[0], q=True, ws=True, sp=True)
mc.move (-objTrans[0],objTrans[1],objTrans[2], [obj])
mc.delete (actualName[0])
示例3: bestFitPlane
def bestFitPlane(ptList,upVector=(0,1,0)):
'''
'''
# Initialize plane normal
norm = OpenMaya.MVector()
pt = OpenMaya.MVector()
# Calculate plane
for i in range(len(ptList)):
prev = OpenMaya.MVector(ptList[i-1][0],ptList[i-1][1],ptList[i-1][2])
curr = OpenMaya.MVector(ptList[i][0],ptList[i][1],ptList[i][2])
norm += OpenMaya.MVector((prev.z + curr.z) * (prev.y - curr.y), (prev.x + curr.x) * (prev.z - curr.z), (prev.y + curr.y) * (prev.x - curr.x))
pt += curr
# Normalize result
norm.normalize()
pt /= len(ptList)
# Build rotation matrix
mat = glTools.utils.matrix.buildRotation(norm,upVector,'y','x')
rot = glTools.utils.matrix.getRotation(mat,'xyz')
# Create Plane
plane = mc.polyPlane(w=1,h=1,sx=1,sy=1,ax=[0,1,0],cuv=2,ch=False)[0]
# Position Plane
mc.rotate(rot[0],rot[1],rot[2],plane,os=True,a=True)
mc.move(pt[0],pt[1],pt[2],plane,ws=True,a=True)
# Return result
return plane
示例4: snapPtsToSurface
def snapPtsToSurface(surface,pointList):
'''
@param surface: Nurbs surface to snap points to
@type surface: str
@param pointList: Point to snap to the specified surface
@type pointList: list
'''
# Check surface
if not isSurface(surface): raise UserInputError('Object '+surface+' is not a valid surface!')
# Check points
pointList = mc.ls(pointList,fl=True)
# Transform types
transform = ['transform','joint','ikHandle','effector']
# Snap points
for pt in pointList:
# Check Transform
if transform.count(mc.objectType(pt)):
snapToSurface(surface,pt,0.0,0.0,True,snapPivot=False)
continue
# Move Point
pos = mc.pointPosition(pt)
(uParam,vParam) = closestPoint(surface,pos)
sPt = mc.pointOnSurface(surface,u=uParam,v=vParam,position=True)
mc.move(sPt[0],sPt[1],sPt[2],pt,ws=True,a=True)
示例5: m
def m(p, _t=None):
if not _t:
_t = mc.ls(sl=1)
for i in range (0,len(_t)):
mc.select(_t[i])
mc.move(p[0],p[1],p[2])
示例6: create_pointer
def create_pointer(m):
if (BAXER_POINTER == True):
# import Baxter Pointer model and use it
try:
cmds.loadPlugin("objExport")
except:
pass
name = os.path.dirname(os.path.realpath(__file__)) + "/models/baxter_gripper.obj"
mel.eval('file -import -type "OBJ" -ignoreVersion -ra true -mergeNamespacesOnClash false -rpr "gripper" -options "mo=1" -pr "%s";' \
% name)
try:
mel.eval('rename "gripper_Mesh" "pointer' + str(m) + '";')
except:
pass
else:
# Create a pointer mesh that represents the robot claw
cmds.polyCone(name="pointer" + str(m), sx=3, r=0.5, h=2)
cmds.select("pointer" + str(m))
cmds.rotate("180deg", 0, 0, r=True)
cmds.move(0, -1, 0, "pointer" + str(m) + ".scalePivot", "pointer" + str(m) + ".rotatePivot")
cmds.move(0, 1, 0, absolute=True)
cmds.makeIdentity(apply=True, t=1, r=1, s=1)
bbx = cmds.xform("table", q=True, bb=True, ws=True)
cur_size = abs(bbx[3] - bbx[0])
cmds.scale(cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, "pointer" + str(m), centerPivot = True)
mel.eval('select -r pointer' + str(m) + '; sets -e -forceElement pointer_matSG;')
mel.eval("makeCollideNCloth")
示例7: bt_moveObjToCamera
def bt_moveObjToCamera():
#Check for hotkey and make if possible
bt_checkCtrFHotkey()
activePanel = cmds.getPanel(wf=1)
if "model" in activePanel:
activeCamera = cmds.modelEditor(activePanel,q=1,camera=1)
else:
cmds.error ('No active panel/camera to frame to')
selected = cmds.ls(sl=1)
locator = cmds.spaceLocator()
cmds.select(activeCamera,add=1)
cmds.parent(r=1)
cmds.move(0,0,-5,locator,r=1,os=1)
location = cmds.xform(q=1,t=1,ws=1)
for object in selected:
cmds.move(location[0],location[1],location[2],object,ws=1,a=1)
#cmds.move(location[0],location[1],location[2],'pCube1',ws=1,a=1)
cmds.delete(locator)
cmds.select(selected,r=1)
示例8: doPositionLocator
def doPositionLocator(locatorName,locInfo):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
Position a locator with locator info generated from returnInfoForLoc
ARGUMENTS:
locatorName(string)
locInfo(dict)
RETURNS:
success(bool)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
if search.returnObjectType(locatorName) == 'locator':
objTrans = locInfo['position']
objRot = locInfo['rotation']
correctRo = locInfo['rotationOrder']
mc.move (objTrans[0],objTrans[1],objTrans[2], locatorName)
mc.setAttr ((locatorName+'.rotateOrder'), correctRo)
#Rotate
if locInfo['objectType'] == 'polyFace':
constBuffer = mc.normalConstraint((locInfo['createdFrom']),locatorName)
mc.delete(constBuffer[0])
else:
mc.rotate (objRot[0], objRot[1], objRot[2], locatorName, ws=True)
return True
else:
guiFactory.warning('Not a locator.')
return False
示例9: locMeCVOnCurve
def locMeCVOnCurve(curveCV):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
Places locators on the cv's closest position on a curve
ARGUMENTS:
curve(string)
RETURNS:
locList(list)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
if search.returnObjectType(curveCV) == 'curveCV':
cvPos = mc.pointPosition (curveCV,w=True)
wantedName = (curveCV + '_loc')
actualName = mc.spaceLocator (n= wantedName)
mc.move (cvPos[0],cvPos[1],cvPos[2], [actualName[0]])
splitBuffer = curveCV.split('.')
uPos = distance.returnClosestUPosition (actualName[0],splitBuffer[0])
mc.move (uPos[0],uPos[1],uPos[2], [actualName[0]])
return actualName[0]
else:
guiFactory.warning ('Not a curveCV')
return False
示例10: duplicate_button
def duplicate_button( self, *args ):
self.original_selected_objects = cmds.ls( selection=True )
if( len(self.original_selected_objects) == 0 ):
print "Nothing selected"
return 0
elif( len(self.original_selected_objects) == 1 ):
self.relatives = cmds.listRelatives( children=True )
if( len(self.relatives) == 1 ):
print "Skip combine"
cmds.duplicate( self.original_selected_objects, name=self.original_selected_objects[0] + "_Copy" )
cmds.delete( constructionHistory=True )
the_parent = cmds.listRelatives( parent=True )
if( the_parent != None ):
cmds.parent( self.original_selected_objects[0] + "_Copy", world=True )
else:
self.combine()
else:
self.combine()
self.newOriginCopy = cmds.ls( selection=True )[0]
self.bbox = cmds.exactWorldBoundingBox( self.newOriginCopy )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, self.newOriginCopy + ".scalePivot", self.newOriginCopy + ".rotatePivot", absolute=True)
cmds.move( 0, 0, 0, self.newOriginCopy, rpr=True )
cmds.makeIdentity( apply=True, t=1, r=1, s=1 )
cmds.delete( constructionHistory=True )
示例11: locMeCenter
def locMeCenter(objList,forceBBCenter = False):
"""
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DESCRIPTION:
Pass an object into it and get a named locator with stored info for updating it
ARGUMENTS:
obj(string)
RETURNS:
name(string)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"""
# make it
nameBuffer = mc.spaceLocator()
#store info
attributes.storeInfo(nameBuffer[0],'cgmSource',(','.join(objList)),False)
attributes.storeInfo(nameBuffer[0],'cgmLocMode','selectCenter',False)
attributes.storeInfo(nameBuffer[0],'cgmName',(str('_to_'.join(objList))),False)
attributes.storeInfo(nameBuffer[0],'cgmTypeModifier','midPoint',False)
posList = []
for obj in objList:
if mc.objExists(obj) == True:
objInfo = returnInfoForLoc(obj,forceBBCenter)
posList.append(objInfo['position'])
objTrans = distance.returnAveragePointPosition(posList)
mc.move (objTrans[0],objTrans[1],objTrans[2], nameBuffer[0])
#return ( NameFactory.doNameObject(nameBuffer[0]) )
return cgmMeta.NameFactory(nameBuffer[0]).doNameObject()
示例12: bulge_button
def bulge_button( self, *args ):
if( cmds.objExists( "ZBend" ) ):
cmds.confirmDialog( title="Error", message="First delete the bulge history on the previously\ndeformed object before bulging another.", button="Okie Dokie" )
return 0
latestSelection = cmds.ls( selection=True )
if( len( latestSelection ) == 0 ):
return 0
if( len( latestSelection ) == 1 ):
self.relatives = cmds.listRelatives( children=True )
if( len(self.relatives) == 1 ):
self.bbox = cmds.exactWorldBoundingBox( latestSelection )
cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "x_bulge_slider", value=True, query=True ) )
cmds.rename( "XBend" )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "XBend", rpr=True )
cmds.setAttr( "XBend.rotateZ", -90 )
cmds.select( latestSelection )
cmds.nonLinear( type='bend', curvature=cmds.intSliderGrp( "z_bulge_slider", value=True, query=True ) )
cmds.rename( "ZBend" )
cmds.move((self.bbox[0] + self.bbox[3])/2, self.bbox[1], (self.bbox[2] + self.bbox[5])/2, "ZBend", rpr=True )
cmds.setAttr( "ZBend.rotateZ", -90 )
cmds.setAttr( "ZBend.rotateX", 90 )
cmds.connectControl( "x_bulge_slider", "bend1.curvature" )
cmds.connectControl( "z_bulge_slider", "bend2.curvature" )
cmds.select( latestSelection )
示例13: buildTargent
def buildTargent(blendShape, targentname, weightID):
postions = mc.getAttr('%s.it[0].itg[%s].iti[6000].ipt'%(blendShape, weightID))
if postions == None :return
points = mc.ls(['%s.%s'%(targentname, pnt) for pnt in mc.getAttr('%s.it[0].itg[%s].iti[6000].ict'%(blendShape, weightID))], fl=True)
for pnt, posi in zip(points, postions):
mc.move(posi[0], posi[1], posi[2], pnt, r=True)
示例14: align
def align():
obj1, obj2 = cmds.ls(selection=True, o=True)
objPos = cmds.xform(obj2, q=1, ws=1, rp=1)
objRot = cmds.xform(obj2, q=1, ro=True)
cmds.move(objPos[0], objPos[1], objPos[2], obj1, rpr=True)
cmds.rotate(objRot[0], objRot[1], objRot[2], obj1, r=True)
cmds.select(obj1)
示例15: generateForm
def generateForm(self) :
"""
This method returns the position of all vertices of an object.
"""
vtxWorldPosition = []
mainObject = self.lineEditMainObject.displayText()
usedObject = self.lineEditUsedObject.displayText()
if mainObject:
# create a group for the new objects
self.groupObject.createGroup("NewObjectsGroup")
mc.SnapToPoint()
vtxIndexList = mc.getAttr( mainObject+".vrts", multiIndices=True )
for i in vtxIndexList :
curPointPosition = mc.xform( str(mainObject)+".pnts["+str(i)+"]", query=True, translation=True, worldSpace=True )
mc.select( usedObject )
newObject = mc.duplicate ( rr=True )
self.groupObject.addInGroup("NewObjectsGroup", newObject)
self.listNewObjects.append(newObject)
mc.move(curPointPosition[0], curPointPosition[1], curPointPosition[2], newObject, rpr=True)
mc.SnapToPoint()
else:
self.messageObject.showWindowMessage( "Please import objects!", "Select" )
mc.select( clear=True )