SHARE
TWEET

Untitled

a guest May 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. import maya.api.OpenMaya as om2
  4. #import maya.api.OpenMayaUI as omui
  5.  
  6. kPluginCmdName = "editorSampleCommand" # MELコマンド名
  7.  
  8. kShortFlagName = "-ts"         # 引数のショートネーム
  9. kLongFlagName = "-test"   # 引数のロングネーム
  10.  
  11. def maya_useNewAPI():
  12.     pass
  13.    
  14. class EditorSampleCommandClass( om2.MPxCommand ):
  15.    
  16.     def __init__(self):
  17.         #reload(sivertexcoloreditor)
  18.         ''' Constructor. '''
  19.         om2.MPxCommand.__init__(self)
  20.    
  21.     def doIt(self, args):
  22.         test = self.parseArguments( args )
  23.         #print 'ignore undo :', ignore_undo
  24.         self.redoIt()
  25.        
  26.     def parseArguments(self, args):
  27.         self.weights = []
  28.         print 'args :', self.syntax(), args
  29.         argData = om2.MArgParser(self.syntax(), args)
  30.         num = argData.numberOfFlagUses('-w')
  31.         print 'arg num :', num
  32.         #print 'arg w :', argData.flagArgumentDouble( '-w', 0)
  33.         for i in range(num):
  34.             pos = argData.getFlagArgumentPosition('-w', i)
  35.             print 'pos :', pos
  36.             argsList = argData.getFlagArgumentList('-w', i)
  37.             print 'argsList :', argsList
  38.             print 'w data :', argsList.asDouble( 0)
  39.             print 'type:', type(argsList.asDouble( 0))
  40.            
  41.         '''
  42.         if argData.isFlagSet( '-rb' ):
  43.             flagValue = argData.flagArgumentBool( '-rb', 0)
  44.         if argData.isFlagSet( '-iu' ):
  45.             ignore_undo = argData.flagArgumentBool( '-iu', 0)
  46.         '''
  47.         return None
  48.        
  49.     def redoIt(self, flash=True):
  50.         pass
  51.    
  52.     def undoIt(self):
  53.         pass
  54.        
  55.     def isUndoable(self):
  56.         return True
  57.  
  58. def cmdCreator():
  59.     return EditorSampleCommandClass()
  60.    
  61. def syntaxCreator():
  62.     syntax = om2.MSyntax()
  63.     syntax.addFlag( '-w', '-weights', om2.MSyntax.kDouble)
  64.     syntax.makeFlagMultiUse( '-w')
  65.     #syntax.addFlag( '-rb', '-realbake', om2.MSyntax.kBoolean )
  66.     #syntax.addFlag( '-iu', '-ignoreundo', om2.MSyntax.kBoolean )
  67.     return syntax
  68.  
  69. def initializePlugin( mobject ):
  70.     mplugin = om2.MFnPlugin( mobject )
  71.     try:
  72.         mplugin.registerCommand( kPluginCmdName, cmdCreator, syntaxCreator )
  73.         #引数持たせないバージョン
  74.         #mplugin.registerCommand( kPluginCmdName, cmdCreator)
  75.     except:
  76.         sys.stderr.write( 'Failed to register command: ' + kPluginCmdName )
  77.  
  78. def uninitializePlugin( mobject ):
  79.     mplugin = om2.MFnPlugin( mobject )
  80.     try:
  81.         mplugin.deregisterCommand( kPluginCmdName )
  82.     except:
  83.         sys.stderr.write( 'Failed to unregister command: ' + kPluginCmdName )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top