69 from builtins
import next
71 import maya.OpenMaya
as OpenMaya
72 import maya.OpenMayaMPx
as OpenMayaMPx
74 kPluginName =
"spBlindDoubleData"
83 stream=OpenMaya.MStreamUtils.stdOutStream()
84 OpenMaya.MStreamUtils.writeCharBuffer(stream,msg)
87 class blindDoubleData(OpenMayaMPx.MPxData):
89 OpenMayaMPx.MPxData.__init__(self)
91 fValueDictionary[OpenMayaMPx.asHashable(self)]=self.__fValue
93 def readASCII(self, args, lastParsedElement):
96 parsedIndex = OpenMaya.MScriptUtil.getUint(lastParsedElement)
97 self.__fValue = args.asDouble( parsedIndex )
99 OpenMaya.MScriptUtil.setUint(lastParsedElement,parsedIndex)
100 fValueDictionary[OpenMayaMPx.asHashable(self)]=self.__fValue
102 sys.stderr.write(
"Failed to read ASCII value.")
105 def readBinary(self, inStream, length):
106 readParam = OpenMaya.MScriptUtil(0.0)
107 readPtr = readParam.asDoublePtr()
108 OpenMaya.MStreamUtils.readDouble(inStream, readPtr,
True )
109 self.__fValue = readParam.getDouble(readPtr)
111 def writeASCII(self, out):
113 OpenMaya.MStreamUtils.writeDouble(out, self.__fValue,
False)
115 sys.stderr.write(
"Failed to write ASCII value.")
118 def writeBinary(self, out):
120 OpenMaya.MStreamUtils.writeDouble(out, self.__fValue,
True)
122 sys.stderr.write(
"Failed to write binary value.")
125 def copy(self, other):
128 self.__fValue = fValueDictionary[OpenMayaMPx.asHashable(other)]
139 def setValue(self, newVal):
140 self.__fValue = newVal
143 class blindDoubleDataCmd(OpenMayaMPx.MPxCommand):
145 OpenMayaMPx.MPxCommand.__init__(self)
148 def doIt(self, args):
158 sys.stderr.write(err)
163 while not self.__iter.isDone():
168 self.__iter.getDependNode(dependNode)
170 error(
"Error getting the dependency node")
176 error(
"Error creating MFnDependencyNode")
182 newAttr = fnAttr.create(
"blindDoubleData",
"BDD", kPluginDataId)
186 fnDN.addAttribute(newAttr, OpenMaya.MFnDependencyNode.kLocalDynamicAttr)
194 newData = OpenMayaMPx.asMPxPtr(blindDoubleData())
195 newData.setValue(3.2)
199 plug.setMPxData(newData)
204 sData = plug.asMObject()
206 error(
"Error getting value off plug")
212 data = pdFn.constData()
217 error(
"Error: failed to retrieve data.")
225 def isUndoable(self):
234 return OpenMayaMPx.asMPxPtr(blindDoubleDataCmd())
237 return OpenMayaMPx.asMPxPtr(blindDoubleData())
240 def initializePlugin(mobject):
241 mplugin = OpenMayaMPx.MFnPlugin(mobject,
"Autodesk",
"1.0",
"Any")
243 mplugin.registerData(kPluginName, kPluginDataId, dataCreator)
245 sys.stderr.write(
"Failed to register new data type: %s\n" % kPluginName)
249 mplugin.registerCommand(kPluginName, cmdCreator)
251 sys.stderr.write(
"Failed to register command: %s\n" % kPluginName)
256 def uninitializePlugin(mobject):
257 mplugin = OpenMayaMPx.MFnPlugin(mobject)
259 mplugin.deregisterCommand(kPluginName)
261 sys.stderr.write(
"Failed to unregister command: %s\n" % kPluginName)
265 mplugin.deregisterData(kPluginDataId)
267 sys.stderr.write(
"Failed to unregister data type: %s\n" % kPluginName)