Guest User

locator

a guest
May 5th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.47 KB | None | 0 0
  1. # import pymel
  2. import math
  3.  
  4. import pymel.api.plugins as plugins
  5. import maya.OpenMaya as om
  6.  
  7. class PymelTestNode(plugins.LocatorNode):
  8.     '''Test plugin node
  9.     '''
  10.     _typeId = om.MTypeId(0x9000F)
  11.     _name = 'PymelTestNode'
  12.    
  13.     @classmethod
  14.     def initialize(cls):
  15.  
  16.         nAttr = om.MFnNumericAttribute()
  17.         mAttr = om.MFnMatrixAttribute()
  18.         cAttr = om.MFnCompoundAttribute()
  19.        
  20.         cls.input = nAttr.create( "input", "in", om.MFnNumericData.kFloat, 0.0 )
  21.         nAttr.setStorable(1)
  22.         nAttr.setWritable(1)
  23.         nAttr.setKeyable(1)
  24.         cls.addAttribute( cls.input )
  25.        
  26.         # outputFloat
  27.         cls.outputFloat = nAttr.create( "outputFloat", "of", om.MFnNumericData.kFloat, 0.0 )
  28.         nAttr.setStorable(0)
  29.         nAttr.setWritable(0)
  30.         cls.addAttribute( cls.outputFloat )
  31.        
  32.         # outputInt
  33.         cls.outputInt = nAttr.create( "outputInt", "oi", om.MFnNumericData.kInt, 0.0 )
  34.         nAttr.setStorable(0)
  35.         nAttr.setWritable(0)
  36.         cls.addAttribute( cls.outputInt )
  37.        
  38.         # output
  39.         cls.output = cAttr.create( "output", "out")
  40.         cAttr.addChild(cls.outputFloat)
  41.         cAttr.addChild(cls.outputInt)
  42.         nAttr.setStorable(0)
  43.         nAttr.setWritable(0)
  44.         nAttr.setArray(True)
  45.         cls.addAttribute( cls.output )
  46.        
  47.         # worldFloat
  48.         #cls.worldFloat = nAttr.create("worldFloat", "wf", om.MFnNumericData.kFloat, 0.0 )
  49.         #nAttr.setStorable(False)
  50.         #nAttr.setWritable(False)
  51.         #nAttr.setArray(True)
  52.         #nAttr.setWorldSpace(1)
  53.         #cls.addAttribute( cls.worldFloat )
  54.        
  55.         # dummyWorldDest
  56.         #cls.dummyWorldDest = nAttr.create("dummyWorldDest", "d", om.MFnNumericData.kFloat, 0.0 )
  57.         #nAttr.setStorable(False)
  58.         #nAttr.setWritable(True)
  59.         #nAttr.setReadable(True)
  60.         #nAttr.setHidden(True)
  61.         #nAttr.setArray(True)
  62.         #nAttr.setIndexMatters(False)
  63.         #cls.addAttribute( cls.dummyWorldDest )
  64.        
  65.         # worldIn
  66.         cls.worldIn = mAttr.create("worldIn", "wi")
  67.         mAttr.setStorable(True)
  68.         nAttr.setWritable(True)
  69.         nAttr.setReadable(True)
  70.         nAttr.setArray(False)
  71.         cls.addAttribute( cls.worldIn )
  72.        
  73.         # set attribute affects
  74.         cls.attributeAffects( cls.worldMatrix, cls.output )
  75.         #cls.attributeAffects( cls.dummyWorldDest, cls.output )
  76.         cls.attributeAffects( cls.parentmatrix, cls.output )
  77.  
  78.  
  79.     def compute(self, plug, dataBlock):
  80.         print "compute called for:", plug.name()
  81.         if ( plug == self.output ):
  82.             return True
  83.         return False
  84.  
  85. ## initialize the script plug-in
  86. def initializePlugin(mobject):
  87.     PymelTestNode.register(mobject)
  88.  
  89. # uninitialize the script plug-in
  90. def uninitializePlugin(mobject):
  91.     PymelTestNode.deregister(mobject)
Advertisement
Add Comment
Please, Sign In to add comment