• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cmds.expression函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中maya.cmds.expression函数的典型用法代码示例。如果您正苦于以下问题:Python expression函数的具体用法?Python expression怎么用?Python expression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了expression函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _buildSpeedExpression

def _buildSpeedExpression(boatWorldCtrl = ''):
    """
    Builds the base expression for the boats world_ctrl speed attr
    @param boatWorldCtrl: The name of the boat world_ctrl to build the expression for
    @type boatWorldCtrl: String
    """
    expStringList = [
                    'float $time;\n',
                    'float $translation[] = `xform -q -ws -translation "%s"`;\n' % boatWorldCtrl,
                    'float $trx;\n',
                    'float $try;\n',
                    'float $trz;\n',
                    'float $dx = $translation[0] - $trx;\n',
                    'float $dy = $translation[1] - $try;\n',
                    'float $dz = $translation[2] - $trz;\n',
                    'float $d = sqrt( ($dx * $dx) + ($dy * $dy) + ($dz * $dz) );\n',
                    '%s.speed = abs( $d / ( time - ($time + 0.001) ) );\n' % boatWorldCtrl,
                    '$trx = $translation[0];\n',
                    '$try = $translation[1];\n',
                    '$trz = $translation[2];\n',
                    '$time = time;\n'
                    ]

    ## Check if the expression already exists in the scene, if so delete it
    utils.checkExpressionExists( '%s_speed' % boatWorldCtrl)
    ## Build new expression
    try:
        cmds.expression(n = '%s_speed' % boatWorldCtrl.replace(':', '_'), string = utils.processExpressionString(expStringList))
    except:
        cmds.warning('YOU ARE USING OLD RIGS!!! PLEASE UPDATE YOUR RIGS!!!')
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:30,代码来源:boat_FX.py


示例2: stabilizer

def stabilizer ():
	global _camera_
	_point = cmds.ls (selection = True)
	
	if cmds.objExists ('stabilizator_expression') == False and len(_point) > 0:
		_camera_	= Camera()
		_point		= _point[0]

		if (cmds.nodeType (_point) == 'mesh' or cmds.nodeType (_point) == 'transform') and _camera_.transform != 'empty':
			_expression	=	r'''
$pos=`python "fmmu.get_normalized_screen_position(\"'''	+	_point	+	r'''\")"`;
setAttr "'''	+	_camera_.shape	+	r'''.horizontalFilmOffset" $pos[2];
setAttr "'''	+	_camera_.shape	+	r'''.verticalFilmOffset" $pos[3];'''

			print "=================================="
			print _expression
			cmds.expression		(name = 'stabilizator_expression', string = _expression)
			cmds.frameLayout	('adjustCam_frml', edit = True, visible = True)
			cmds.symbolButton	('button_stabilizer', edit = True, image = 'ford_matchMoveUtilities__deStabilize.xpm', annotation = 'deStabilizer')
			cmds.floatField		('field_overscan', edit = True, value = _camera_.overscan)

	else:
		if cmds.objExists ('stabilizator_expression') == True:
			cmds.delete ('stabilizator_expression')
		
		cmds.symbolButton	('button_stabilizer', edit = True, image = 'ford_matchMoveUtilities__stabilize.xpm', annotation = 'deStabilizer')
		cmds.frameLayout	('adjustCam_frml', edit = True, collapse = True, visible = False)
		
		try:
			_camera_.reset_camera()
		except:
			pass
开发者ID:danielforgacs,项目名称:code-dump,代码行数:32,代码来源:ford_matchMoveUtils_v0.5.3.py


示例3: _buildNURBSPlaneExpression

def _buildNURBSPlaneExpression(NURBSPlane, xRes, zRes, oceanShader):
    """
    Function to setup the expression that hooks the nurbsPlane to the ocean
    @param NURBSPlane: The build of the nurbsPlane, this build command should have returned a list. Due to refactoring we're just handling this list instead of accepting the actual name
    @type NURBSPlane: List
    """
    ## Now build the expression to connect the cv's of the NURBSPlane to the ocean
    xSize = xRes+1
    zSize = zRes+1

    expStringList = ['float $u, $v;\n float $minx = %s.scaleX * -0.5 + %s.translateX;\n' % (NURBSPlane[0], NURBSPlane[0]),
                                'float $maxx = %s.scaleX *  0.5 + %s.translateX;\n' % (NURBSPlane[0], NURBSPlane[0]),
                                'float $minz = %s.scaleZ * -0.5 + %s.translateZ;\n' % (NURBSPlane[0], NURBSPlane[0]),
                                'float $maxz = %s.scaleZ *  0.5 + %s.translateZ;\n' % (NURBSPlane[0], NURBSPlane[0]),
                                'float $disp[] = `colorAtPoint -o A -su %s  -sv  %s -mu $minx -mv $minz -xu $maxx -xv $maxz %s`;\n' % (str(xSize), str(zSize), oceanShader)
                                ]
    expString = utils.processExpressionString(expStringList)
    #unfold loop and use output connections
    i=0
    for x in range(xSize):
        planeX = x * zSize
        for z in range(zSize):
            planeZ= zSize - z - 1
            addTo = "%s.cv[%s].yv = $disp[%s];\n" % (NURBSPlane[0], str(planeX +planeZ), str(i))
            expString += addTo
            #increment by 1
            i=i+1

    ## Check if the expression already exists in the scene, if so delete it
    utils.checkExpressionExists( '%s_IntersectionPlane' % NURBSPlane[0])

    ## Build new expression
    cmds.expression(n = '%s_IntersectionPlane' % '_'.join(NURBSPlane[0].split(':')), string = expString)
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:33,代码来源:oceanNurbsPreviewPlane.py


示例4: generate

    def generate(self):
        self.m_fingers = []
        names = ["indexFing", "middleFing", "ringFing", "pinkyFing", "thumb"]
        for i in range(len(names)):
            thumb = False
            if i == (len(names) - 1):
                thumb = True
            newFinger = fing.FingerRig(
                "%s_%s" %(self.m_name, names[i]),
                self.m_handJoints.getFinger(i),
                thumb
                )
            newFinger.generate()
            cmds.parent(newFinger.getGroup(), self.m_group)
            self.m_fingers.append(newFinger)

        #create control
        self.m_control = cmds.spaceLocator(n="%s_CTRL" %(self.m_name))[0]


        rc.orientControl(self.m_control, self.m_fingers[3].getKnuckle())
        group = rg.addGroup(self.m_control, "%s_0" %(self.m_control))
        rc.lockAttrs(self.m_control, ["tx", "rotate", "scale"], True, False)
        cmds.parent(group, self.m_group)
        cmds.expression(n="%s_EXP" %(self.m_name), s=self.createExp())
开发者ID:jaredauty,项目名称:Rigging,代码行数:25,代码来源:HandRig.py


示例5: runPreset

def runPreset():
	cmds.select(clear=True)
	cmds.promptDialog(message='Nome do sistema MASH:')
	mashName = cmds.promptDialog(query=True, text=True)
	if not mashName:
		mashName = '#'
	else:
		mashName = '_' + mashName
	############################################################################################
	steps = [	'Selecione as instancias | n >= 2 (arraste com o botao do meio)',
				'Selecione a superficie  | n = 1  (arraste com o botao do meio)']
	accepts = [['mesh'], ['mesh']]
	############################################################################################
	fx.DropWindow.getDrop(	steps,
							lambda data: smartPreset.send(data),
							accepts=accepts)
	node = yield
	nodes = node.split('\n')
	############################################################################################
	cmds.promptDialog(message='Numero de pontos:')
	pointCount = cmds.promptDialog(query=True, text=True)
	try:
		pointCount =  int(pointCount)
	except:
		pointCount = 10
	
	mash = mapi.Network()
	mash.createNetwork(name='MASH' + mashName, geometry='Instancer')

	node = yield
	node = node.split('\n')[0]

	mash.meshDistribute(node)
	############################################################################################
	distNodeName = mash.waiter + '_Distribute'
	cmds.setAttr(distNodeName + '.pointCount', pointCount)

	idNodeName = mash.waiter + '_ID'
	cmds.setAttr(idNodeName + '.idtype', 2)
	count = cmds.getAttr(idNodeName + '.numObjects')

	pyNode = mash.addNode('MASH_Python')
	cmds.addAttr(pyNode.name, longName='countID', attributeType='long', defaultValue=count)
	expr = '{0}.countID = {1}.numObjects'.format(pyNode.name, idNodeName)
	cmds.expression(s=expr)
	cmds.addAttr(pyNode.name, longName='seed', attributeType='long', defaultValue=1234)
	scriptID = ''.join(['p[{0}] = 1  # {1} prob.\n'.format(i, e) for i, e in enumerate(nodes)])
	cmds.setAttr(pyNode.name + '.pyScript', SCRIPT.format(scriptID), type='string')

	randNode = mash.addNode('MASH_Random')
	cmds.setAttr(randNode.name + '.positionX', 0)
	cmds.setAttr(randNode.name + '.positionY', 0)
	cmds.setAttr(randNode.name + '.positionZ', 0)
	cmds.setAttr(randNode.name + '.rotationY', 180)
	cmds.setAttr(randNode.name + '.scaleX', 1)
	cmds.setAttr(randNode.name + '.uniformRandom', 1)

	strengthNode = mash.addNode('MASH_Strength')

	yield
开发者ID:diegoinacio,项目名称:coding,代码行数:60,代码来源:MASH_probScatter.py


示例6: create

	def create(self, objnum, shape="cone"):
		if shape == "cone":
			node = cmds.cone(ch=False, n='herdmemb')
		else:
			node = cmds.duplicate(shape, ic=True, n='herdmemb')

		cmds.addAttr(node, sn='fad', ln='frameAdjust', dv=0, k=True)
	
		values = herds().values()
		
		cmds.expression(s=("$herdvar = " + str(random.random() - 0.5) + " * " + self.leader + ".rnds + " + str(objnum) + ";\n"
						+ "$randfac = " + self.leader + ".stry;\n"
						+ "$foc = " + self.leader + ".lf;\n"
						+ "if( $foc != 0 ) {\n"
						+ "$randfac *= min( 1.0,abs($herdvar)*(1-$foc)/($foc*"+ str(values["population"]) +") );}\n"
						+ "$herdvar = $herdvar * -" + self.leader + ".frameOffset + frame +" + node[0] + ".frameAdjust;\n"
						+ "$offset = " + str(random.random() - 0.45) + " * $randfac;\n"
						+ node[0] + ".tx = $offset + `getAttr -time $herdvar " + self.leader + ".tx`;\n" 
						+ "$offset = " + str(random.random() - 0.45) + " * $randfac;\n"
						+ node[0] + ".ty = $offset + `getAttr -time $herdvar " + self.leader + ".ty`;\n" 
						+ "$offset = " + str(random.random() - 0.45) + " * $randfac;\n"
						+ node[0] + ".tz = $offset + `getAttr -time $herdvar " + self.leader + ".tz`;\n"
						), n=(node[0] + "_herd_exp"))
		# Turns off the checker for finding cycles - throws up lots of warnings without it.
		cmds.cycleCheck(e=True, all=False)
		
		self.node = node[0]
		self.point()
		
		return node
开发者ID:roboneill,项目名称:herds,代码行数:30,代码来源:herds.py


示例7: _update_flipbook_node

def _update_flipbook_node(new_page, current_frame):
    """ Updates the flipbook node with a new page in the enumerator
    and sets the key for that frame.

    :param new_page:
    :type new_page:
    :returns: None
    """
    # ...:
    cmds.expression(object=new_page,
            name="%s_visbility_EXP" % (new_page),
            string="int $page = %d;\n"
            "int $current_keyed_frame = flipbook_LOC.pagesToDisplay;\n"
            "%s.visibility = ($page==$current_keyed_frame)||(visibilityOverride);"
            % (current_frame, new_page),
            alwaysEvaluate=True)

    # We will also be adding another attribute with just integer values.
    # This will be set here at this point as well.
    cmds.setKeyframe("flipbook_LOC.pagesToDisplay",
                     value=current_frame,
                     time=current_frame,
                     outTangentType="step")

    # Return:
    return
开发者ID:eoghancunneen,项目名称:mayaflipbook,代码行数:26,代码来源:animationflipbook.py


示例8: __init__

	def __init__(self, curve, objects, pointsCount, useTips = False, keepConnected = True, tangent = False,rand = False, groupit = False, animated = False  ):
		"""creates objects allong curve,
		curve: Curve Class object that handles the curve
		objects: Array of one o more transforms objects to position allong curve
		pointsCount: Amount of points in the curve
		useTips: is to position objects in the curve
		keepConnected: Keep pointOnCurveInfo connected between transform and curve
		tangent: Manage rotation on objects also
		rand: Place the objects in random order
		animated: Add speed attribute to move objects along curve"""
		self._nodes = []
		self._curve    = curve
		if useTips:
			val = -1
		else:
			val = 1
		startParam = 1.0 / ( pointsCount + val )
		param      = 0
		objsIter = it.bicycle( objects )
		grp = mn.Node( curve.name + '_grp' )
		if groupit:
			grp = mn.Node( mc.group( n = grp.name, em = True ) )
			if animated:
				grp.a.laps.add( k = True )
		with undo.Undo():
			for p in range( pointsCount ):
				#place transform in param point
				if not useTips:
					param += startParam
				if rand:
					baseobj = random.choice( objects )
				else:
					baseobj = objsIter.next()
				obj = baseobj.duplicate()
				self._nodes.append( obj )
				if groupit:
					obj.parent = grp
				pcurveNode = mn.Node( mc.pathAnimation( obj.name, su=0.5,  c=curve.name, fm = True, follow=tangent, followAxis = 'z', upAxis = 'y', worldUpType = 'object', worldUpObject = curve.parent.name ) )
				animCurve = pcurveNode.a.uValue.input.node
				animCurve.delete()
				if keepConnected:
					obj.a.parameter.add( k = True )
					obj.a.parameter.v = param
					obj.a.parameter.min = 0
					obj.a.parameter.max = 1
					obj.a.parameter >> pcurveNode.a.uValue
				else:
					if param > 1.0:
						param = 1
					pcurveNode.a.uValue.v = param
					t = obj.a.t.v
					r = obj.a.r.v
					pcurveNode.delete()
					obj.a.t.v = t[0]
					obj.a.r.v = r[0]
				if useTips:
					param += startParam
				if animated:
					cmd = obj.a.parameter.fullname + ' = ( abs( ' + str( obj.a.parameter.v ) + ' + ' + grp.a.laps.fullname + ' ) ) % 1;'
					mc.expression( s=cmd )
开发者ID:skarone,项目名称:PipeL,代码行数:60,代码来源:curveScatter.py


示例9: customizeCamera

 def customizeCamera(self, camera):
     cmds.lookThru(camera)
     cmds.addAttr(camera, ln="Overlay", at="enum", en="No Overlay:Grid:SpiralTopRight:SpiralTopLeft:SpiralBottomRight:SpiralBottomLeft")
     cmds.addAttr(camera, ln="Overlay_Value", at="long")
     cmds.setAttr(camera + '.Overlay', e=True, keyable=True)
     cmds.setAttr(camera + '.Overlay_Value', e=True, keyable=True)
     cmds.expression(s='int $a=%s.Overlay;\r\n' % camera +
                       '%s.Overlay_Value=$a;' % camera+
                       'switch($a) { \r\n' +
                       '  case 0: \r\n' +
                       '    python("camera_overlays.Overlay_Function().noOverlay()"); \r\n' +
                       '    break;\r\n' +
                       '  case 1: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleThirdsGrid()"); \r\n' +
                       '    break;\r\n' +
                       '  case 2: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopRight()"); \r\n' +
                       '    break;\r\n' +
                       '  case 3: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialTopLeft()"); \r\n' +
                       '    break;\r\n' +
                       '  case 4: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomRight()"); \r\n' +
                       '    break;\r\n' +
                       '  case 5: \r\n' +
                       '    python("camera_overlays.Overlay_Function().toggleGoldenSprialBottomLeft()"); \r\n' +
                       '}select %s;\r' % camera, ae=False, o="renderCam")
开发者ID:afrocircus,项目名称:LVFX-pipeline,代码行数:27,代码来源:custom_camera.py


示例10: stabilizer

def stabilizer (task):
	camera	= Camera()
	point	= cmds.ls (selection = True)

	if task == 'end':
		# turn off stab
		expression		= str (cmds.expression ('stabilizator_expression', string = True, query = True))
		camera.shape	= expression[2:expression.find('#')]
		cmds.delete ('stabilizator_expression')
		camera.reset_camera ()
		cmds.button ('button_stabilizer',
					edit				= True,
					label				= 'stabilize',
					backgroundColor		= (0, 0.5, 0),
					command				= 'fstab.stabilizer("start")')

	else:
		# start stab
		if cmds.objExists ('stabilizator_expression'):
			# stabilizator exists
			expression		= str (cmds.expression ('stabilizator_expression', string = True, query = True))
			camera.shape	= expression[2:expression.find('#')]
			cmds.delete ('stabilizator_expression')
			cmds.select (camera.shape, replace = True)
			cmds.warning (('>>> STAB WAS TURNED ON. CHECK: ' + camera.shape + ' <<< FOR NONZERO OFFSET VALUES ::..'))
		
		else:
			if cmds.nodeType (point) != 'mesh' and cmds.nodeType (point) != 'transform' and len (point) == 0:
				# wrong selection
				cmds.warning ('..:: SELECT SOMETHING TO STABILIZE ::..')
			else:
				point = point[0]
				
				if point != camera.transform and point != camera.shape and camera.transform != 'empty':
					# stabilize
					cmds.setAttr( camera.shape + '.displayResolution', 0)
					cmds.setAttr( camera.shape + '.displayFilmGate', 0)
				
					expression = '//%s#' % camera.shape
					expression += '\npython "import maya.cmds as cmds";'
					expression += '\npython "fov_h = cmds.camera (\'%s\', query = True, horizontalFieldOfView = True)";' % camera.shape
					expression += '\npython "fov_v = cmds.camera (\'%s\', query = True, verticalFieldOfView = True)";' % camera.shape
					expression += '\npython "aperture_h = cmds.camera (\'%s\', query = True, horizontalFilmAperture = True)";' % camera.shape
					expression += '\npython "aperture_v = cmds.camera (\'%s\', query = True, verticalFilmAperture = True)";' % camera.shape
					expression += '\n$pos=`python "fstab.get_normalized_screen_position(\'%s\',\'%s\',fov_h, fov_v,aperture_h,aperture_v)"`;' % (point, camera.transform)
					expression += '\nsetAttr "%s.horizontalFilmOffset" ($pos[2]);' % camera.shape
					expression += '\nsetAttr "%s.verticalFilmOffset" ($pos[3]);' % camera.shape

					# create expression
					cmds.expression		(name = 'stabilizator_expression', string = expression)
		
					# update GUI
					cmds.button			('button_stabilizer',
										edit			= True,
										label			="deStabilize",
										backgroundColor	= (1, 0, 0),
										command			= 'fstab.stabilizer("end")')
					
				else:
					cmds.warning ('..:: CLICK IN THE PANE WITH THE CAMERA ::..')
开发者ID:danielforgacs,项目名称:code-dump,代码行数:60,代码来源:ford_stabilizer_v0.5.5.py


示例11: mirror_locators

def mirror_locators(**kwargs):
    file_name = kwargs.setdefault('filename')
    unmirror = kwargs.setdefault('unmirror', False)
    file_list = ['up_eye', 'low_eye', 'cheek', 'up_mouth', 'low_mouth']
    if unmirror is False:
        if file_name == 'all':
            for i in range(0, len(file_list)):
                file_path = get_file_path('expressions/%s' % file_list[i])
                with open(file_path) as myfile:
                    expressionData = myfile.read()
                mc.expression(string=expressionData, name="%s_Expression" % file_list[i], ae=1, uc='all')
            py.headsUpMessage('Mirroring for all enabled. Must unmirror to reset locations')
        else:
            file_path = get_file_path('expressions/%s' % file_name)
            with open(file_path) as myfile:
                expressionData = myfile.read()
            mc.expression(string=expressionData, name="%s_Expression" % file_name, ae=1, uc='all')
            py.headsUpMessage('Mirroring for %s enabled. Must unmirror to reset locations' % file_name)
    else:
        for i in range(0, len(file_list)):
            try:
                mc.delete('%s_Expression' % file_list[i])
            except:
                pass
        py.headsUpMessage('Mirroring disabled')
开发者ID:coxevan,项目名称:tech_art_tools,代码行数:25,代码来源:definitions.py


示例12: turntable

def turntable():
    """
    Main function. Creates turntable. Requires a list of selected objects.
    :return: None
    """
    objs = cmds.ls(selection=True)
    meshes = checkSelection(objs)
    if not meshes:
        cmds.error('Please select a mesh object')
    pivlist = getSelectionPivot(meshes)
    turnCam = createCamera()
    centroid = findCentroid(pivlist)

    # change camera pivot to centroid
    cmds.xform(turnCam[0], ws=True, piv=centroid)

    # animate camera. rotate around y axis.
    firstFrame = str(cmds.playbackOptions(q=True, minTime=True))
    lastFrame = str(cmds.playbackOptions(q=True, maxTime=True))
    cmds.expression(name='TurnTableExpression',
                    string='{0}.rotateY=360*(frame-{1})/{2}-{1};'.format(turnCam[0],
                                                                         firstFrame, lastFrame))

    # create a 3 point light rig.
    keyLight = createLight('areaLight', 'key', centroid)
    fillLight = createLight('areaLight', 'fill', centroid)
    rimLight = createLight('areaLight', 'rim', centroid)
    cmds.lookThru(turnCam[0])
开发者ID:afrocircus,项目名称:LVFX-pipeline,代码行数:28,代码来源:turntable.py


示例13: editMainExpression

def editMainExpression(objectName="", splashDisc="", oceanShader="", objectNameEmitter="", wakeEmitter="", splashDiscEmitter=""):
    """
    editing the main expression for the scene
    @param splashDiscParticle: Name of SplashDiscParticle
    @type splashDiscParticle: String
    --------------------------------------------
    @return: 0-ExpressionText
    """
    
    oldMainExoression = cmds.expression("ocean_MainExpression",query=True, string=True)
    
    startExpression = "\n////////////////////////////// Start %s Expression //////////////////////////////\n"%objectName
    
    newExp = ""
    newExp += "float $%s_particleSprayRate = 3000;\n"%objectName
    newExp += "float $%s_particleBubblesRate = 100;\n" %objectName
    newExp += "float $%s_fluidDisplacement = 6.0;\n" %objectName
    newExp += "float $%s_fluidFoam = 2.0;\n" %objectName
    newExp += "float $%s_u = .I[0];\n" %objectName
    newExp += "float $%s_v = .I[1];\n" %objectName
    newExp += "float $%s_disp[] = `colorAtPoint -u $%s_u -v $%s_v %s`;\n" %(objectName,objectName,objectName,oceanShader)
    newExp += "float $%s_lastY = `getAttr -time (frame - 2) %s.translateY`;\n" %(objectName,objectName)
    newExp += "float $%s_curY = %s.translateY;\n" %(objectName,objectName)
    newExp += "float $%s_ydiff = $%s_lastY - $%s_curY;\n" %(objectName,objectName,objectName)
    
    newExp += "if( $%s_curY < 0.5 ){\n\t"%objectName
    newExp += "%s.rate = $%s_particleBubblesRate;"%(objectNameEmitter,objectName)
    newExp += "\n} else {\n\t"
    newExp += "%s.rate = 0;\n}\n"%objectNameEmitter
    newExp += "if( $%s_ydiff < 0 ){\n\t"%objectName
    newExp += "$%s_ydiff = -$%s_ydiff;"%(objectName,objectName)
    newExp += "\n}\n"
    newExp += "if( $%s_curY > -1 && $%s_curY < 0.6 ){\n\t"%(objectName,objectName)
    newExp += "%s.fluidDensityEmission = $%s_fluidDisplacement;\n\t"%(wakeEmitter,objectName)
    newExp += "%s.fluidHeatEmission = $%s_fluidFoam;"%(wakeEmitter,objectName)
    newExp += "\n} else {\n\t"
    newExp += "%s.fluidDensityEmission = 0;\n\t"%wakeEmitter
    newExp += "%s.fluidHeatEmission = 0;"%wakeEmitter
    newExp += "\n}\n"
    newExp += "if( $%s_curY > -1 && $%s_curY < 0.5 && $%s_ydiff > 0.05 ){\n\t"%(objectName,objectName,objectName)
    newExp += "%s.rate = $%s_particleSprayRate * $%s_ydiff;\n\t"%(splashDiscEmitter,objectName,objectName)
    newExp += "float $%s_speed = $%s_ydiff * 10;\n\t"%(objectName,objectName)
    newExp += "if( $%s_speed > 10 ){\n\t\t"%objectName
    newExp += "$%s_speed = 10;"%objectName
    newExp += "\n\t}\n\t"
    newExp += "%s.speed = $%s_speed;"%(splashDiscEmitter,objectName)
    newExp += "\n} else {\n\t"
    newExp += "%s.rate = 0;"%splashDiscEmitter
    newExp += "\n}\n"
    newExp += "%s.translateY = $%s_disp[0];\n"%(splashDisc,objectName)
    newExp += "float $%s_dummy = %s.displacement;\n"%(objectName,oceanShader)

    endExpression = "////////////////////////////// End %s Expression //////////////////////////////\n\n"%objectName

    totalExp = oldMainExoression+startExpression+newExp+endExpression
    
    cmds.expression ("ocean_MainExpression",string=totalExp ,edit=True, alwaysEvaluate=1, unitConversion="all")
    
    return totalExp
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:59,代码来源:SplashTool_Helper.py


示例14: connectAttrs

def connectAttrs(newObj,oldObj):
    #r = str(0.7)
    for attr in attrs:
        #if attr=='translateX':
        #    #scale translateX
        #    cmds.expression(s = newObj+'.' +attr+ ' = ' + r + '*' + oldObj+'.' +attr)
        #else:
        cmds.expression(s = newObj+'.' +attr+ ' = ' + oldObj+'.' +attr)
开发者ID:jlopezbi,项目名称:GeometricFractalsMaya,代码行数:8,代码来源:nBranching.py


示例15: loop_selection

def loop_selection(num_loops, step=1):
    """ Loop over selected pages num_loop times.

    With the pages selected in the maya scene, loop over the pages
    num_loop times with step amount of frames between each loop.
    And some...

    :param num_loops: The page to display.
    :param step: The number of frames between the loop.
    :type num_loops: int.
    :type step: int.
    :returns:  List.
    :raises: None.

    .. note::

       There is a Maya Expression declared in this function as a string.
       This could be removed to another file and use something like Jinja
       to work with it.
    """
    # If there are pages selected:
    pages = cmds.ls(selection=True)
    if pages:
        regex = re.compile(r"page_(\d{4})")
        page_vals = [int(regex.search(page).group(1)) for page in pages]
        inc_value = (page_vals[-1] + step) - page_vals[0]
        page_loop = [page_vals[i] + (j * inc_value) for j in xrange(num_loops) for i in xrange(len(page_vals))]

        #
        page_array = ""

        # Set the expression now:
        for index, page in enumerate(page_vals):
            page_name = "page_%04d" % (page)
            expr_name = "page_%04d_visbility_EXP" % (page)

            if cmds.objExists(expr_name):
                cmds.delete(expr_name)

            # Reads the expression from the ./templates folder and fills
            # in the values before setting the expression on the curves
            # for that given page:
            exp = open(os.path.join(TEMPLATE_DIR, 'flipbookexpression.mel'), 'r').read()
            exp = exp % {'values': ','.join(map(str, page_loop[index::len(page_vals)])),
                         'end_values': ','.join(map(str, page_loop[index + 1::len(page_vals)])),
                         'page': page,
                         'page_name': page_name}
            cmds.expression(object=page_name,
                            name=expr_name,
                            string=exp,
                            alwaysEvaluate=True)

    go_to_page(page_vals[-1] + 1)
    page_name = "page_%04d" % (page_vals[-1] + 1)
    set_empty_page()

    # Return the loop list:
    return page_loop
开发者ID:eoghancunneen,项目名称:mayaflipbook,代码行数:58,代码来源:animationflipbook.py


示例16: _setDistance

	def _setDistance(self):
		''' 
		Creates expression
		Exp: moveVector = currentPosition - oldPosition
		'''
		exp = 'vector $move = <<%s.mvx,%s.mvy,%s.mvz>>;\n'%(self.node,self.node,self.node)
		exp += '%s.distance = mag($move);\n'%self.node

		cmds.expression(s=exp,n='%s_distExp'%self.ctrlName)	
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:9,代码来源:RotationSetup.py


示例17: addCorrectiveExpressionToMaster

def addCorrectiveExpressionToMaster(master, blendshape_dummy, blendshape1, blendshape2):
	"""
	Add expression to turn on corrective expression when
	bs1 and bs2 are active.
	"""
	master_blendshape = getBlendshapesFromMaster(master)[0]
	expression_name = "exp_" + blendshape_dummy
	expression_string = master_blendshape+"."+blendshape_dummy + "=" + master_blendshape +"."+blendshape1 + " * " + master_blendshape+"."+blendshape2 + ";"
	expression(s=expression_string, n=expression_name)
开发者ID:caedocha,项目名称:blend-it,代码行数:9,代码来源:correctiveBlendshapeCreator.py


示例18: modifyBtnCmd

 def modifyBtnCmd(self, *args):
     nodeName = self.getNodeName()
     movieInputList = cmds.listConnections('%s_movieNode'%nodeName)
     expressions = [item for item in movieInputList if 'expression' in item]
     print expressions
     expressionString = cmds.expression(expressions[0], q = 1, s = 1)
     offsetFrame = cmds.intField(self.frameOffset, q = 1, v = 1)
     newString = '%s.frameExtension = frame - %s'%('%s_movieNode'%nodeName, str(offsetFrame))
     cmds.expression(expressions[0], e = 1, s = newString)
开发者ID:chuckbruno,项目名称:importMovie,代码行数:9,代码来源:importMovie.py


示例19: _setMoveVector

	def _setMoveVector(self):
		''' 
		Creates expression
		Exp: Using currentPosition, oldPosition, get moveVector. 
		'''
		exp = '%s.mvx = %s.cpx - %s.ppx;\n'%(self.node,self.node,self.node)
		exp += '%s.mvy = %s.cpy - %s.ppy;\n'%(self.node,self.node,self.node)
		exp += '%s.mvz = %s.cpz - %s.ppz;\n'%(self.node,self.node,self.node)

		cmds.expression(s=exp,n='%s_moveVecExp'%self.ctrlName)	
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:10,代码来源:RotationSetup.py


示例20: createShoulderIndicator

def createShoulderIndicator(trackway):
    shoulders, shape = cmds.polyCube(name='shoulders', width=15, height=15, depth=15)
    groupItems.append(shoulders)
    cmds.move(0, 100, 0, shoulders)

    manus = trackway.manus
    cmds.expression("%s.z = 0.5*abs(%s.z - %s.z) + min(%s.z, %s.z)" % (
        shoulders, manus.left, manus.right, manus.left, manus.right))

    return shoulders
开发者ID:sernst,项目名称:Cadence,代码行数:10,代码来源:Show_GaitVisualizer.py



注:本文中的maya.cmds.expression函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cmds.file函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.exactWorldBoundingBox函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap