[B]Hi
i watched Digital Tutors tutorial and he teach a plug-in (called jitter)as below but it wont working with maya2010 or you might find the problem in it and help me to fix it.
by the way thank you for your time reading this Thread.
but it does not work in maya2010 or some forums said i have to have 64bit os[/B]:tear:
import maya.standalone
maya.standalone.initialize(name=‘python’)
#Import Desired Libraries Here
import maya.OpenMaya as om
import maya.OpenMayaMPx as omMPx
#Set name and ID
nodeName = “jitter”
nodeId = om.MTypeId(0x101112)
Jitter Node - uses MPXNode as a base node
class jitterNode(omMPx.MPxNode):
# input and output variables
INPUT = om.MObject()
OUTPUT = om.MObject()
def __init__(self):
omMPx.MPxNode.__init__(self)
def cmpute(self, plug, dataBlock):
if (plug == jitterNode.OUTPUT):
dataHandel = dataBlock.inputValue(jitterNode.INPUT)
inFloat = dataHandel.asFloat()
result = random.uniform(-1,1) + inFloat
outputHandel = dataBlock.outputValue(jitterNode.OUTPUT)
outputHandel.setFloat(result)
dataBlock.setClean(plug)
def nodeCreater():
return omMPx.asMPxPtr(jitterNode())
def nodInit():
numAttr = om.MFnNumericAttribute()
jitterNode.INPUT = numAttr.creat(“input”,“in”,om.MFnNumericData.KFloat,0.0)
numAttr.setStorable(1)
numAttr = om.MFnNumericAttribute()
jitterNode.OUTPUT = numAttr.creat("output","out",om.MFnNumericData.KFloat,0.0)
numAttr.setStorable(1)
numAttr.setWritable(1)
jitterNode.addAttribute(jitterNode.INPUT)
jitterNode.addAttribute(jitterNode.OUTPUT)
jitterNode.attributeAffects(jitterNode.INPUT, jitterNode.OUTPUT)
This is used for loadind plugins
def initializPlugin(mobjects):
mplugin = omMPx.MFnPlugin(mobject)
try:
mplugin.registerNode(nodeName, nodId, nodeCreater, nodeInit)
except:
sys.stderr.write("Error loading")
raise
This is used for removing plugins
def uninitializPlugin(mobject):
mplugin = omMPx.MFnPlugin(mobject)
try:
mplugin.deregisterNode(nodeId)
except:
sys.stderr.write(“Error removing”)
raise