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

Python cmds.draggerContext函数代码示例

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

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



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

示例1: drag

 def drag(self, *args):
     
     self.dragPoint = mc.draggerContext(self.draggerContext, query=True, dragPoint=True)
     
     #if this doesn't work, try getmodifier
     self.modifier = mc.draggerContext(self.draggerContext, query=True, modifier=True)
     
     self.x = ((self.dragPoint[0] - self.anchorPoint[0]) * self.multiplier) + self.defaultValue
     self.y = ((self.dragPoint[1] - self.anchorPoint[1]) * self.multiplier) + self.defaultValue
     
     if self.minValue is not None and self.x < self.minValue:
         self.x = self.minValue
     if self.maxValue is not None and self.x > self.maxValue:
         self.x = self.maxValue
     
     #dragString
     if self.modifier == 'control':
         if self.button == 1:
             self.dragControlLeft(*args)
         elif self.button == 2:
             self.dragControlMiddle(*args)
     elif self.modifier == 'shift':
         if self.button == 1:
             self.dragShiftLeft(*args)
         elif self.button == 2:
             self.dragShiftMiddle(*args)
     else:
         if self.button == 1:
             self.dragLeft()
         elif self.button == 2:
             self.dragMiddle()
     
     mc.refresh()
开发者ID:Bumpybox,项目名称:Tapp,代码行数:33,代码来源:ml_utilities.py


示例2: __init__

 def __init__(self,
             name = 'mlDraggerContext',
             title = 'Dragger',
             defaultValue=0,
             minValue=None,
             maxValue=None,
             multiplier=0.01,
             cursor='hand'
             ):
     
     self.multiplier = multiplier
     self.defaultValue = defaultValue
     self.minValue = minValue
     self.maxValue = maxValue
     self.cycleCheck = mc.cycleCheck(query=True, evaluation=True)
     
     self.draggerContext = name
     if not mc.draggerContext(self.draggerContext, exists=True):
         self.draggerContext = mc.draggerContext(self.draggerContext)
                                                 
     mc.draggerContext(self.draggerContext, edit=True,
                     pressCommand=self.press, 
                     dragCommand=self.drag,
                     releaseCommand=self.release,
                     cursor=cursor,
                     drawString=title,
                     undoMode='all'
                     )
开发者ID:Bumpybox,项目名称:Tapp,代码行数:28,代码来源:ml_utilities.py


示例3: TraceGestureRelease

    def TraceGestureRelease( self ):
        """ when the mouse is released, find the matching joint trajectory """
        if debug>0: print("begin RELEASE")
        releasePosition = Vector( mc.draggerContext( 'TraceGesture', query=True, dragPoint=True) ).projectToPlane( self.trace[self.nearestRoot].normal, planePt=self.trace[self.nearestRoot].planePt )
        if debug>0: print "release! ", releasePosition
        theTrace = self.trace[self.nearestRoot]
        selectedMotion = None
        if theTrace.closestJoint and theTrace.timespan and (theTrace.timespan[1]-theTrace.timespan[0]) > 1 and \
           not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":        
            theDTW = theTrace.dtws[theTrace.closest]
            if debug > 0:
                print "closest = ", theTrace.closestJoint, theTrace.timespan
                if not mc.objExists("DTW_Y"):
                    mc.group(n="DTW_Y",empty=True)
                for pt in theDTW.Y:
                    loc = mc.spaceLocator(p=pt)
                    mc.parent(loc,"DTW_Y")
        ##    ghostJoint(trace[nearestRoot].closestJoint,trace[nearestRoot].timespan)

            # Build the motion curve and store it's name in the selectedMotions dictionary
            duration = [ int(theTrace.timespan[0]), int(theTrace.timespan[1]+1) ]
            keyframes = [ theTrace.searchList[theTrace.closestJoint].points[frame] for frame in range(duration[0],duration[1]) ]
            selectedMotion = bmt.CurveMotionTrace( theTrace.closestJoint, keys=keyframes ) #duration=theTrace.timespan )
            
        else:
            self.ScrubToNearestTimeOnPath( releasePosition, self.nearestRoot, self.nearestPath )
            cam2pop = self.CameraToPopDist()
            path = theTrace.searchList[self.nearestPath]
            pointKey = path.ClosestTimeTo(releasePosition)
            closestPoint = path.points[pointKey]
            closestPtOnPath = closestPoint.projectToPlane( theTrace.normal, planePt=theTrace.planePt )
            mouse2path = (releasePosition - closestPtOnPath).mag()
            # if motion paths are visible and no drag happened
            # and releasePosition is very close to the path,
            # then select the whole motion path
            if self.motionPathsVisible[self.nearestRoot] and mouse2path < 0.3:  
                # Build the motion curve and store it's name in the selectedMotions dictionary
                duration = [ mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)+1 ]
                keyframes = [ theTrace.searchList[self.nearestPath].points[frame] for frame in range(duration[0],duration[1]) ]
                selectedMotion = bmt.CurveMotionTrace( self.nearestPath, keys=keyframes ) #duration=[mc.playbackOptions(q=True,min=True),mc.playbackOptions(q=True,max=True)] )

            # if not scrubbing
            if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl" and \
               cam2pop >= self.viewFitDistance:      # if trucked out, and mouse is clicked (w/ no drag)
                mc.select(self.nearestRoot)     # zoom in on the nearest root for a better view
                mc.viewFit(fitFactor=2.5)            # the invisible parts of the roots can artificially enlarge the BB, so truck in a little extra
                mc.select(clear=True)
        if selectedMotion:
            selectedMotionCurve = selectedMotion.construct(self.nearestPath)
            
            if not self.nearestRoot in self.selectedMotions.keys():
                self.selectedMotions[self.nearestRoot] = []
            mc.setAttr("%s_MotionTraces.visibility"%self.nearestRoot, 0)
            selectedMotionCurve = mc.rename(selectedMotionCurve, "%s_selection%d"%(self.nearestPath,len(self.selectedMotions[self.nearestRoot])))
            self.selectedMotions[self.nearestRoot].append( selectedMotionCurve )
            self.AddCustomAttr( selectedMotionCurve, "isTraceSelection", True )
            self.AddCustomAttr( selectedMotionCurve, "interactTime", time.time()-self.startTime )
            self.AddCustomAttr( selectedMotionCurve, "startFrame", duration[0] )
            self.AddCustomAttr( selectedMotionCurve, "endFrame", duration[1] )
        mc.select(cl=True)
开发者ID:jeisenma,项目名称:traceSelectionInMaya,代码行数:60,代码来源:traceSelectTool.py


示例4: getProjectedPoint

 def getProjectedPoint(self, dragged):
     '''
     gets the mouse position (in screen coordinates) 
     and finds the projected point on the plane that is parallel to the camera (in world coordinates).
     '''               
     # if we first clicked inside the viewport
     if not dragged:
         
         mousePosition = cmds.draggerContext(self._mContext, query = True, anchorPoint = True)
         self._mView.viewToWorld(int(mousePosition[0]), int(mousePosition[1]), self._mRayPos, self._mRayDir)           
         self.setOriginPoint()                                       
     
     # if we are dragging the mouse                
     else:
         
         if self._mOriginPt:
             
             mousePosition = cmds.draggerContext(self._mContext, query = True, dragPoint = True)
             modifier = cmds.draggerContext(self._mContext, query = True, modifier = True)
             
             self._mView.viewToWorld(int(mousePosition[0]), int(mousePosition[1]), self._mNear, self._mFar)
             self.planeLineIntersection(self._mNear, self._mFar, self._mOriginPt, self._mEye)
             
             mRadius = self._mOriginPt.distanceTo(self._mDragPt)
             cmds.setAttr(self._mVoroImpactShape + '.radius', mRadius)
             cmds.setAttr(self._mVoroImpactTrs + '.visibility', True)
             
             if modifier == 'shift':
                 cmds.setAttr(self._mVoroImpactShader + '.color', 1.0, 0.0, 0.0, type = 'double3')
                 cmds.setAttr(self._mVoroImpactShader + '.incandescence', 0.15, 0.0, 0.0, type = 'double3')
                 cmds.setAttr(self._mVoroImpactTrs + '.overrideColor', 13)
             else:
                 cmds.setAttr(self._mVoroImpactShader + '.color', 0.0, 1.0, 0.0, type = 'double3')
                 cmds.setAttr(self._mVoroImpactShader + '.incandescence', 0.0, 0.15, 0.0, type = 'double3')
                 cmds.setAttr(self._mVoroImpactTrs + '.overrideColor', 14)                     
开发者ID:jeffhong21,项目名称:scripts,代码行数:35,代码来源:IShatterCTX.py


示例5: __init__

    def __init__(self, uioptions, transformoptions, sourcelist, targetlist):
        '''
        initial setup
        '''
        #create the tool context
        if (mc.draggerContext(spPaint3dContextID, exists=True)):
            mc.deleteUI(spPaint3dContextID);
        mc.draggerContext(spPaint3dContextID, pressCommand=self.onPress, dragCommand=self.onDrag, releaseCommand=self.onRelease, name=spPaint3dContextID, cursor='crossHair', undoMode='step')

        #create context local options
        self.runtimeUpdate(uioptions, transformoptions, sourcelist, targetlist)

        #debug purpose
        self.reentrance = 0

        #initialise world up vector
        if ( (mc.upAxis(q=True, axis=True)) == "y" ):
            self.worldUp = om.MVector (0,1,0);
        elif ( (mc.upAxis(q=True, axis=True)) == "z" ):
            self.worldUp = om.MVector (0,0,1);
        else:
            #can't figure out up vector
            mc.confirmDialog(title='Weird stuff happening', message='Not getting any proper info on what the current up vector is. Quitting...')
            sys.exit()

        #fetch current scene unit
        self.unit = mc.currentUnit(query=True, linear=True)
开发者ID:utsdab,项目名称:usr,代码行数:27,代码来源:spPaint3dContext.py


示例6: 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


示例7: drag

 def drag(self):
     self.dragPoint = mc.draggerContext(self.name, query=True, dragPoint=True)
     self.button = mc.draggerContext( self.name, query=True, button=True)
     self.modifier = mc.draggerContext( self.name, query=True, modifier=True)
     
     self.x = self.dragPoint[0]
     self.y = self.dragPoint[1]
     self.z = self.dragPoint[2]
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:8,代码来源:DraggerContextFactory.py


示例8: TraceGesturePress

    def TraceGesturePress( self ):
        """ Procedure called on press """
        if debug>0: print("begin PRESS")
        # Clean up: if there are any locators or groups in the scene, delete them
        if( len(mc.ls("locator*")) > 0 ):
            mc.delete(mc.ls("locator*"))
        if( len(mc.ls("*Grp")) > 0 ):
            mc.delete(mc.ls("*Grp"))

        # find the position of the mouse click
        pressPosition = Vector( mc.draggerContext( 'TraceGesture', query=True, anchorPoint=True) )

        camPos = self.CameraPosition()
        viewAxis = self.CameraViewAxis()
        closestObj2Cam = self.FindNearestObjectToCamera()
        self.interactionPlane = Plane(viewAxis,closestObj2Cam)

        pressPosition = self.FindRayPlaneIntersect( camPos, pressPosition, self.interactionPlane )
        if debug > 0:
            mc.group(n="traceGrp",empty=True)
            loc = mc.spaceLocator(p=pressPosition)
            mc.parent(loc,"traceGrp")

        for root in self.xformRoots:
            # remember whether (or not) the motion paths for a root were visible when the interaction started
            self.motionPathsVisible[root] = mc.getAttr("%s_MotionTraces.visibility"%root)
            # set up all the traces
            self.trace[root].Clear()
            # set the trace normal to the viewing normal of the camera
            self.trace[root].normal = self.interactionPlane.normal #Vector( mc.xform(mc.lookThru(q=True), q=True, m=True)[8:11] )
            self.trace[root].planePt = self.interactionPlane.point #closestObj2Cam

        self.nearestRoot, rootDist = self.FindNearestRoot( pressPosition, self.interactionPlane )
        mc.setAttr("%s_MotionTraces.visibility"%self.nearestRoot, 1)   # vis the new display layer

        # make a group to hold the trace locators
        if debug > 0:
            mc.group(name="trace%sGrp"%self.nearestRoot,empty=True)
            loc = mc.spaceLocator(p=pressPosition)
            mc.parent(loc,"trace%sGrp"%self.nearestRoot)
        # reset the trace
        self.trace[self.nearestRoot].Clear()
        # start the timer
        self.startTime = time.time()
        # set the trace normal to the viewing normal of the camera
        self.trace[self.nearestRoot].normal = Vector( mc.xform(mc.lookThru(q=True), q=True, m=True)[8:11] )
        self.trace[self.nearestRoot].planePt = closestObj2Cam
                
        # add the initial click position to the trace
        self.trace[self.nearestRoot].AddPoint( pressPosition )
        
        self.nearestPath, pathDist = self.FindNearestMotionPath( pressPosition, self.nearestRoot )
        if not mc.draggerContext( 'TraceGesture', query=True, modifier=True) == "ctrl":
            self.trace[self.nearestRoot].SetUpDTWs()
            mc.refresh(currentView=True,force=True)
        if debug>0: print("end PRESS")
开发者ID:jeisenma,项目名称:traceSelectionInMaya,代码行数:56,代码来源:traceSelectTool.py


示例9: Dragger

	def Dragger(self, selection = 'NA' , historyName = '', speed = [0.01, .1, .0001] ):
		if selection == 'NA':
			self.selection = self.getSelection()
		else:
			self.selection = selection
		self.history = self.getHistory(self.selection, -1, historyName)
		self.attribute = self.history[-1] + Cache.currentAttribute
		try:
			cmds.draggerContext( 'dragTool', edit=True, pressCommand= partial(self.pressFunction), dragCommand= partial(self.dragFunction), finalize = partial(self.exitFunction),  undoMode = "step")
		except:
			cmds.draggerContext( 'dragTool', pressCommand= partial(self.pressFunction), dragCommand= partial(self.dragFunction), finalize = partial(self.exitFunction), undoMode = "step" )
		cmds.setToolTo( 'dragTool' )
开发者ID:jricker,项目名称:JR_Maya,代码行数:12,代码来源:JR_dragger_class.py


示例10: press

 def press(self):
     if not mc.draggerContext(self.name,query=True,exists=True): # if it exists, delete it       
         self.build
         self.setTool()            
     
     self.anchorPoint = mc.draggerContext(self.name, query=True, anchorPoint=True)
     self.modifier = mc.draggerContext(self.name, query=True, modifier=True)
     self.button = mc.draggerContext(self.name, query=True, button=True)
     
     self.x = self.anchorPoint[0]
     self.y = self.anchorPoint[1]
     self.z = self.anchorPoint[2]
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:12,代码来源:DraggerContextFactory.py


示例11: pressEvent

    def pressEvent(self):
        button = cmds.draggerContext(DRAGGER, query=True, button=True)

        # Leave the tool by middle click
        if button == 2:
            cmds.setToolTo('selectSuperContext')
            return

        # Get clicked point in viewport screen space
        pressPosition = cmds.draggerContext(DRAGGER, query=True, ap=True)
        x = pressPosition[0]
        y = pressPosition[1]

        self.ANCHOR_POINT = [x, y]

        # Convert
        point_in_3d, vector_in_3d = convertTo3D(x, y)

        # Get MFnMesh of snap target
        targetDagPath = getDagPathFromScreen(x, y)

        # If draggin outside of objects
        if targetDagPath is None:
            return

        # Create new object to snap
        self.DUPLICATED = self.getNewObject()

        # Get origianl scale information
        self.SCALE_ORIG = cmds.getAttr(self.DUPLICATED + ".scale")[0]

        self.MATRIX_ORIG = cmds.xform(self.SOURCE, q=True, matrix=True)

        self.TARGET_FNMESH = OpenMaya.MFnMesh(targetDagPath)

        transformMatrix = self.getMatrix(
            point_in_3d,
            vector_in_3d,
            self.TARGET_FNMESH,
            self.SCALE_ORIG,
            self.MATRIX_ORIG)

        # Reset transform of current object
        cmds.setAttr(self.DUPLICATED + ".translate", *[0, 0, 0])

        location = [-i for i
                    in cmds.xform(self.DUPLICATED, q=True, ws=True, rp=True)]
        cmds.setAttr(self.DUPLICATED + ".translate", *location)
        cmds.makeIdentity(self.DUPLICATED, apply=True, t=True)

        # Apply transformMatrix to the new object
        cmds.xform(self.DUPLICATED, matrix=transformMatrix)
开发者ID:jonnybrowo,项目名称:miMayaUtils,代码行数:52,代码来源:duplicateOverSurface.py


示例12: overshoot

def overshoot(baseFrame='previous'):
	'''Input kan either be 'previous','next' or an integer'''
	
	global attrDict
	global deltaX
	global lastVal
	deltaX = 0
	lastVal = 0
	
	print "# Initializing drag"
	
	selList = mc.ls(sl=True)
	
	try:
		###	Checking userInput
		if baseFrame != 'previous' and baseFrame != 'next' and type(baseFrame) != type(123):
			raise QuitException, "# init >> Input is incorrect. Only supported inputs are 'previous', 'next' or an integer"
	
		###	Checking selection
		if selList != None:
			attrDict = calcAttrDiff(selList, baseFrame)
		else:
			raise QuitException, "# Init >> Nothing is selected"
			
		###	Initializing context
		if mc.draggerContext( 'overshootCtx', exists=True ) == 0:
			mc.draggerContext( "overshootCtx" )
			
		
		###	Checking script file name (execution namespace)
		if __name__ != '__main__':
			prefix = __name__ + '.'
		else:
			prefix = ''
			
		mc.draggerContext( 
			'overshootCtx', 
			edit=True,
			pressCommand= prefix + 'overshoot_OnPress()', 
			dragCommand= prefix + 'overshoot_OnDrag()', 
			releaseCommand= prefix + 'overshoot_EndDrag()',
			cursor='crossHair' 
			);
			
			
		mm.eval('storeLastAction( "restoreLastContext " + `currentCtx` )')
		mc.setToolTo( 'overshootCtx' )
		
	except QuitException, arg:
		print "### Tool terminated ###"
		if arg != None:
			print arg,
开发者ID:joetainment,项目名称:mmmmtools,代码行数:52,代码来源:OMT_to_overshoot.py


示例13: load

 def load(s):
     sel = cmds.ls(sl=True)
     if sel and sel[0] in s.valid:
         s.sel = sel[0]
         s.tool = cmds.currentCtx()
         s.myTool = "TempTool"
         if cmds.draggerContext(s.myTool, exists=True):
             cmds.deleteUI(s.myTool)
         cmds.draggerContext(s.myTool, name=s.myTool, pressCommand=s.click, cursor='hand')
         cmds.setToolTo(s.myTool)
         print "Make a selection"
     else:
         print "Nothing selected"
开发者ID:internetimagery,项目名称:RigTool,代码行数:13,代码来源:joints.py


示例14: press

 def press(self, *args):
     '''
     Be careful overwriting the press method in child classes, because of the undoInfo openChunk
     '''
     
     self.anchorPoint = mc.draggerContext(self.draggerContext, query=True, anchorPoint=True)
     self.button = mc.draggerContext(self.draggerContext, query=True, button=True)
     #dragString
     
     # This makes it so the script editor doesn't get spammed by a cycle in the puppet
     mc.cycleCheck(evaluation=False)
     
     # This turns off the undo queue until we're done dragging, so we can undo it.
     mc.undoInfo(openChunk=True)
开发者ID:Bumpybox,项目名称:Tapp,代码行数:14,代码来源:ml_utilities.py


示例15: pressFunction

	def pressFunction(self):
		self.attribute = self.history[-1] + Cache.currentAttribute # re-init the attribute in case cached has been switched
		self.modifier = cmds.draggerContext( 'dragTool', query=True, modifier=True)
		self.button = cmds.draggerContext('dragTool', query = True, button=True)
		self.attributeValue = cmds.getAttr( self.attribute )
		if cmds.currentUnit( query=True, linear=True ) == 'cm':
			self.speed = .01 # modifier for speed traveled through values while dragging
		elif cmds.currentUnit( query=True, linear=True ) == 'm':
			self.speed = .001 # modifier for speed traveled through values while dragging
		else:
			self.speed = .0001
		self.space = 'screen' # initialize the variable
		if isinstance(self.attributeValue, list): # only edit the space based on button if the attribute is a list value
			# If left click is used, then the space is set to (X,Y,Z) world based
			# If middle click is used, space is set to (X, Y) screen based
			if self.button == 1: # left button
				self.space = 'world' # tracking space used
				cmds.draggerContext( 'dragTool', edit=True, space = 'world')
			elif self.button == 2: # middle button
				self.space = 'screen' # tracking space used
				cmds.draggerContext( 'dragTool', edit=True, space = 'screen')
		else: # set to 'screen' as default if the attr isn't a list value
			cmds.draggerContext( 'dragTool', edit=True, space = 'screen')
		if self.modifier == 'ctrl':
			self.speed = self.speed * .01
		if self.modifier == 'shift':
			self.speed = self.speed * 10
		if len(self.dragDirection) > 0:
			self.dragDirection = []
开发者ID:jricker,项目名称:JR_Maya,代码行数:29,代码来源:JR_dragger_class.py


示例16: __init__

	def __init__(self,name):
		
		self.userSelection = []
		self.cursor = 'crossHair'
		self.dragStart = [0,0]
		self.dragEnd = [0,0]
		self.dragComponentSelection = []
		self.dragObjectSelection = []
		self.modifier = 'none'
		self.context = name+'_CTX'
		
		if mc.draggerContext(self.context,q=1,ex=1):
			mc.deleteUI(self.context)
		self.context = mc.draggerContext(self.context, pressCommand=name+'.onPress()', dragCommand=name+'.onDrag()', releaseCommand=name+'.onRelease()', cursor=self.cursor )
开发者ID:auqeyjf,项目名称:pubTool,代码行数:14,代码来源:surfaceSkinEditInfMembershipCTX.py


示例17: on3DSceneClick

	def on3DSceneClick(self):
		if not cmds.window("autorigging_ui", exists=True) :
			self.resetExternalContext()
			return
		
		if not self.isActive :
			self.setConsoleText("Vous devez activer l'autorigging.",color=[255,0,0])
			return

		if not self.currentPointKey :
			self.setConsoleText("Choisissez un type de point a placer.")
			return


		pos = cmds.draggerContext("riggingContext", query=1, anchorPoint=1)
		strPos = "x:"+str(round(pos[0],2)) +"\ny:" + str(round(pos[1],2))

		if self.pointsMap[self.currentPointKey]["isSet"] is True :
			cmds.delete(self.currentPointKey+"sphere")
		
		
		nextObj = cmds.polySphere(name=self.currentPointKey+"sphere", radius=0.3)
		cmds.move(pos[0], pos[1], 10, nextObj)
		cmds.scale(1.0,1.0,0.0, nextObj)

		self.pointsMap[self.currentPointKey]["isSet"] = True
		self.pointsMap[self.currentPointKey]["clickedPoint"] = pos
		cmds.button(self.pointsMap[self.currentPointKey]["stateButton"], e=1, backgroundColor=[0,255,0],label=strPos)
开发者ID:LecomteEmerick,项目名称:MayaProject,代码行数:28,代码来源:autoriggin_ui.py


示例18: getPointer

 def getPointer(s):
     """
     Get intersection point on the mesh from the mouse click.
     """
     if s.meshes:
         try:
             # Grab screen co-ords
             viewX, viewY, viewZ = cmds.draggerContext(s.tool, q=True, dp=True)
             # Set up empty vectors
             position = om.MPoint()
             direction = om.MVector()
             # Convert 2D positions into 3D positions
             omui.M3dView().active3dView().viewToWorld(int(viewX), int(viewY), position, direction)
             # Check our meshes
             for mesh in s.meshes:
                 selection = om.MSelectionList()
                 selection.add(mesh)
                 dagPath = selection.getDagPath(0)
                 fnMesh = om.MFnMesh(dagPath)
                 # Shoot a ray and check for intersection
                 intersection = fnMesh.closestIntersection(om.MFloatPoint(position), om.MFloatVector(direction), om.MSpace.kWorld, 99999, False)
                 # hitPoint, hitRayParam, hitFace, hitTriangle, hitBary1, hitBary2 = intersection
                 if intersection and intersection[3] != -1:
                     return (mesh, intersection[2]) # hit mesh and face ID
         except RuntimeError:
             pass
开发者ID:internetimagery,项目名称:RigTool,代码行数:26,代码来源:__init__.py


示例19: setObjectToShatterCmd

 def setObjectToShatterCmd(self, *args):
     '''
     
     '''
     if not (cmds.draggerContext(self._IScontextTool._mContext, exists = True)):
         
         iMinTime = cmds.playbackOptions(query = True, minTime = True)
         cmds.currentTime(iMinTime, edit = True)       
         
         polySelection = cmds.filterExpand(selectionMask = 12)
         if polySelection:            
             
             if len(polySelection) > 0:                   
                 
                 mBreakNode = cmds.listConnections(polySelection[0], sh = True, type = 'fxBreakGeometry')
                 if not mBreakNode:
                     
                     cmds.button(self._ISaddBtn, edit = True, label = 'Please wait... checking mesh toplogy')
                     self._IScontextTool.checkForNonManifoldMeshes(polySelection[0])
                     cmds.delete(polySelection[0], ch = True)                    
                 
                 self.resetIShatterGUI()
                 self._IScontextTool._mVoroObject = polySelection[0]                
                 cmds.button(self._ISaddBtn, edit = True, label = polySelection[0])
                 cmds.button(self._ISdelBtn, edit = True, enable = True)
                 cmds.button(self._ISprocessBtn, edit = True, enable = True)
                 cmds.checkBox(self._ISborderEdgesCbx, edit = True, enable = True)
                 cmds.checkBox(self._IShideObjectsCbx, edit = True, enable = True)                                                                                                  
                 
         else:
             cmds.confirmDialog(title = 'Oups... IShatter Error', message = 'You must select one mesh object first !', button = 'OK', defaultButton = 'Yes', cancelButton = 'No', dismissString = 'No')            
开发者ID:jeffhong21,项目名称:scripts,代码行数:31,代码来源:IShatterGUI.py


示例20: __init__

    def __init__(self, name, **kwargs):
        self.name = name
        if not cmds.draggerContext(self.name, exists=True):
            self.name = cmds.draggerContext(name)

        cmds.draggerContext(
            self.name,
            edit=True,
            pressCommand=self.press,
            dragCommand=self.drag,
            releaseCommand=self.release,
            inz=self.setup,
            fnz=self.tear_down,
            **kwargs
        )
        self.context = partial(cmds.draggerContext, self.name)
开发者ID:arubertoson,项目名称:maya-mampy,代码行数:16,代码来源:utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cmds.duplicate函数代码示例发布时间:2022-05-27
下一篇:
Python cmds.dockControl函数代码示例发布时间: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