def ParamChange(self):
    try:
        oObj = cmds.ls(sl=True, type="transform")
        FirstObj = oObj[0].split("_")[-1]
    except:
        cmds.warning(u'選択して実行してください。')
        cmds.confirmDialog(title='ChangeOrder',
                           m=u'選択して実行してください。',
                           icon='warning')
        return
    if FirstObj != "TempObj":
        oLoc = cmds.spaceLocator(n=oObj[0] + "_TempObj")[0]
        cmds.addAttr(oLoc, sn="OriSel", ln="Original_Selection", dt="string")
        cmds.setAttr(oLoc + ".Original_Selection", oObj, type="string")
        PointCons = cmds.pointConstraint(oObj[0], oLoc, n="Dummy_point")
        OrientCons = cmds.orientConstraint(oObj[0], oLoc, n="Dummy_orient")
    else:
        oLoc = cmds.ls(sl=True)[0]
    cmds.setToolTo('RotateSuperContext')
    Rotate_Mode = cmds.manipRotateContext('Rotate', q=True, mode=True)
    cmds.manipRotateContext('Rotate', e=True, mode=2)
    oOrder = cmds.optionMenu('Check_Order_List', q=True, sl=True)
    if oOrder == 1:
        cmds.setAttr(oLoc + ".rotateOrder", 0)
    elif oOrder == 2:
        cmds.setAttr(oLoc + ".rotateOrder", 1)
    elif oOrder == 3:
        cmds.setAttr(oLoc + ".rotateOrder", 2)
    elif oOrder == 4:
        cmds.setAttr(oLoc + ".rotateOrder", 3)
    elif oOrder == 5:
        cmds.setAttr(oLoc + ".rotateOrder", 4)
    elif oOrder == 6:
        cmds.setAttr(oLoc + ".rotateOrder", 5)
def load():
    '''loads animation environment'''
    print "loading animation environment presets..."
    #set autoKey
    cmds.autoKeyframe( state=True )
    #set 24fps and playback on all viewports
    cmds.playbackOptions(ps=1.0, v='all')
    #set unlimited undo's
    cmds.undoInfo( state=True, infinity=True )
    #set manipulator sizes
    if lib.checkAboveVersion(2014):
        cmds.manipOptions( r=False, hs=55, ls=4, sph=1 )
    else:
        cmds.manipOptions( r=False, hs=55, ls=4 )
    #set framerate visibility
    mel.eval("setFrameRateVisibility(1);")
    #gimbal rotation
    cmds.manipRotateContext('Rotate', e=True, mode=2)
    #world translation
    cmds.manipMoveContext('Move', e=True, mode=2)
    #time slider height
    aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider')
    cmds.timeControl(aPlayBackSliderPython, h=45, e=True);
    #special tick color
    cmds.displayRGBColor("timeSliderTickDrawSpecial", 1,0.5,0)

    #check if hotkeys have been set
    if (cmds.hotkey( 't', ctl=True, query=True, name = True)== 'CharacterAnimationEditorNameCommand'):
        print "Hotkeys have been previously loaded"
    else:
        setHotkeys('default')

    print "ENVIRONMENT SET\n", #the comma forces output on the status line
Beispiel #3
0
    def setMode(self, onOff):
        
        utilMod.killScriptJobs("G.microTransformScriptJobs")
                
        if onOff:
            
            self.rotationOrientMode         = cmds.manipRotateContext('Rotate', query=True, mode=True)
            cmds.manipRotateContext('Rotate', edit=True, mode=2)#gimbal
            #update values on turning on
            self.addMicroTransform()
            
            G.microTransformScriptJobs = []
            # get the current selected object values
            G.microTransformScriptJobs.append(cmds.scriptJob(runOnce = False, killWithScene = False, event =('SelectionChanged', self.addMicroTransform ))) 
            G.microTransformScriptJobs.append(cmds.scriptJob(runOnce = False, killWithScene = False, event =('timeChanged', self.updateValues )))
            G.microTransformScriptJobs.append(cmds.scriptJob(runOnce = False, killWithScene = False, event =('Undo', self.updateValues ))) 
            G.microTransformScriptJobs.append(cmds.scriptJob(runOnce = False, killWithScene = False, event =('Redo', self.updateValues ))) 
            G.microTransformScriptJobs.append(cmds.scriptJob(runOnce = False, killWithScene = False, event =('DragRelease', self.release ))) 
            

            
            #print "microTransform is ON."
            
        else:
            cmds.manipRotateContext('Rotate', edit=True, mode=self.rotationOrientMode)
            self.removeMicroTransform()
Beispiel #4
0
def rotSett(*args):
	sttng = cmds.radioButtonGrp("rottSetts", q=True, sl=True)

	if (sttng==1):
		rots = 0
	else:
		rots = 1
	
	cmds.manipRotateContext("Rotate", e=True, mode=rots)
Beispiel #5
0
def rotSett(*args):
	sttng = cmds.radioButtonGrp("rottSetts", q=True, sl=True)

	if (sttng==1):
		rots = 0
	else:
		rots = 1
	
	cmds.manipRotateContext("Rotate", e=True, mode=rots)
Beispiel #6
0
def hotRotate():
	rotateQuery = cmds.manipRotateContext('Rotate', q=True, mode=True) + 1
	if rotateQuery > 1:
		rotateQuery = 0
	if rotateQuery == 0:
		rotateName = 'object'
	elif rotateQuery == 1:
		rotateName = 'world'
	cmds.manipRotateContext('Rotate', edit=True, mode=rotateQuery)
	cmds.headsUpMessage('Rotate: ' + rotateName)
def nmManipulator_world():
    '''
	this function will set all the transform tools to world space.
	'''
    cmds.manipMoveContext('Move', e=True, mode=2)
    cmds.manipRotateContext('Rotate', e=True, mode=1)
    try:
        cmds.manipScaleContext('Scale', e=True, mode=2)
    except:
        pass
    # line
    nmGUI_func.nmGUI_runCheck(
        'complete', 'Manipulator tools have been set to world space.')
Beispiel #8
0
def HotKey_AxisSwitcher():
	# AxisSwitcher v2.1.0

	oPanel = cmds.getPanel(wf = True)
	if 'modelPanel' in oPanel: # if a viewport is acitve (Not graphEditor1/etc)
		oCamera = cmds.modelPanel(oPanel, query=True, camera=True).replace('Shape', '')


		iVal = cmds.manipMoveContext('Move', q = True, mode = True)

	if iVal == 1:
		cmds.manipMoveContext('Move', e = True, mode = 2)
		cmds.manipRotateContext('Rotate', e = True, mode = 1)
		aPrint = ['6bad64', 'WORLD', 0x6c756b] # Green
	elif iVal == 2:
		cmds.manipMoveContext('Move', e = True, mode = 0)
		cmds.manipRotateContext('Rotate', e = True, mode = 0)
		aPrint = ['d8766c', 'OBJECT', 0x756b6b] # Red
	elif iVal == 0:
		# Camera space Manipultor
		aCoordinate = cmds.xform(oCamera, q = True, a = True, ws = True, t = True)

		cmds.manipMoveContext('Move', e = True, mode = 6, activeHandle = 0, orientTowards = aCoordinate)
		cmds.manipRotateContext('Rotate', e = True, mode = 3)
		aPrint = ['9bbcf2', 'CAMERA', 0x485872] # Blue
	else:
		cmds.manipMoveContext('Move', e = True, mode = 1)
		cmds.manipRotateContext('Rotate', e = True, mode = 2)
		aPrint = ['a7a8af', 'LOCAL ', 0x6b6c75] # Gray

	cmds.inViewMessage(amg = '<text style="color:#%s";>%s</text>'%(aPrint[0], aPrint[1]), pos = 'botCenter', fade = True, fts = 7, ft = 'arial',bkc = aPrint[2] )
Beispiel #9
0
def set_commands(node_type='transform', pre_func=str, post_func=str):
    mc.manipMoveContext('Move', e=True, preDragCommand=[pre_func, node_type])
    mc.manipMoveContext('Move', e=True, postDragCommand=[post_func, node_type])
    mc.manipRotateContext('Rotate',
                          e=True,
                          preDragCommand=[pre_func, node_type])
    mc.manipRotateContext('Rotate',
                          e=True,
                          postDragCommand=[post_func, node_type])
    mc.manipScaleContext('Scale', e=True, preDragCommand=[pre_func, node_type])
    mc.manipScaleContext('Scale',
                         e=True,
                         postDragCommand=[post_func, node_type])
    # the drag commands are only active on reentering the context
    mc.setToolTo(mc.currentCtx())
Beispiel #10
0
	def __init__( self ):
		self.ButtonIsStart 				= False
		self.ObjectPicked				= None
		self.RotatePosition		    	= MTVector( 0.0, 0.0, 0.0 ) 
		self.RotateAroundSelected 		= -1
		self.SelectedObjects        	= None
		self.ObjectsToRotate        	= None
		self.IgnoreSelectionChangeEvent	= False
		self.CloseButtonPressed 		= False	
		self.DummyNode					= None
		self.CurrentContext				= None
		
		self.BuildUI()
		self.OnRotateAroundCenterBBoxSelected( None )
		self.OnSelectionChange()
		
		self.SelectionJob = cmds.scriptJob( event = ( "SelectionChanged", self.OnSelectionChange ), parent = self.Window )
		self.DeleteJob    = cmds.scriptJob( uiDeleted = ( self.Window, self.OnWindowClosed ) )
		
		# se crea un nodo invisible que servira para obtener las rotaciones de mundo
		self.DummyNode = cmds.createNode( "transform", skipSelect = True )		
		
		# nuevo rotator para saber cuando se termina de girar
		self.CurrentContext = cmds.currentCtx()
		self.ManipRotate = cmds.manipRotateContext( mode = 1, postDragCommand = ( self.OnObjectRotated, "transform" ) )	
Beispiel #11
0
def setManipCommands(nodeType='transform', preFunc=str, postFunc=str):
    mc.manipMoveContext('Move', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipMoveContext('Move', e=True, postDragCommand=[postFunc, nodeType])
    mc.manipRotateContext('Rotate', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipRotateContext('Rotate',
                          e=True,
                          postDragCommand=[postFunc, nodeType])
    mc.manipScaleContext('Scale', e=True, preDragCommand=[preFunc, nodeType])
    mc.manipScaleContext('Scale', e=True, postDragCommand=[postFunc, nodeType])
    # the drag commands are only active on reentering the context
    currentCtx = mc.currentCtx()
    if currentCtx in [
            'moveSuperContext', 'RotateSuperContext', 'scaleSuperContext'
    ]:
        # only set context if needed
        mc.setToolTo(currentCtx)
Beispiel #12
0
    def _testMultiSelectRotateUSD(self):
        '''Rotate multiple USD objects, read through Transform3d interface.'''

        # Select multiple balls to rotate them.
        proxyShapePathSegment = mayaUtils.createUfePathSegment(
            "|world|transform1|proxyShape1")

        balls = ['Ball_33', 'Ball_34']
        ballPaths = [
            ufe.Path([proxyShapePathSegment, 
                      usdUtils.createUfePathSegment('/Room_set/Props/'+ball)])
            for ball in balls]
        ballItems = [ufe.Hierarchy.createItem(ballPath) 
                     for ballPath in ballPaths]

        for ballItem in ballItems:
            ufe.GlobalSelection.get().append(ballItem)

        # We compare the UFE rotation with the USD run-time rotation.  To
        # obtain the full rotation of USD scene items, we need to add the USD
        # rotation to the Maya proxy shape rotation.
        proxyShapeXformObj = om.MSelectionList().add('transform1').getDagPath(0).node()
        proxyShapeXformFn = om.MFnTransform(proxyShapeXformObj)

        def usdSceneItemRotation(item):
            prim = usdUtils.getPrimFromSceneItem(item)
            if not prim.HasAttribute('xformOp:rotateXYZ'):
                return proxyShapeXformFn.rotation(om.MSpace.kTransform)
            else:
                x,y,z = prim.GetAttribute('xformOp:rotateXYZ').Get()
                return  proxyShapeXformFn.rotation(om.MSpace.kTransform) + om.MEulerRotation(radians(x), radians(y), radians(z))

        def ufeSceneItemRotation(item):
            return transform3dRotation(ufe.Transform3d.transform3d(item))

        # Set up the callables that will retrieve the rotation.
        self.runTimeRotation = usdSceneItemRotation
        self.ufeRotation = ufeSceneItemRotation

        # Give the tail item in the selection an initial rotation that
        # is different, to catch bugs where the relative rotation
        # incorrectly squashes any existing rotation.
        backItem = ballItems[-1]
        backT3d = ufe.Transform3d.transform3d(backItem)
        initialRot = [-10, -20, -30]
        backT3d.rotate(*initialRot)
        assertVectorAlmostEqual(self, [radians(a) for a in initialRot], 
                                     usdSceneItemRotation(backItem))

        # Save the initial positions to the memento list.
        expected = [usdSceneItemRotation(ballItem) for ballItem in ballItems]

        # MAYA-96058: unfortunately, rotate command currently requires a rotate
        # manipulator to be created to update the UFE object.
        manipCtx = cmds.manipRotateContext()
        cmds.setToolTo(manipCtx)

        #Temporarily disabling undo redo until we fix it for PR 94
        self.runMultiSelectTestRotate(ballItems, expected)
Beispiel #13
0
    def rotateModePress(self):

        # modes = {'Gimbal': 2, 'Global': 1, 'Local': 0}

        cmds.RotateToolMarkingMenu()

        mode = int(cmds.manipRotateContext('Rotate', q=True, mode=True))

        if self.tool == 'RotateSuperContext':
            if mode == 0:
                cmds.manipRotateContext('Rotate', e=True, mode=2)
                # 0 = Local, 1 = Global, 2 = Gimbal
                self.printMode('Gimbal', changed=True)
            elif mode == 2:
                cmds.manipRotateContext('Rotate', e=True, mode=1)
                self.printMode('Global', changed=True)
            elif mode == 1:
                cmds.manipRotateContext('Rotate', e=True, mode=0)
                self.printMode('Local', changed=True)

        elif mode == 0:
            self.printMode('Local')
        elif mode == 2:
            self.printMode('Gimbal')
        elif mode == 1:
            self.printMode('Global')
Beispiel #14
0
def setManip():

    manip = cmds.radioButtonGrp('manip', q=True, sl=True)

    # Setting to World Space
    if (manip == 1):
        cmds.manipMoveContext('Move', e=True, mode=2)
        cmds.manipRotateContext('Rotate', e=True, mode=1)
        cmds.manipScaleContext('Scale', e=True, mode=2)

    # Setting to Object Space
    elif (manip == 2):
        cmds.manipMoveContext('Move', e=True, mode=0)
        cmds.manipRotateContext('Rotate', e=True, mode=0)
        cmds.manipScaleContext('Scale', e=True, mode=0)

    maya.mel.eval('SelectToolOptionsMarkingMenu; MarkingMenuPopDown;'
                  )  # Changing Tool to selection
Beispiel #15
0
def manipRotateToggle():
    '''Toggles the Rotate Manip Context Through the useful modes'''
    try:
        if cmds.manipRotateContext('Rotate', q=1, mode=1) == 0:
            cmds.manipRotateContext('Rotate', e=1, mode=1)
        elif cmds.manipRotateContext('Rotate', q=1, mode=1) == 1:
            cmds.manipRotateContext('Rotate', e=1, mode=2)
        else:
            cmds.manipRotateContext('Rotate', e=1, mode=0)
    except Exception as e:
        print(e)
Beispiel #16
0
def manipRotateToggle():
    '''Toggles the Rotate Manip Context Through the useful modes'''
    try:
        if cmds.manipRotateContext('Rotate',q=1, mode=1 ) == 0:
            cmds.manipRotateContext('Rotate',e=1,mode=1)
        elif cmds.manipRotateContext('Rotate',q=1, mode=1 ) == 1:
            cmds.manipRotateContext('Rotate',e=1,mode=2)
        else:
            cmds.manipRotateContext('Rotate',e=1,mode=0)
    except Exception, e:
        print e
Beispiel #17
0
    def setMode(self, onOff):

        utilMod.killScriptJobs("G.microTransformScriptJobs")

        if onOff:

            self.rotationOrientMode = cmds.manipRotateContext('Rotate',
                                                              query=True,
                                                              mode=True)
            cmds.manipRotateContext('Rotate', edit=True, mode=2)  #gimbal
            #update values on turning on
            self.addMicroTransform()

            G.microTransformScriptJobs = []
            # get the current selected object values
            G.microTransformScriptJobs.append(
                cmds.scriptJob(runOnce=False,
                               killWithScene=False,
                               event=('SelectionChanged',
                                      self.addMicroTransform)))
            G.microTransformScriptJobs.append(
                cmds.scriptJob(runOnce=False,
                               killWithScene=False,
                               event=('timeChanged', self.updateValues)))
            G.microTransformScriptJobs.append(
                cmds.scriptJob(runOnce=False,
                               killWithScene=False,
                               event=('Undo', self.updateValues)))
            G.microTransformScriptJobs.append(
                cmds.scriptJob(runOnce=False,
                               killWithScene=False,
                               event=('Redo', self.updateValues)))
            G.microTransformScriptJobs.append(
                cmds.scriptJob(runOnce=False,
                               killWithScene=False,
                               event=('DragRelease', self.release)))

            #print "microTransform is ON."

        else:
            cmds.manipRotateContext('Rotate',
                                    edit=True,
                                    mode=self.rotationOrientMode)
            self.removeMicroTransform()
Beispiel #18
0
def toggleRotateMode():
    rot = cmds.manipRotateContext('Rotate', query=True, mode=True)
    
    # 0 = Local, 1 = Global, 2 = Gimbal
    if (rot == 0):
        cmds.manipRotateContext('Rotate', edit=True, mode=1)
    elif (rot == 1):
        cmds.manipRotateContext('Rotate', edit=True, mode=2)
    else:
        cmds.manipRotateContext('Rotate', edit=True, mode=0)
    def scriptJobCmds(self):

        mc.manipScaleContext('Scale', e=True, mode=6)
        mc.manipRotateContext('Rotate', e=True, mode=3)
        mc.manipMoveContext('Move', e=True, mode=6)

        #fix: isolateSelection
        viewSelectedSets = mc.ls('*ViewSelectedSet', type='objectSet')
        isolatedObjs = []
        panelName = ''

        for set in viewSelectedSets:
            isolatedObjs = mc.sets(set, q=True)

            if (len(isolatedObjs) == 0):
                continue

            panelName = set.split('ViewSelectedSet')[0]
            mc.isolateSelect(panelName, s=False)
            mc.isolateSelect(panelName, s=True)
            break
Beispiel #20
0
def toggleRotateMode():
    rot = cmds.manipRotateContext('Rotate', query=True, mode=True)

    # 0 = Local, 1 = Global, 2 = Gimbal
    if (rot == 0):
        cmds.manipRotateContext('Rotate', edit=True, mode=1)
    elif (rot == 1):
        cmds.manipRotateContext('Rotate', edit=True, mode=2)
    else:
        cmds.manipRotateContext('Rotate', edit=True, mode=0)
Beispiel #21
0
def rotateManip():
    mode = cmds.manipRotateContext('Rotate', q=True, mode=True)
    if mode == 0:
        cmds.manipRotateContext('Rotate', e=True, mode=2)
        message('Gimbal')
    elif mode == 2:
        cmds.manipRotateContext('Rotate', e=True, mode=0)
        message('Local')
    elif mode == 1:
        cmds.manipRotateContext('Rotate', q=True, mode=2)
        message('Gimbal')
Beispiel #22
0
def manipRotateContext(*args, **kwargs):
    if len(args):
        doPassSelf = kwargs.pop('passSelf', False)
    else:
        doPassSelf = False
    for key in ['pod', 'postCommand', 'postDragCommand', 'prc', 'prd', 'preCommand', 'preDragCommand', 'psc']:
        try:
            cb = kwargs[key]
            if callable(cb):
                kwargs[key] = _factories.makeUICallback(cb, args, doPassSelf)
        except KeyError:
            pass
    res = cmds.manipRotateContext(*args, **kwargs)
    return res
Beispiel #23
0
def lightingMode():
    light = 'dmptools_temp_directional_light'
    sel = cmds.ls(sl=True)
    if not sel:
        raise UserWarning('Please select something!')

    if not cmds.ls(light):
        light = cmds.directionalLight(name='dmptools_temp_directional_light')
    selM = cmds.xform(sel[0], q=True, matrix=True)
    lightT = cmds.listRelatives(light, p=True)[0]

    cmds.setAttr(light+'.locatorScale', 0.01)
    cmds.xform(lightT, matrix=selM)
    
    rotateCtx = cmds.manipRotateContext()
    cmds.setToolTo(rotateCtx)
    
    setSelectedLights()
Beispiel #24
0
	def rotateTool(self):
		try:
			if Cache.keyOffset == 0:
				cmds.manipRotateContext('myRotate', edit = True, mode = 0) # world mode
				Cache.currentContext = 'myRotate'
				self.setAttributes()
			else:
				cmds.manipRotateContext('myRotate', edit = True, mode = 1) # local mode
				Cache.currentContext = 'myRotate'
				self.setAttributes()
		except:
			if Cache.keyOffset == 0:
				cmds.manipRotateContext( 'myRotate', mode = 0 ) # world mode
				Cache.currentContext = 'myRotate'
				self.setAttributes()
			else:
				cmds.manipRotateContext('myRotate', mode = 1 ) # local mode
				Cache.currentContext = 'myRotate'
				self.setAttributes()
		cmds.setToolTo( Cache.currentContext )
Beispiel #25
0
    def testRotateUSD(self):
        '''Rotate USD object, read through the Transform3d interface.'''

        # Select Ball_35 to rotate it.
        ball35Path = ufe.Path([
            mayaUtils.createUfePathSegment("|world|transform1|proxyShape1"), 
            usdUtils.createUfePathSegment("/Room_set/Props/Ball_35")])
        ball35Item = ufe.Hierarchy.createItem(ball35Path)

        ufe.GlobalSelection.get().append(ball35Item)

        # Create a Transform3d interface for it.
        transform3d = ufe.Transform3d.transform3d(ball35Item)

        # We compare the UFE rotation with the USD run-time rotation.  To
        # obtain the full rotation of Ball_35, we need to add the USD
        # rotation to the Maya proxy shape rotation.
        proxyShapeXformObj = om.MSelectionList().add('transform1').getDagPath(0).node()
        proxyShapeXformFn = om.MFnTransform(proxyShapeXformObj)

        def ball35Rotation():
            ball35Prim = usdUtils.getPrimFromSceneItem(ball35Item)
            if not ball35Prim.HasAttribute('xformOp:rotateXYZ'):
                return proxyShapeXformFn.rotation(om.MSpace.kTransform)
            else:
                x,y,z = ball35Prim.GetAttribute('xformOp:rotateXYZ').Get()
                return  proxyShapeXformFn.rotation(om.MSpace.kTransform) + om.MEulerRotation(radians(x), radians(y), radians(z))

        # Set up the callables that will retrieve the rotation.
        self.runTimeRotation = ball35Rotation
        self.ufeRotation = partial(transform3dRotation, transform3d)

        # Save the initial position to the memento list.
        expected = ball35Rotation()

        # MAYA-96058: unfortunately, rotate command currently requires a rotate
        # manipulator to be created to update the UFE object.
        manipCtx = cmds.manipRotateContext()
        cmds.setToolTo(manipCtx)

        #Temporarily disabling undo redo until we fix it for PR 94
        self.runTestRotate(expected)
Beispiel #26
0
 def rotateTool(self):
     try:
         if Cache.keyOffset == 0:
             cmds.manipRotateContext('myRotate', edit=True,
                                     mode=0)  # world mode
             Cache.currentContext = 'myRotate'
             self.setAttributes()
         else:
             cmds.manipRotateContext('myRotate', edit=True,
                                     mode=1)  # local mode
             Cache.currentContext = 'myRotate'
             self.setAttributes()
     except:
         if Cache.keyOffset == 0:
             cmds.manipRotateContext('myRotate', mode=0)  # world mode
             Cache.currentContext = 'myRotate'
             self.setAttributes()
         else:
             cmds.manipRotateContext('myRotate', mode=1)  # local mode
             Cache.currentContext = 'myRotate'
             self.setAttributes()
     cmds.setToolTo(Cache.currentContext)
Beispiel #27
0
 def __init__(self):
     
     G.deferredManager.removeFromQueue("MT_blinking")
     
     if G.aToolsBar.microTransform: return
     G.aToolsBar.microTransform = self
     
     self.attributes = ['translate', 'translateX','translateY','translateZ','rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX','scaleY','scaleZ']
     
     self.multiplierValues = [ {"name":"ultraSlow",  "value":.05
                             },{"name":"superSlow",  "value":.2
                             },{"name":"slow",       "value":.5
                             },{"name":"medium",     "value":1
                             }]
     self.defaultMultiplier          = "slow"
     self.microTransformStartTimer   = {}
     self.microTransformValues       = {}
     self.onOff                      = False
     self.rotationOrientMode         = cmds.manipRotateContext('Rotate', query=True, mode=True)
     
     self.setMultiplier(self.getMultiplier())
     self.removeMicroTransform()
     self.blinkingButton(self.onOff)
Beispiel #28
0
    def __init__(self):

        G.deferredManager.removeFromQueue("MT_blinking")

        if G.aToolsBar.microTransform: return
        G.aToolsBar.microTransform = self

        self.attributes = [
            'translate', 'translateX', 'translateY', 'translateZ', 'rotate',
            'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY',
            'scaleZ'
        ]

        self.multiplierValues = [{
            "name": "ultraSlow",
            "value": .05
        }, {
            "name": "superSlow",
            "value": .2
        }, {
            "name": "slow",
            "value": .5
        }, {
            "name": "medium",
            "value": 1
        }]
        self.defaultMultiplier = "slow"
        self.microTransformStartTimer = {}
        self.microTransformValues = {}
        self.onOff = False
        self.rotationOrientMode = cmds.manipRotateContext('Rotate',
                                                          query=True,
                                                          mode=True)

        self.setMultiplier(self.getMultiplier())
        self.removeMicroTransform()
        self.blinkingButton(self.onOff)
Beispiel #29
0
def cus():
    cmds.manipMoveContext("Move", e=True, m=6)
    cmds.manipScaleContext("Scale", e=True, m=6)
    cmds.manipRotateContext("Rotate", e=True, m=6)
Beispiel #30
0
def wrd():
    cmds.manipMoveContext("Move", e=True, m=2)
    cmds.manipScaleContext("Scale", e=True, m=2)
    cmds.manipRotateContext("Rotate", e=True, m=1)
Beispiel #31
0
def bakePivot(ob, pos=1, ori=1):
    currentCtx = mc.currentCtx()
    contextList = [
        "moveSuperContext", "manipMoveContext", "RotateSuperContext",
        "manipRotateContext", "scaleSuperContext", "manipScaleContext"
    ]

    if currentCtx not in contextList:
        mc.error("m_bakeCustomToolPivot.kWrongToolError")
        return None

    # Check 3) must be in custom orientation mode
    customOri = []
    pivotModeActive = 0
    customModeActive = 0
    if currentCtx == "moveSuperContext" or currentCtx == "manipMoveContext":
        customOri = mc.manipMoveContext('Move', q=1, orientAxes=1)
        pivotModeActive = mc.manipMoveContext('Move', q=1, editPivotMode=1)
        customModeActive = mc.manipMoveContext('Move', q=1, mode=1) / 6
    elif (
        currentCtx == "RotateSuperContext"
        or currentCtx == "manipRotateContext"
    ):
        customOri = mc.manipRotateContext('Rotate', q=1, orientAxes=1)
        pivotModeActive = mc.manipRotateContext('Rotate', q=1, editPivotMode=1)
        customModeActive = mc.manipRotateContext('Rotate', q=1, mode=1) / 3
    elif (
        currentCtx == "scaleSuperContext" or currentCtx == "manipScaleContext"
    ):
        customOri = mc.manipScaleContext('Scale', q=1, orientAxes=1)
        pivotModeActive = mc.manipScaleContext('Scale', q=1, editPivotMode=1)
        customModeActive = mc.manipScaleContext('Scale', q=1, mode=1) / 6

    if ori and not pos and not customModeActive:
        mc.error("m_bakeCustomToolPivot.kWrongAxisOriModeError")
        return None

    # Get custom orientation
    if ori and customModeActive:
        customOri[0] = mel.eval('rad_to_deg({})'.format(customOri[0]))
        customOri[1] = mel.eval('rad_to_deg({})'.format(customOri[1]))
        customOri[2] = mel.eval('rad_to_deg({})'.format(customOri[2]))
        # Set object(s) rotation to the custom one
        # (preserving child transform positions and geometry positions)
        mc.rotate(
            customOri[0], customOri[1], customOri[2],
            ob, a=1, pcp=1, pgp=1, ws=1, fo=1
        )

    if pos:
        # Get pivot in parent space
        # object = 'pSphere4'
        old = [0, 0, 0]
        m = mc.xform(ob, q=1, m=1)
        p = mc.xform(ob, q=1, os=1, sp=1)
        old[0] = (p[0] * m[0] + p[1] * m[4] + p[2] * m[8] + m[12])
        old[1] = (p[0] * m[1] + p[1] * m[5] + p[2] * m[9] + m[13])
        old[2] = (p[0] * m[2] + p[1] * m[6] + p[2] * m[10] + m[14])

        # Zero out pivots
        mc.xform(ob, zeroTransformPivots=1)

        # Translate object(s) back to previous pivot
        # (preserving child transform positions and geometry positions)
        new = mc.getAttr(ob + ".translate")[0]
        mc.move(
            (old[0] - new[0]),
            (old[1] - new[1]),
            (old[2] - new[2]),
            ob, pcp=1, pgp=1, ls=1, r=1
        )

    # Exit pivot mode
    if pivotModeActive:
        mel.eval('ctxEditMode;')

    # Set the axis orientation mode back to object
    if ori and customModeActive:
        if (
            currentCtx == "moveSuperContext"
            or currentCtx == "manipMoveContext"
        ):
            mc.manipMoveContext('Move', e=1, mode=0)
        elif (
            currentCtx == "RotateSuperContext"
            or currentCtx == "manipRotateContext"
        ):
            mc.manipRotateContext('Rotate', e=True, mode=0)
        elif (
            currentCtx == "scaleSuperContext"
            or currentCtx == "manipScaleContext"
        ):
            mc.manipScaleContext('Scale', e=1, mode=0)
def setCustomAxisOrientation():
    '''
	TENTATIVE DE PATH DE L ISOLATE SELECTION ----
	
	#fix: isolateSelection   part1	
	viewSelectedSets = mc.ls( '*ViewSelectedSet' , type = 'objectSet' )
	isolatedObjs     = []
	panelName = ''
	
	for set in viewSelectedSets:
		isolatedObjs  = mc.sets( set , q = True )
		
		if( len(isolatedObjs) == 0 ):
		    continue
		 
		panelName = set.split( 'ViewSelectedSet' )[0]
		break
	#fix: isolateSelection   part1	
	
	'''

    selection = mc.ls(sl=True)
    locators = buildLocator.buildLocator()

    if (len(locators) > 1):
        mc.delete(locators)
        mc.error('marche pas avec plusieurs obj')

    rot = [0, 0, 0]
    rotRad = [0, 0, 0]

    rot[0] = mc.getAttr(locators[0] + '.rotateX')
    rot[1] = mc.getAttr(locators[0] + '.rotateY')
    rot[2] = mc.getAttr(locators[0] + '.rotateZ')

    rotRad[0] = math.radians(rot[0])
    rotRad[1] = math.radians(rot[1])
    rotRad[2] = math.radians(rot[2])

    mc.delete(locators)
    mc.select(selection)

    if (len(selection) == 0):
        return 0

    if ('.' in selection[0]):
        i = selection[0].index('.')
        selection[0] = selection[0][0:i]

    #changement orientation

    mel.eval('changeSelectMode -component;')
    mc.hilite(selection[0], r=True)

    mc.manipScaleContext('Scale', e=True, mode=6, orientAxes=rotRad)
    mc.manipRotateContext('Rotate', e=True, mode=3, orientAxes=rotRad)
    mc.manipMoveContext('Move', e=True, mode=6, orientAxes=rotRad)

    #fix gizmo au centre du monde
    mc.setToolTo('RotateSuperContext')
    mc.setToolTo('scaleSuperContext')
    mc.setToolTo('moveSuperContext')
    '''
	TENTATIVE DE PATH DE L ISOLATE SELECTION ----
		
	
	#fix: isolateSelection   part2	
	
	print( isolatedObjs )
	print( panelName )
	
	mc.refresh()

	if( len( isolatedObjs ) > 0 ):		
		mc.isolateSelect( panelName , s = False )
		for obj in isolatedObjs:
			mc.isolateSelect( panelName , ado = obj  )

	mc.isolateSelect( panelName , rdo = '|polySurface115.f[58]')
	mc.isolateSelect( panelName , u = True  )			
	mc.isolateSelect( panelName , s = True  )	
	
	'''

    #fix: scriptJob pour les changement de selection

    exec('maintainCustomOrientationSJW = scriptJobWindow()') in globals()
    exec('maintainCustomOrientationSJW.UI()') in globals()

    return 1
def MainWindow(V):
    print V
    try:
        Chcek_BakeAll = cmds.checkBox("Check_FrameLock", q=True, value=True)
    except:
        Chcek_BakeAll = []
    windowname = "ChangeOrder"
    WindowWidth_Size = 230
    WindowHight_Size = 300
    oObj = []

    if cmds.window(windowname, exists=True):
        cmds.deleteUI(windowname, window=True)
    Window = cmds.window(windowname,
                         title=windowname,
                         sizeable=True,
                         mxb=False,
                         wh=[WindowWidth_Size, WindowHight_Size])

    #Helpの為にメインメニューバーを追加します
    cmds.menuBarLayout()
    cmds.menu(label=u"Menu", tearOff=False)
    cmds.menuItem(label=Window + u"の解説", c=HelpWindow_Page)
    cmds.separator(w=WindowWidth_Size)
    cmds.setParent("..")

    cmds.columnLayout(w=WindowWidth_Size + 3)
    tab = cmds.tabLayout(w=WindowWidth_Size)

    tab1_B = cmds.frameLayout("ChangeOrder",
                              label="ChangeOrder",
                              bgc=[1.0, 0.3, 0.2])
    cmds.columnLayout(columnAttach=('left', 2))
    cmds.rowLayout('Orders', numberOfColumns=4, columnWidth2=[100, 40])
    cmds.optionMenu('Order_List', w=100, h=50)
    cmds.menuItem(l='0.  xyz')
    cmds.menuItem(l='1.     yzx')
    cmds.menuItem(l='2.        zxy')
    cmds.menuItem(l='3.  xzy')
    cmds.menuItem(l='4.     yxz')
    cmds.menuItem(l='5.        zyx')
    try:
        oObj = cmds.ls(sl=True, type="transform")[0]
        cmds.setToolTo("RotateSuperContext")
        cmds.manipRotateContext("Rotate", e=True, mode=2)
    except:
        pass
    if len(oObj) > 1:
        oObj_Order = cmds.getAttr(oObj + ".rotateOrder")
    else:
        oObj_Order = 0

    cmds.optionMenu('Order_List',
                    e=True,
                    bgc=[0.5, 0.2, 0.2],
                    ebg=False,
                    sl=oObj_Order + 1)
    cmds.button('exe', l=u'実行!', h=40, w=110, c='ChangeOrder_exe(%d)' % (0))
    cmds.separator(height=1)
    cmds.setParent(tab1_B)
    Lock = cmds.checkBox("FrameLock", label=u'フレームを保持しない')

    tab_2 = cmds.frameLayout("OrderCheck",
                             label="OrderCheck",
                             bgc=[0.2, 0.4, 0.6])
    cmds.columnLayout()
    cmds.text("")
    cmds.text(label=u"オーダー変更後の確認が行えます。")

    cmds.button('exe_test', l=u'オーダー確認', h=35, w=220, c=CheckOrder)
    cmds.separator(h=15)

    cmds.setParent(tab)

    tab2_B = cmds.frameLayout("Plot", label=u"Plot処理", bgc=[0.9, 0.1, 0.1])
    cmds.columnLayout()
    cmds.separator(h=15)
    cmds.button('remove', l=u'オーダーを元にもどす', h=60, w=220, c=Bake_BeforeOrder)
    cmds.separator(h=15)
    cmds.button('order_sel', l=u'オーダー変えたやつを選択', h=60, w=220, c=ChangeSelect)

    cmds.tabLayout(tab,
                   edit=True,
                   tabLabel=((tab1_B, u'オーダー変更'), (tab2_B, u"プロット")))
    if Chcek_BakeAll != []:
        if Chcek_BakeAll == True:
            cmds.checkBox("FrameLock", e=True, value=True)
    cmds.showWindow(Window)
Beispiel #34
0
def get_matrix():
    global SYM_AVOIDANCE
    global sb
    from . import sisidebar_main as sb
    #print '-------------get Matrix---------------- :'
    #print 'select obj :', cmds.ls(sl=True)
    #current_tool = cmds.currentCtx()
    #print 'current tool ;',  current_tool
    #cmds.setToolTo('selectSuperContext')
    #cmds.setToolTo(current_tool)
    if SYM_AVOIDANCE:
        SYM_AVOIDANCE = False
        return
    #ロックの有無をチェック
    try:
        sb.window.attribute_lock_state(mode=3, check_only=True)
    except Exception as e:
        print e.message
        pass
    try:  #2018up2以降の不具合対応
        sid = sb.space_group.checkedId()
    except Exception as e:
        print e.message
        return
    #一旦スケールX値をリセットしてメインウィンドウクラスに変更をお知らせする
    #sb.set_temp_text('change')
    sb.set_active_mute()
    scale = ['', '', '']
    rot = ['', '', '']
    trans = ['', '', '']
    if cmds.selectMode(q=True, o=True):
        selection = cmds.ls(sl=True, type='transform')
        if selection:
            try:
                s_list, r_list, t_list = get_srt(selection)
            except Exception as e:
                print e.message
                return
            #print 'get matrix :', s_list, r_list, t_list
            for i in range(3):
                s_list = [
                    map(lambda a: round(float(a), view_decimal), xyz)
                    for xyz in s_list
                ]
                r_list = [
                    map(lambda a: round(float(a), view_decimal), xyz)
                    for xyz in r_list
                ]
                t_list = [
                    map(lambda a: round(float(a), view_decimal), xyz)
                    for xyz in t_list
                ]
                if not all(s[i] == s_list[0][i] for s in s_list):
                    #print 'not same'
                    scale[i] = ''
                else:
                    #print 'same'
                    scale[i] = str(s_list[0][i])
                if not all(r[i] == r_list[0][i] for r in r_list):
                    #print 'not same', r_list
                    rot[i] = ''
                else:
                    #print 'same', r_list
                    rot[i] = str(r_list[0][i])
                if not all(t[i] == t_list[0][i] for t in t_list):
                    trans[i] = ''
                else:
                    trans[i] = str(t_list[0][i])
        #sb.check_key_anim()
        if np_flag:
            sb.view_np_time(culc_time='- Numpy Calculation Mode -')
        else:
            sb.view_np_time(culc_time='- Usual Calculation Mode -')
    selection = cmds.ls(sl=True, type='float3')
    #カーブもとっておく
    cv_selection = cmds.ls(sl=True, type='double3', fl=True)
    #print cv_selection
    if selection or cv_selection:
        #ラティスポイント他すべてを有効にする
        sel_str = str(selection + cv_selection)
        '''
        if '.vtx[' in sel_str:
            cmds.selectType(polymeshVertex=True)
            #cmds.selectType(particle=True)
        '''
        if '.cv[' in sel_str:
            cmds.selectType(cv=True)
            cmds.selectMode(co=True)
        if '.pt[' in sel_str:
            cmds.selectType(latticePoint=True)
            cmds.selectMode(co=True)
        #オブジェクトモードでもコンポーネント選択がある場合は強制的にモード変更する

        components = cmds.polyListComponentConversion(selection,
                                                      tv=True) + cv_selection
        #print components
        #if not components:
        s_list, r_list, t_list = get_srt(components, mode='component')
        start = dt.datetime.now()  #計測開始
        #マニプ情報取得に必要な情報を集める
        sym = cmds.symmetricModelling(q=True, symmetry=True)
        current_tool = cmds.currentCtx()
        tools_list = [
            'scaleSuperContext', 'RotateSuperContext', 'moveSuperContext'
        ]
        if sym:
            axis_list = ['x', 'y', 'z']
            sym_axis = cmds.symmetricModelling(q=True, ax=True)
            axis_id = axis_list.index(sym_axis)
            meshes = cmds.ls(hl=True, l=True)
            #マニプが有効でない場合はシンメトリ座標を取得できないので自前計算
            if not current_tool in tools_list:
                for i, value in enumerate(t_list):
                    if i % 3 == axis_id:
                        value = math.sqrt(value**2)
                        t_list[i] = value

        if np_flag:
            #print 'culc in numpy'
            s_list = np.reshape(s_list, (len(s_list) / 3, 3))
            scale = np.average(s_list, axis=0).tolist()
            r_list = np.reshape(r_list, (len(r_list) / 3, 3))
            rot = np.average(r_list, axis=0).tolist()
            t_list = np.reshape(t_list, (len(t_list) / 3, 3))
            trans = np.average(t_list, axis=0).tolist()
        else:
            #print 'culc in math'
            srt_list = [0, 0, 0, 0, 0, 0, 0, 0, 0]
            for i in range(0, len(s_list), 3):
                srt_list[0] += s_list[i + 0]
                srt_list[1] += s_list[i + 1]
                srt_list[2] += s_list[i + 2]
            scale = map(lambda a: a / (len(s_list) / 3), srt_list[0:3])
            for i in range(0, len(r_list), 3):
                srt_list[3] += r_list[i + 0]
                srt_list[4] += r_list[i + 1]
                srt_list[5] += r_list[i + 2]
            rot = map(lambda a: a / (len(r_list) / 3), srt_list[3:6])
            for i in range(0, len(t_list), 3):
                srt_list[6] += t_list[i + 0]
                srt_list[7] += t_list[i + 1]
                srt_list[8] += t_list[i + 2]
            trans = map(lambda a: a / (len(t_list) / 3), srt_list[6:9])
        #シンメトリのときとワールド座標の場合の処理
        #ワールド空間のときもMayaのマニピュレータ位置とあわせる
        if sym or sid == 0 or sid == 4:
            if current_tool in tools_list:
                if current_tool == 'moveSuperContext':
                    trans = cmds.manipMoveContext('Move', q=True, p=True)
                elif current_tool == 'RotateSuperContext':
                    trans = cmds.manipRotateContext('Rotate', q=True, p=True)
                elif current_tool == 'scaleSuperContext':
                    trans = cmds.manipScaleContext('Scale', q=True, p=True)
                #ワールド空間でない且つ選択オブジェクトが1つの場合はマトリクス計算で座標を求める
                if sid != 0 and sid != 4 and len(meshes) == 1:
                    scale = cmds.xform(meshes[0], q=True, s=True, ws=True)
                    #scale = [1.0]*3
                    if len(meshes) == 1:
                        pos = trans + [1]  #行列掛けるようの位置配列、末尾に1つけとく
                        if np_flag:
                            #マトリクス計算で座標求める
                            matrix = cmds.xform(meshes[0],
                                                q=True,
                                                m=True,
                                                ws=True)
                            matrix = np.reshape(matrix, (4, 4))
                            rev_matrix = np.linalg.inv(matrix)  #逆行列
                            #print 'get mesh matrix :', matrix, meshes[0]
                            #print 'get rev matrix np:', rev_matrix
                            mul_matrix_trans = np.dot(pos, matrix)
                            mul_rev_matrix_trans = np.dot(pos, rev_matrix)
                            #print 'mul matrix :', mul_matrix_trans
                            #print 'mul rev matrix :', mul_rev_matrix_trans
                            trans = scale * mul_rev_matrix_trans[:3]
                            #print 'Local trans np:', trans
                        else:  #Numpy使わない処理
                            matrix = cmds.xform(meshes[0],
                                                q=True,
                                                m=True,
                                                ws=True)
                            rev_matrix = pm.ls(
                                meshes[0])[0].transformationMatrix().inverse()
                            #print 'get rev matrix :', rev_matrix
                            pos = [pos]  #行列掛けるようの位置配列、末尾に1つけとく
                            #print matrix
                            #print rev_matrix
                            mul_rev_matrix_trans = mm.dot(pos, rev_matrix)[0]
                            #print mul_rev_matrix_trans
                            trans = mm.mul(mul_rev_matrix_trans[:3], scale)
                        #print 'Local trans :', trans
                    #print 'sym pos :',  trans, meshes, sid
        #print 'trans :', trans
        end = dt.datetime.now()
        culc_time = end - start
        sb.view_np_time(culc_time='Culc Time ' + str(culc_time))
        #表示桁数を調整する
    try:
        scale = map(lambda a: round(float(a), view_decimal)
                    if a != '' else '', scale)
        rot = map(lambda a: round(float(a), view_decimal)
                  if a != '' else '', rot)
        trans = map(lambda a: round(float(a), view_decimal)
                    if a != '' else '', trans)
        #念のため0のマイナス符号を除去、main側のセットでもやってるんで一旦ミュート
        #print rot
        #scale = map(lambda a : float(str(a).replace('-0.0', '0.0')) if a=='-0.0' else a, scale)
        #rot = map(lambda a : float(str(a).replace('-0.0', '0.0')) if a=='-0.0' else a, rot)
        #trans = map(lambda a : float(str(a).replace('-0.0', '0.0')) if a=='-0.0' else a, trans)
        #print rot
        sb.set_pre_transform(trans, rot, scale)
        sb.set_srt_text(scale, rot, trans)
    except:
        sb.set_pre_transform(trans, rot, scale)
        sb.set_srt_text(scale, rot, trans)
Beispiel #35
0
def set_reference(mode=''):
    c_ctx = cmds.currentCtx(q=True)
    #print c_ctx
    sel = cmds.ls(sl=True, l=True)
    #print 'set reference :', mode, sel
    current_ctx = cmds.currentCtx()
    if mode == 'object':
        #print 'set reference object mode :'
        cmds.selectMode(o=True)
        rot = cmds.xform(sel, q=True, ro=True, ws=True)
        pos = cmds.xform(sel, q=True, t=True, ws=True)
        rx = rot[0] / 180 * math.pi
        ry = rot[1] / 180 * math.pi
        rz = rot[2] / 180 * math.pi
        cmds.manipScaleContext('Scale', e=True, orientAxes=(rx, ry, rz))
        cmds.manipRotateContext('Rotate', e=True, orientAxes=(rx, ry, rz))
        cmds.manipMoveContext('Move', e=True, orientAxes=(rx, ry, rz))

        cmds.setToolTo('scaleSuperContext')  #マニプ表示がおかしくなるのでいったんコンテキスト設定してから戻す
        cmds.setToolTo('RotateSuperContext')
        cmds.setToolTo('moveSuperContext')
        cmds.setToolTo(current_ctx)
    else:
        if mode == 'vertex':
            manip_type = 'PointHandleTowards'
            comp = cmds.polyListComponentConversion(sel, tv=True)
            comp = cmds.filterExpand(comp, sm=31)
            sel_node = '" , "'.join(pre_sel)
            #print 'vertex ref :', sel_node, comp[0]
        if mode == 'edge':
            manip_type = 'AlignHandleWith'
            comp = cmds.polyListComponentConversion(sel, te=True)
            comp = cmds.filterExpand(comp, sm=32)
            sel_node = comp[0]
        if mode == 'face':
            manip_type = 'AlignHandleWith'
            comp = cmds.polyListComponentConversion(sel, tf=True)
            comp = cmds.filterExpand(comp, sm=34)
            sel_node = comp[0]
        if comp:
            mel.eval('manipScaleOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipScale' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
            mel.eval('manipRotateOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipRotate' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
            mel.eval('manipMoveOrient 5;')
            mel.eval('{  string $Selection1[]; $Selection1[0] = "' + comp[0] +
                     '"; manipMove' + manip_type + '($Selection1[0], {"' +
                     sel_node + '"}, {}, "", 0);;  };')
        cmds.selectMode(co=True)
        if pre_ref_mode == 'vertex':
            cmds.selectType(pv=1,
                            smu=0,
                            smp=1,
                            pf=0,
                            pe=0,
                            smf=0,
                            sme=0,
                            puv=0)
        if pre_ref_mode == 'edge':
            cmds.selectType(pv=0,
                            smu=0,
                            smp=0,
                            pf=0,
                            pe=1,
                            smf=0,
                            sme=1,
                            puv=0)
        if pre_ref_mode == 'face':
            cmds.selectType(pv=0,
                            smu=0,
                            smp=0,
                            pf=1,
                            pe=0,
                            smf=0,
                            sme=1,
                            puv=0)
        trans = cmds.xform(sel, q=True, t=True, ws=True)
        num = len(trans) / 3
        x = y = z = 0
        for i in range(0, len(trans), 3):
            x += trans[i]
            y += trans[i + 1]
            z += trans[i + 2]
        pos = [x / num, y / num, z / num]
        #sel_obj = []
        #obj_list = list(set([vtx.split('.')[0] for vtx in pre_sel]))
        #if obj_list:
        #sel_obj = [cmds.listRelatives(s, p=True)[0] if cmds.nodeType(s)=='mesh' else s for s in obj_list]
        #print obj_list, pre_sel
        #cmds.hilite(obj_list, r=True)
        #cmds.hilite(pre_sel, r=True)
    #print 'set to pre mode :', pre_ref_mode
    #print 'set to mode pre :', pre_ref_mode
    if pre_ref_mode == 'object':
        cmds.selectMode(o=True)
    else:
        cmds.selectMode(co=True)
        if pre_obj_list:
            cmds.hilite(pre_obj_list, r=True)
    if pre_sel:
        cmds.select(pre_sel, r=True)
    else:
        cmds.select(cl=True)
    sb.after_pick_context(ctx=c_ctx)
    #移動マニプを選択の中心に移動する
    cmds.manipPivot(p=pos)
Beispiel #36
0
def lcl():
    cmds.manipMoveContext("Move", e=True, m=0)
    cmds.manipScaleContext("Scale", e=True, m=0)
    cmds.manipRotateContext("Rotate", e=True, m=0)