示例#1
0
    def readBinary(self, inStream, numBytesToRead):
        """Read in 4 byte packs to cStringIO, unpickle from there
        
        :note: this method is more complicated than it needs be since asCharPtr does not work !
            It returns a string of a single char ... which is not the same :) !
        :note: YES, this is a CUMBERSOME way to deal with bytes ... terrible, thanks maya :), thanks python"""
        sio = cStringIO.StringIO()
        scriptutil = api.MScriptUtil()
        scriptutil.createFromInt(0)
        intptr = scriptutil.asIntPtr()

        # require multiple of 4 !
        if numBytesToRead % 4 != 0:
            raise AssertionError("Require multiple of for for number of bytes to be read, but is %i" % numBytesToRead)

        bitmask = 255                               # mask the lower 8 bit
        shiftlist = [0, 8, 16, 24]              # used to shift bits by respective values
        for i in xrange(numBytesToRead  / 4):
            api.MStreamUtils.readInt(inStream, intptr, True)
            intval = scriptutil.getInt(intptr)

            # convert to chars - endianess should be taken care of by python
            for shift in shiftlist:
                sio.write(chr((intval >> shift) & bitmask))
            # END for each byte
        # END for all 4 bytes to read

        self.__data = cPickle.loads(binascii.a2b_base64(sio.getvalue()))
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
示例#2
0
    def nodeCreator(cls):

        """
        !@Brief Node creator function. Get maya API help for more informations.
        """

        return OpenMayaMPx.asMPxPtr(cls())
示例#3
0
def cmdCreator():
    # Create the command
    """
    
    Return:
        pointer to the command
    
    """
    ptr = OpenMayaMPx.asMPxPtr(SamplePyCmd())
    return ptr
示例#4
0
	def readASCII(self, args, lastParsedElement):
		try:
			if args.length() > 0:
				parsedIndex = OpenMaya.MScriptUtil.getUint(lastParsedElement)
				self.__fValue = args.asDouble( parsedIndex )
				parsedIndex += 1
				OpenMaya.MScriptUtil.setUint(lastParsedElement,parsedIndex)
				fValueDictionary[OpenMayaMPx.asHashable(self)]=self.__fValue
		except:
			sys.stderr.write("Failed to read ASCII value.")
			raise
示例#5
0
    def readASCII(self, args, lastParsedElement):
        """Read base64 element and decode to cStringIO, then unpickle"""
        parsedIndex = api.MScriptUtil.getUint(lastParsedElement)
        base64encodedstring = args.asString(parsedIndex)
        self.__data = cPickle.loads(binascii.a2b_base64(base64encodedstring))

        parsedIndex += 1
        api.MScriptUtil.setUint(lastParsedElement,parsedIndex)  # proceed the index

        # update tracking dict
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
示例#6
0
 def __del__(self):
     """Remove ourselves from the dictionary to prevent flooding
     
     :note: we can be called even if maya is already unloaded or shutting down"""
     if mpx.asHashable is not None:
         del(sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)])
     # call super just to be on the safe side in future, currently it appears
     # not to be required
     try:
         super(PyPickleData, self).__del__()
     except AttributeError:
         # Maya 2008 and following do not require this anymore as they
         # do not have a del method implemented apparently
         pass
示例#7
0
	def doEditFlags(self):
		theParser = self._parser()
		theControl = kPythonPtrTable.get(OpenMayaMPx.asHashable(self._control()), None)

		if theParser.isFlagSet(kNopFlag):
			theControl.setOperation(kNop)
		elif theParser.isFlagSet(kMultFlag):
			theControl.setOperation(kMult)
		elif theParser.isFlagSet(kAddFlag):
			theControl.setOperation(kAdd)
		elif theParser.isFlagSet(kRedrawFlag):
			theControl.redrawCells()
			theControl.redrawLabels()
		else:
			OpenMayaMPx.MPxControlCommand.doEditFlags(self)
示例#8
0
	def doPress(self, event):
		OpenMayaMPx.MPxSelectionContext.doPress(self, event)
		spc = OpenMaya.MSpace.kWorld

		# If we are not in selecting mode (i.e. an object has been selected)
		# then set up for the translation.
		#
		if not self._isSelecting():
			argX = OpenMaya.MScriptUtil()
			argX.createFromInt(0)
			argXPtr = argX.asShortPtr()
			argY = OpenMaya.MScriptUtil()
			argY.createFromInt(0)
			argYPtr = argY.asShortPtr()
			event.getPosition(argXPtr, argYPtr)
			self.__startPos_x = OpenMaya.MScriptUtil(argXPtr).asShort()
			self.__startPos_y = OpenMaya.MScriptUtil(argYPtr).asShort()
			self.__view = OpenMayaUI.M3dView.active3dView()

			camera = OpenMaya.MDagPath()
			self.__view.getCamera(camera)
			fnCamera = OpenMaya.MFnCamera(camera)
			upDir = fnCamera.upDirection(spc)
			rightDir = fnCamera.rightDirection(spc)

			# Determine the camera used in the current view
			#
			if fnCamera.isOrtho():
				if upDir.isEquivalent(OpenMaya.MVector.zNegAxis, kVectorEpsilon):
					self.__currWin = MoveContext.kTop
				elif rightDir.isEquivalent(OpenMaya.MVector.xAxis, kVectorEpsilon):
					self.__currWin = MoveContext.kFront
				else:
					self.__currWin = MoveContext.kSide
			else:
				self.__currWin = MoveContext.kPersp

			# Create an instance of the move tool command.
			#
			newCmd = self._newToolCommand()
			self.__cmd = kTrackingDictionary.get(OpenMayaMPx.asHashable(newCmd), None)
			self.__cmd.setVector(0.0, 0.0, 0.0)
def nodeCreator():
	return OpenMayaMPx.asMPxPtr( dynNode() )
示例#10
0
 def nodeCreator(cls):
     return OpenMayaMPx.asMPxPtr(cls())
def nodeCreator():
	return OpenMayaMPx.asMPxPtr( vertSnapDeformer() )
示例#12
0
def creator():
    return OpenMayaMPx.asMPxPtr(gear_curveCns())
示例#13
0
def initializePlugin(mobject):
	mplugin = omMPx.MFnPlugin(mobject)
	try:
		mplugin.registerNode( kPluginNodeTypeName, stickyDeformerId, nodeCreator, nodeInitializer, omMPx.MPxNode.kDeformerNode )
	except:
		sys.stderr.write( "Failed to register node: %s\n" % kPluginNodeTypeName )
示例#14
0
		return OpenMayaMPx.asMPxPtr( moveManipContext() )
示例#15
0
 def nodeCreator(cls):
     return OpenMayaMPx.asMPxPtr(cls())
示例#16
0
def nodeCreator():
    '''creator
    '''
    return OpenMayaMPx.asMPxPtr(oyTrajectoryDrawer())
示例#17
0
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(CVG())
示例#18
0
def nodeCreator():
    return ompx.asMPxPtr(ParentConstraint())
示例#19
0
def cmdCreator():

    return ompx.asMPxPtr(ParentConstraintCmd())
示例#20
0
def uninitializePlugin(obj):
    fnPlugin = OpenMayaMpx.MFnPlugin(obj)
    fnPlugin.deregisterNode(varfkNode.kPluginNodeId)
示例#21
0
def initializePlugin(obj):
    fnPlugin = OpenMayaMpx.MFnPlugin(obj, 'Bogdan Diaconu', '1.0', 'Any')
    fnPlugin.registerNode('varfkNode', varfkNode.kPluginNodeId, creator,
                          initialize)
示例#22
0
def creator():
    return OpenMayaMpx.asMPxPtr(varfkNode())
示例#23
0
def nodeCreator():
	# TODO change this node name
	return OpenMayaMPx.asMPxPtr(nodeName)
示例#24
0
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterNode( nodeID )
    except:
        sys.stderr.write( "Failed to unregister command: %s\n" % nodeName )
示例#25
0
def creator():
    return OpenMayaMPx.asMPxPtr( gear_percentageToU() )
示例#26
0
 def nodeCreator(cls):
     print('nodeCreator')
     return ommpx.asMPxPtr(cls())
def cmdCreator():
    return OpenMayaMPx.asMPxPtr( scriptedCommand() )
示例#28
0
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(ehm_pushDeformer())
def contextCmdCreator():
    """Wrapper function that created the command"""
    return OpenMayaMPx.asMPxPtr(mayaSelctionCtxCmd())
示例#30
0
def uninitializePlugin(mobject):
	mplugin = omMPx.MFnPlugin(mobject)
	try:
		mplugin.deregisterNode( stickyDeformerId )
	except:
		sys.stderr.write( "Failed to unregister node: %s\n" % kPluginNodeTypeName )
示例#31
0
def cmdCreator():
    return ompx.asMPxPtr(selPoles())
示例#32
0
def nodeCreator():
	return omMPx.asMPxPtr( stickyDeformer() )
def nodeCreator():
	return OpenMayaMPx.asMPxPtr( sceneMsgCmd() )
示例#34
0
 def commandCreator():
     return OpenMayaMPx.asMPxPtr(createCameraFrustum())
示例#35
0
def normalizeCreator():
    return OpenMayaMPx.asMPxPtr( normalize() )
def nodeCreator():
	return  OpenMayaMPx.asMPxPtr(jiggleNode())
示例#37
0
def locatorManipCreator():
    return OpenMayaMPx.asMPxPtr(swissArmyLocatorManip())
示例#38
0
def uninitializePlugin(mObj):
    plugin = OpenMayaMPx.MFnPlugin(mObj)
    try:
        plugin.deregisterNode(nodeId)
    except:
        sys.stderr.write('Faild to unload plugin: %s' % nodeName)
示例#39
0
 def create(cls):
     return mpx.asMPxPtr( cls() )    
示例#40
0
 def cmdCreator():
     return OpenMayaMPx.asMPxPtr(WhatIsCmd())
示例#41
0
def nodeCreator():
	return OpenMayaMPx.asMPxPtr(stretchSplineSolver())
示例#42
0
def nodeCreatorLSystem():
    return OpenMayaMPx.asMPxPtr( LSystemInstanceNode() )
def ms_environment_nodeCreator():
    return OpenMayaMPx.asMPxPtr(ms_environment())
示例#44
0
def nodeCreatorRandom():
    return OpenMayaMPx.asMPxPtr( randomNode() )
def cmdCreator():
    return OpenMayaMPx.asMPxPtr(InheritParentsName())
示例#46
0
def initializePlugin(mobject):
    # Create menu
    buildMenu = "if (`menu -exists LSystemInstance`) { deleteUI LSystemInstance; }; "
    buildMenu += "menu -parent MayaWindow -label \"LSystemInstance\" -tearOff true LSystemInstance; "
    mel.eval(buildMenu)

    mplugin = OpenMayaMPx.MFnPlugin(mobject)

    # load randomNode commands
    try:
        mplugin.registerNode(kPluginNodeTypeName2, randomNodeId, nodeCreatorRandom, nodeInitializerRandom)

        # default randomNode network
        defaultRandom = "polySphere; hide; instancer; createNode randomNode; "
        defaultRandom += "connectAttr pSphere1.matrix instancer1.inputHierarchy[0]; "
        defaultRandom += "connectAttr randomNode1.outPoints instancer1.inputPoints; "
        cmds.menuItem(label="RandomNode Default",
                      parent="MayaWindow|LSystemInstance",
                      command=defaultRandom, sourceType="mel")

        # custom randomNode network
        customRandom = "$selection = `ls -selection`; "
        customRandom += "if(size($selection) != 1) { error \"Select one object\"; }; "
        customRandom += "hide; instancer; createNode randomNode; "
        customRandom += "connectAttr ($selection[0] + \".matrix\") instancer1.inputHierarchy[0]; "
        customRandom += "connectAttr randomNode1.outPoints instancer1.inputPoints; "
        cmds.menuItem(label="RandomNode Selection",
                      parent="MayaWindow|LSystemInstance",
                      command=customRandom,
                      sourceType="mel")

    except:
        sys.stderr.write("Failed to register node: %s\n" % kPluginNodeTypeName2)

    # load LSystem commands
    try:
        mplugin.registerNode(kPluginNodeTypeName1, LSystemInstanceNodeId, nodeCreatorLSystem, nodeInitializerLSystem)

        # default LSystem network
        defaultLSystem = "polyCube; instancer; createNode LSystemInstanceNode; "
        defaultLSystem += "connectAttr pCube1.matrix instancer1.inputHierarchy[0]; "
        defaultLSystem += "connectAttr LSystemInstanceNode1.branches instancer1.inputPoints; "
        defaultLSystem += "polySphere; instancer; "
        defaultLSystem += "connectAttr pSphere1.matrix instancer2.inputHierarchy[0]; "
        defaultLSystem += "connectAttr LSystemInstanceNode1.flowers instancer2.inputPoints; "
        defaultLSystem += "select -add pCube1; "
        defaultLSystem += "hide; "
        cmds.menuItem(label="LSystem Default",
                      parent="MayaWindow|LSystemInstance",
                      command=defaultLSystem, sourceType="mel")

        # custom LSystem network
        customLSystem = "$selection = `ls -selection`; hide; "
        customLSystem += "if(size($selection) != 2) { error \"Select two objects (branches, flowers)\"; }; "
        customLSystem += "instancer; createNode LSystemInstanceNode; "
        customLSystem += "connectAttr ($selection[0] + \".matrix\") instancer1.inputHierarchy[0]; "
        customLSystem += "connectAttr LSystemInstanceNode1.branches instancer1.inputPoints; "
        customLSystem += "instancer; "
        customLSystem += "connectAttr ($selection[1] + \".matrix\") instancer2.inputHierarchy[0]; "
        customLSystem += "connectAttr LSystemInstanceNode1.flowers instancer2.inputPoints; "
        cmds.menuItem(label="LSystem Custom",
                      parent="MayaWindow|LSystemInstance",
                      command=customLSystem,
                      sourceType="mel")
    except:
        sys.stderr.write( "Failed to register node: %s\n" % kPluginNodeTypeName1 )
示例#47
0
def creator():
    return OpenMayaMPx.asMPxPtr(cvShapeInverter())
示例#48
0
def helixManipCreator():
    #print "helixManip: helixManipCreator called"
    return OpenMayaMPx.asMPxPtr(helixManip())
示例#49
0
 def create():
     return OpenMayaMPx.asMPxPtr(Ik2bCGA())
示例#50
0
def cmdCreator():
    return OpenMayaMPx.asMPxPtr( scriptedCommand() )
示例#51
0
		OpenMayaMPx.MPxContextCommand.__init__(self)
示例#52
0
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterCommand( kPluginCmdName )
    except:
        sys.stderr.write( "Failed to unregister command: %s\n" % kPluginCmdName )
示例#53
0
def moveManipCreator():
	return OpenMayaMPx.asMPxPtr( moveManip() )
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(TDtrigonometricNode())
示例#55
0
def nodeCreator():
	return OpenMayaMPx.asMPxPtr(wheelNode())
示例#56
0
 def nodeCreator(cls):
     return ommpx.asMPxPtr(cls())
 def makeObj(self):
     return OpenMayaMPx.asMPxPtr(mayaSelectionContext())
示例#58
0
def initializePlugin(obj):
    plugin = ommpx.MFnPlugin( obj , 'matthieuCantat', '1.0', 'Any')
    try:
        plugin.registerNode( dynamicTrs.kPluginNodeTypeName, dynamicTrs.kPluginNodeId, dynamicTrs.nodeCreator, dynamicTrs.nodeInitializer)
    except:
        raise Exception('Failed to register node: {0}'.format(dynamicTrs.kPluginNodeTypeName) )
示例#59
0
def delaunayCreator():
    return OpenMayaMPx.asMPxPtr( delaunay() )
示例#60
0
def nodeCreator():
    return ompx.asMPxPtr(DsRaycast())