Exemple #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
Exemple #2
0
    def nodeCreator(cls):

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

        return OpenMayaMPx.asMPxPtr(cls())
Exemple #3
0
def cmdCreator():
    # Create the command
    """
    
    Return:
        pointer to the command
    
    """
    ptr = OpenMayaMPx.asMPxPtr(SamplePyCmd())
    return ptr
	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
Exemple #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
Exemple #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
	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)
Exemple #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() )
Exemple #10
0
 def nodeCreator(cls):
     return OpenMayaMPx.asMPxPtr(cls())
def nodeCreator():
	return OpenMayaMPx.asMPxPtr( vertSnapDeformer() )
Exemple #12
0
def creator():
    return OpenMayaMPx.asMPxPtr(gear_curveCns())
Exemple #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 )
Exemple #14
0
		return OpenMayaMPx.asMPxPtr( moveManipContext() )
Exemple #15
0
 def nodeCreator(cls):
     return OpenMayaMPx.asMPxPtr(cls())
Exemple #16
0
def nodeCreator():
    '''creator
    '''
    return OpenMayaMPx.asMPxPtr(oyTrajectoryDrawer())
Exemple #17
0
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(CVG())
def nodeCreator():
    return ompx.asMPxPtr(ParentConstraint())
def cmdCreator():

    return ompx.asMPxPtr(ParentConstraintCmd())
Exemple #20
0
def uninitializePlugin(obj):
    fnPlugin = OpenMayaMpx.MFnPlugin(obj)
    fnPlugin.deregisterNode(varfkNode.kPluginNodeId)
Exemple #21
0
def initializePlugin(obj):
    fnPlugin = OpenMayaMpx.MFnPlugin(obj, 'Bogdan Diaconu', '1.0', 'Any')
    fnPlugin.registerNode('varfkNode', varfkNode.kPluginNodeId, creator,
                          initialize)
Exemple #22
0
def creator():
    return OpenMayaMpx.asMPxPtr(varfkNode())
def nodeCreator():
	# TODO change this node name
	return OpenMayaMPx.asMPxPtr(nodeName)
Exemple #24
0
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterNode( nodeID )
    except:
        sys.stderr.write( "Failed to unregister command: %s\n" % nodeName )
Exemple #25
0
def creator():
    return OpenMayaMPx.asMPxPtr( gear_percentageToU() )
Exemple #26
0
 def nodeCreator(cls):
     print('nodeCreator')
     return ommpx.asMPxPtr(cls())
def cmdCreator():
    return OpenMayaMPx.asMPxPtr( scriptedCommand() )
Exemple #28
0
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(ehm_pushDeformer())
def contextCmdCreator():
    """Wrapper function that created the command"""
    return OpenMayaMPx.asMPxPtr(mayaSelctionCtxCmd())
Exemple #30
0
def uninitializePlugin(mobject):
	mplugin = omMPx.MFnPlugin(mobject)
	try:
		mplugin.deregisterNode( stickyDeformerId )
	except:
		sys.stderr.write( "Failed to unregister node: %s\n" % kPluginNodeTypeName )
Exemple #31
0
def cmdCreator():
    return ompx.asMPxPtr(selPoles())
Exemple #32
0
def nodeCreator():
	return omMPx.asMPxPtr( stickyDeformer() )
def nodeCreator():
	return OpenMayaMPx.asMPxPtr( sceneMsgCmd() )
Exemple #34
0
 def commandCreator():
     return OpenMayaMPx.asMPxPtr(createCameraFrustum())
Exemple #35
0
def normalizeCreator():
    return OpenMayaMPx.asMPxPtr( normalize() )
def nodeCreator():
	return  OpenMayaMPx.asMPxPtr(jiggleNode())
def locatorManipCreator():
    return OpenMayaMPx.asMPxPtr(swissArmyLocatorManip())
Exemple #38
0
def uninitializePlugin(mObj):
    plugin = OpenMayaMPx.MFnPlugin(mObj)
    try:
        plugin.deregisterNode(nodeId)
    except:
        sys.stderr.write('Faild to unload plugin: %s' % nodeName)
 def create(cls):
     return mpx.asMPxPtr( cls() )    
Exemple #40
0
 def cmdCreator():
     return OpenMayaMPx.asMPxPtr(WhatIsCmd())
Exemple #41
0
def nodeCreator():
	return OpenMayaMPx.asMPxPtr(stretchSplineSolver())
def nodeCreatorLSystem():
    return OpenMayaMPx.asMPxPtr( LSystemInstanceNode() )
def ms_environment_nodeCreator():
    return OpenMayaMPx.asMPxPtr(ms_environment())
def nodeCreatorRandom():
    return OpenMayaMPx.asMPxPtr( randomNode() )
def cmdCreator():
    return OpenMayaMPx.asMPxPtr(InheritParentsName())
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 )
def creator():
    return OpenMayaMPx.asMPxPtr(cvShapeInverter())
Exemple #48
0
def helixManipCreator():
    #print "helixManip: helixManipCreator called"
    return OpenMayaMPx.asMPxPtr(helixManip())
Exemple #49
0
 def create():
     return OpenMayaMPx.asMPxPtr(Ik2bCGA())
Exemple #50
0
def cmdCreator():
    return OpenMayaMPx.asMPxPtr( scriptedCommand() )
Exemple #51
0
		OpenMayaMPx.MPxContextCommand.__init__(self)
Exemple #52
0
def uninitializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.deregisterCommand( kPluginCmdName )
    except:
        sys.stderr.write( "Failed to unregister command: %s\n" % kPluginCmdName )
Exemple #53
0
def moveManipCreator():
	return OpenMayaMPx.asMPxPtr( moveManip() )
def nodeCreator():
    return OpenMayaMPx.asMPxPtr(TDtrigonometricNode())
Exemple #55
0
def nodeCreator():
	return OpenMayaMPx.asMPxPtr(wheelNode())
Exemple #56
0
 def nodeCreator(cls):
     return ommpx.asMPxPtr(cls())
 def makeObj(self):
     return OpenMayaMPx.asMPxPtr(mayaSelectionContext())
Exemple #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) )
Exemple #59
0
def delaunayCreator():
    return OpenMayaMPx.asMPxPtr( delaunay() )
Exemple #60
0
def nodeCreator():
    return ompx.asMPxPtr(DsRaycast())