Esempio n. 1
0
    def __init__(self):
        ompx.MPxCommand.__init__(self)

        self.logger = logging_util.SporeLogger(__name__)
        self.dag_mod_instancer = om.MDagModifier()
        self.dag_mod_spore = om.MDagModifier()
        self.dag_mod_transform = om.MDagModifier()
        self.spore = om.MObject()
        self.instancer = om.MObject()
        self.target = om.MObject()
        self.source = om.MObjectArray()
        self.name = ''
Esempio n. 2
0
def remove(mo_node, b_force=False):
    
    """
    !@Brief Remove given node

    @type mo_node: OpenMaya.MObject
    @param mo_node: Maya object node.
    @type b_force: bool
    @param b_force: Delete locked node.
    """

    if isinstance(mo_node, OpenMaya.MObject) is False:
        raise TypeError("Argument must be a MObject not {0}".format(type(mo_node)))

    if mo_node.hasFn(OpenMaya.MFn.kDagNode) is False and mo_node.hasFn(OpenMaya.MFn.kDependencyNode) is False:
        raise TypeError("Object must be a DagNode or DependencyNode not {0}".format(mo_node.apyTypeStr()))

    moh_node = OpenMaya.MObjectHandle(mo_node)
    if mo_node.isNull() or not moh_node.isValid() or not moh_node.isAlive():
        cmds.debug('Node given does not exists !')
        return

    mfn_node = OpenMaya.MFnDependencyNode(mo_node)
    if mfn_node.isLocked() and b_force is False:
        raise TypeError('Node "{0}" is locked. Set b_force to True for remove it'.format(name(mo_node)))

    if b_force:
        mfn_node.setLocked(False)

    mdg_mod = OpenMaya.MDagModifier() if mo_node.hasFn(OpenMaya.MFn.kDagNode) else OpenMaya.MDGModifier()
    mdg_mod.deleteNode(mo_node)
    mdg_mod.doIt()
    del mdg_mod
Esempio n. 3
0
    def doIt(self, pArguments):
        ''' Command Execution. '''

        # Parse the passed arguments.
        self.parseArgs(pArguments)

        # Create an instance of an MDagModifier to keep track of the created objects,
        # and to undo their creation in our undoIt() function.
        self.dagModifier = OpenMaya.MDagModifier()

        # Create the joint MObjects we will be manipulating.
        self.jointObjects = []
        for i in range(0, self.length):
            if i == 0:
                # The first joint has no parent.
                newJointObj = self.dagModifier.createNode('joint')
            else:
                # Assign the new joint as a child to the previous joint.
                newJointObj = self.dagModifier.createNode(
                    'joint', self.jointObjects[i - 1])
            # Keep track of all the joints created.
            self.jointObjects.append(newJointObj)

        # Create the inverse kinematic effector MObject. The effector is a child of the last joint object.
        # The [-1] index is a Python-specific way of referring to the last item in a list.
        self.effectorObj = self.dagModifier.createNode('ikEffector',
                                                       self.jointObjects[-1])

        # Invoke the command's redoIt() function to actually create and manipulate these objects.
        self.redoIt()
Esempio n. 4
0
def SwitchFromReferenceToAss2(refFile, assFile):
    refedNodes = GetReferenceNodes(refFile)
    it = om.MItSelectionList(refedNodes)
    item = om.MDagPath()
    it.getDagPath(item)

    (t, r, s) = GetDagTransform(item)
   
    print 'remove reference ', refFile
    om.MFileIO.removeReference(refFile)
    
    print 'standin ', assFile
    mod = om.MDagModifier()
    
    standin = mod.createNode('aiStandIn')
    mod.doIt()

    path = om.MDagPath.getAPathTo(standin)

    SetTransform(path, t, r, s)
    
    path.extendToShape()
    fstandin = om.MFnDependencyNode(path.node())
    
    print 'created ', fstandin.name()
    print 'set ', fstandin.findPlug('dso').name()
    
    c = 'setAttr  -type "string" "'+ fstandin.findPlug('dso').name() +'" "'+assFile+'"'
    om.MGlobal.executeCommand(c)
    return True
Esempio n. 5
0
    def __init__(self):
        OMMPx.MPxCommand.__init__(self)
        self.__isQueryUsed = True  # initialize to True so command is not added to queue if argument parsing fails
        self.__isEditUsed = False

        self.__ribbonNodeFn = OM.MFnDependencyNode(
        )  # the am_ribbon node selected for edit and query modes

        self.__selectedCurves = OM.MSelectionList(
        )  # selection list containing only nurbs curves in the object list

        self.__baseNameArg = ''  # base name for the newly created ribbon meshes
        self.__widthArg = None  # width of the ribbon in centimeters
        self.__divisionsArg = None  # divisions along the ribbon
        self.__divisionsPerUnitArg = None  # optional parameter to specify a rate of divisions to get similar-sized faces when multiple curves are selected
        self.__taperArg = None  # scale at the end of the ribbon
        self.__twistBaseArg = None  # rotation around the curve at the start of the ribbon
        self.__twistLengthArg = None  # rotation around the curve at the end of the ribbon
        self.__upVectorArg = None  # base up-vector at the start of the ribbon
        self.__uvScaleArg = None  # scale factor of new uvs
        self.__uvScaleGroupArg = None  # scaling method to apply to the whole group of newly-created ribbons--only in create mode
        self.__uvPinArg = None  # uv pinning location

        self.__dagModify = OM.MDagModifier(
        )  # Dag modifier used to create new shapes/transforms
        self.__dgModify = OM.MDGModifier(
        )  # DG modifier used to create and modify new ribbon nodes
Esempio n. 6
0
 def undoIt(self):
     print 'undo'
     MDagMod = OpenMaya.MDagModifier()
     #need to delete parent Node
     mDagNode = OpenMaya.MFnDagNode(self.mObj_particle)
     MDagMod.deleteNode(mDagNode.parent(0))
     MDagMod.doIt()
     return
Esempio n. 7
0
def LoaderAddObject(arg):
    p = cmds.textScrollList('packages', query=True, selectItem=True)
    s = cmds.textScrollList('metascripts', query=True, selectItem=True)

    print "Loading script:", s[0], "from package:", p[0]
    d = PyClient.assetmanagercommon.runMetaScript(p[0], s[0])

    pathFilename = PyClient.assetmanagercommon.appendPathToAssetsIn(
        d['t']['mayaRep']).replace('\\', '/')
    mFileIO = OpenMaya.MFileIO()

    print mFileIO.importFile(pathFilename, None, 0, "PEObject0")
    lastTransformAdded = None
    maxId = -1
    lastPath = None
    itDag = OpenMaya.MItDag(OpenMaya.MItDag.kDepthFirst,
                            OpenMaya.MFn.kTransform)
    while not itDag.isDone():
        path = OpenMaya.MDagPath()
        itDag.getPath(path)
        fnTransform = OpenMaya.MFnTransform(path.node())
        name = fnTransform.partialPathName()
        if name.startswith("PEObject"):
            id = int(name[len('PEObject'):name.find(':')])
            print "PEObject Detected: ", name, 'ID:', id
            if id > maxId:
                maxId = id
                lastTransformAdded = fnTransform
                lastPath = path

        itDag.next()
    if maxId == -1 or not lastTransformAdded:
        print "Error: Could not find PEObject that was added last"
        return
    print "Adding notes to the last transform"
    dagModifier = OpenMaya.MDagModifier()
    print dagModifier
    #notes = dagModifier.createNode('notes')
    if cmds.objExists(name):
        print "Dbg: Object exists. Adding attribute metaScript"
        cmds.select(name)
        cmds.addAttr(shortName='metaScript', dt='string')
        cmds.setAttr('%s.%s' % (name, 'metaScript'),
                     d['t']['callerScript'],
                     type='string')
        script = cmds.getAttr('%s.%s' % (name, 'metaScript'))
        print repr(script)

        cmds.addAttr(shortName='peuuidStr', dt='string')
        peuuidStr = peuuid.conv.regisrtyTo4UInt32()
        if peuuidStr.endswith(','):
            peuuidStr = peuuidStr[:-1]
        cmds.setAttr('%s.%s' % (name, 'peuuidStr'), peuuidStr, type='string')
        peuuidStr = cmds.getAttr('%s.%s' % (name, 'peuuidStr'))
        print repr(peuuidStr)
    else:
        print "Error: object %s does not exist" % name
Esempio n. 8
0
    def __init__(self):
        super(SplitShape, self).__init__()

        self.baseGeo = None
        self.targetGeo = None
        self.numOfDivision = 2
        self.dgMod = OpenMaya.MDGModifier()
        self.dagMod = OpenMaya.MDagModifier()
        self.createdNodes = OpenMaya.MObjectArray()
Esempio n. 9
0
 def undoIt(self):
     print 'undo'
     # we have the particle but not the transform node in mFnDagNode
     mFnDagNode = OpenMaya.MFnDagNode(self.mObj_particle)
     # so we create an object to delete the particle system
     mDagMod = OpenMaya.MDagModifier()
     # and use the .parent fn to find the transform node
     mDagMod.deleteNode(mFnDagNode.parent(0))
     mDagMod.doIt()
Esempio n. 10
0
 def __init__(self):
     OMMPx.MPxCommand.__init__(self)
     self.__selection = OM.MSelectionList()
     self.__prefix = ''
     self.__suffix = '_xForm'
     self.__scale = OM.MVector(1.0, 1.0, 1.0)
     self.__pickedObjects = OM.MDagPathArray()  # all valid transform nodes in the selection
     self.__newLocators = OM.MDagPathArray()  # any new locators created by the command
     self.__dagModify = OM.MDagModifier()  # modifier to create and modify the new nodes
Esempio n. 11
0
    def redoIt(self):
        # clear out the modifier and arrays so they don't store old object names
        self.__oldTransformationMatrices = []
        self.__newLocators = OM.MDagPathArray()
        self.__pickedObjects = OM.MDagPathArray()
        self.__dagModify = OM.MDagModifier()

        # iterate through the list of selected transform nodes and create a locator for each one
        iter = OM.MItSelectionList(self.__selection, OM.MFn.kTransform)
        # containers for use inside the iterator
        currentObject = OM.MObject()
        currentObjectFn = OM.MFnDagNode()
        currentDagPath = OM.MDagPath()
        currentPlug = OM.MPlug()
        currentParent = OM.MObject()
        currentObjectFn = OM.MFnTransform()
        newLocator = OM.MObject()
        newLocFn = OM.MFnTransform()
        newLocatorPath = OM.MDagPath()
        while not iter.isDone():
            # append the current object to the array of picked objects
            iter.getDagPath(currentDagPath)
            self.__pickedObjects.append(currentDagPath)
            # create the new locator
            newLocator = self.__dagModify.createNode('locator')
            # insert the locator sibling to the object
            currentObjectFn.setObject(currentDagPath)
            currentParent = currentObjectFn.parent(0)
            self.__dagModify.reparentNode(newLocator, currentParent)
            # move the new locator to the same location as its corresponding object, parent, and name appropriately
            newLocFn.setObject(newLocator)
            newLocFn.set(currentObjectFn.transformation())  # align the new locator to the object
            self.__dagModify.reparentNode(currentDagPath.node(),
                                          newLocator)  # the object is now a child of the new locator
            currentObjectFn.set(OM.MTransformationMatrix())  # set the object's local matrix to identity
            self.__dagModify.renameNode(newLocator, self.__prefix + currentObjectFn.partialPathName() + self.__suffix)
            # append the new locator to the array
            newLocFn.getPath(newLocatorPath)
            self.__newLocators.append(newLocatorPath)
            iter.next()
        # WARNING: must tell the MDagModifier to doIt() now in order to let Maya's auto-rename kick in and ensure the names are unique
        # otherwise attempts to use setAttr below may end up using some other object
        self.__dagModify.doIt()

        # now set the attributes and reparent the selected objects
        selectionString = ''  # the selection list needs to be formatted for MEL
        for i in range(0, self.__newLocators.length()):
            newLocFn.setObject(self.__newLocators[i])
            selectionString += ' %s' % newLocFn.fullPathName()
            # resize the new locator
            self.__dagModify.commandToExecute('setAttr %s.localScaleX %f' % (newLocFn.fullPathName(), self.__scale.x))
            self.__dagModify.commandToExecute('setAttr %s.localScaleY %f' % (newLocFn.fullPathName(), self.__scale.y))
            self.__dagModify.commandToExecute('setAttr %s.localScaleZ %f' % (newLocFn.fullPathName(), self.__scale.z))

        # select the new locators
        self.__dagModify.commandToExecute('select%s' % selectionString)
        self.__dagModify.doIt()
Esempio n. 12
0
    def undoIt(self):
        print "Undo"
        # we can use DAG_NODE_FUNCTION_SET or Dag Path
        mFnDagNode = openmaya.MFnDagNode(self.mObj_particle)

        mDagMod = openmaya.MDagModifier()
        # delete the transform node
        mDagMod.deleteNode(mFnDagNode.parent(0))
        mDagMod.doIt()
Esempio n. 13
0
	def plugin_loaded(self, pluginName):
		"""Retrieve plugin information from a plugin named ``pluginName``, which is 
		assumed to be loaded.
		Currently the nodetypes found are added to the node-type tree to make them available.
		The plugin author is free to add specialized types to the tree afterwards, overwriting 
		the default ones.
		
		We loosely determine the inheritance by differentiating them into types suggested
		by MFn::kPlugin<Name>Node"""
		import base		# needs late import, TODO: reorganize modules
		
		self.log.debug("plugin '%s' loaded" % pluginName)
		
		type_names = cmds.pluginInfo(pluginName, q=1, dependNode=1) or list()
		self[pluginName] = type_names
		
		# register types in the system if possible
		dgmod = api.MDGModifier()
		dagmod = api.MDagModifier()
		transobj = None
		
		nt = globals()
		for tn in type_names:
			tnc = capitalize(tn)
			if tnc in nt:
				self.log.debug("Skipped type %s as it did already exist in module" % tnc)
				continue
			# END skip existing node types ( probably user created )
			
			# get the type id- first try depend node, then dag node. Never actually
			# create the nodes in the scene, created MObjects will be discarded
			# once the modifiers go out of scope
			apitype = None
			try:
				apitype = dgmod.createNode(tn).apiType()
			except RuntimeError:
				try:
					# most plugin dag nodes require a transform to be created
					# We create a dummy for the dagmod, otherwise it would create
					# it for us and return the parent transform instead, which 
					# has no child officially yet as its not part of the dag
					# ( so we cannot query the child from there ).
					if transobj is None:
						transobj = dagmod.createNode("transform")
					# END assure we have parent 
					
					apitype = dagmod.createNode(tn, transobj).apiType()
				except RuntimeError:
					self.log.error("Failed to retrieve apitype of node type %s - skipped" % tnc)
					continue
				# END dag exception handling
			# END dg exception handling 
			
			parentclsname = base._plugin_type_to_node_type_name.get(apitype, 'Unknown')
			typ._addCustomType( nt, parentclsname, tnc, force_creation=True )
Esempio n. 14
0
    def rayCallback(*args):
        callbackType, callbackPlug, _, thisNode = args
        dependNode = om.MFnDependencyNode(thisNode.thisMObject())
        debugPlug = dependNode.findPlug("debugRay", False)

        if callbackPlug != debugPlug:
            return

        if debugPlug.asBool():
            dgMod = om.MDagModifier()
            drawVector = dgMod.createNode("drawVector")
            dgMod.doIt()

            sourcePlug = dependNode.findPlug("sourcePoint", False)
            aimPlug = dependNode.findPlug("hitPoint", False)
            messagePlug = dependNode.findPlug('message', False)

            drawVectorTrnDag = om.MFnDagNode(drawVector)
            drawVectorTrnDag.setLocked(True)
            drawVectorDepend = om.MFnDependencyNode(drawVectorTrnDag.child(0))
            sourceDestPlug = drawVectorDepend.findPlug("sourcePoint", False)
            aimDestPlug = drawVectorDepend.findPlug("aimPoint", False)
            messageDestPlug = drawVectorDepend.findPlug("drawMessage", False)

            dgMod = om.MDGModifier()
            dgMod.connect(sourcePlug, sourceDestPlug)
            dgMod.connect(aimPlug, aimDestPlug)
            dgMod.connect(messagePlug, messageDestPlug)
            dgMod.doIt()

        else:
            #Delete draw vector node connected through message
            sourcePlug = dependNode.findPlug("message", False)
            plugArray = om.MPlugArray()
            sourcePlug.connectedTo(plugArray, False, True)
            drawVectorTrn = om.MFnDagNode(plugArray[0].node()).parent(0)
            drawVectorTrnDag = om.MFnDagNode(drawVectorTrn)
            drawVectorTrnDag.setLocked(0)

            dgMod = om.MDagModifier()
            dgMod.deleteNode(drawVectorTrn)
            dgMod.doIt()
Esempio n. 15
0
def _createTmpNode(nodetype):
    """Return tuple(mobject, modifier) for the nodetype or raise RuntimeError
	doIt has not yet been called on the modifier, hence the mobject is temporary"""
    try:
        mod = api.MDGModifier()
        obj = mod.createNode(nodetype)
        return (obj, mod)
    except RuntimeError:
        mod = api.MDagModifier()
        tmpparent = mod.createNode("transform")
        obj = mod.createNode(nodetype, tmpparent)
        return (obj, mod)
Esempio n. 16
0
    def __init__(self, **kwargs):
        """Constructor.

        Parameters
        ----------
        kwargs
            Keyword arguments to define additional attributes.
        """
        self.dg = OpenMaya.MDGModifier()
        self.dag = OpenMaya.MDagModifier()
        self.transforms = []
        self.__dict__.update(kwargs)
Esempio n. 17
0
    def rename(self, new_name, force=False):

        if self.dependency_node.isLocked() and force:
            self.dependency_node.setLocked(False)
            try:
                dagMod = om.MDagModifier()
                dagMod.renameNode(self.mobject, new_name)
                dagMod.doIt()

            finally:
                self.dependency_node.setLocked(True)
        else:
            cmds.rename(self.name, new_name)
Esempio n. 18
0
def getAllExtraAttributes(obj):
    m_result = []
    m_obj = get_mObject(obj)
    m_workMFnDep = OpenMaya.MFnDependencyNode()
    m_workMDagMod = OpenMaya.MDagModifier()
    m_objFn = OpenMaya.MFnDependencyNode()
    m_objFn.setObject(m_obj)  # get function set from MObject
    m_objRef = m_workMFnDep.create(
        m_objFn.typeName())  # Create reference MObject of the given type
    # -- get the list --
    m_result = getAttrListDifference(m_obj, m_objRef)
    # --
    m_workMDagMod.deleteNode(m_objRef)  # set node to delete
    m_workMDagMod.doIt()  # execute delete operation
    return m_result
Esempio n. 19
0
def __processUpstreamNode(data, meshDagPath, dgModifier):

    if __hasHistory(meshDagPath):
        # Just swap the connections around
        tempPlugArray = OpenMaya.MPlugArray()
        data.meshNodeDestPlug.connectedTo(tempPlugArray, True, False)
        assert (tempPlugArray.length() == 1)

        data.upstreamNodeSrcPlug = OpenMaya.MPlug(tempPlugArray[0])

        data.upstreamNodeShape = data.upstreamNodeSrcPlug.node()

        data.upstreamNodeSrcAttr = data.upstreamNodeSrcPlug.attribute()

        dgModifier.disconnect(data.upstreamNodeSrcPlug, data.meshNodeDestPlug)
        dgModifier.doIt()

    else:
        # Duplicate mesh, mark as "intermediate", and reconnect in the DAG
        dagNodeFn = OpenMaya.MFnDagNode(data.meshNodeShape)
        meshNodeShapeName = dagNodeFn.name()

        data.upstreamNodeTransform = dagNodeFn.duplicate(False, False)
        dagNodeFn.setObject(data.upstreamNodeTransform)

        fDagModifier = OpenMaya.MDagModifier()

        if dagNodeFn.childCount() < 1:
            raise RuntimeError("Duplicated mesh has no shape")

        data.upstreamNodeShape = dagNodeFn.child(0)

        fDagModifier.reparentNode(data.upstreamNodeShape,
                                  data.meshNodeTransform)
        fDagModifier.renameNode(data.upstreamNodeShape,
                                meshNodeShapeName + "Orig")
        fDagModifier.doIt()

        dagNodeFn.setObject(data.upstreamNodeShape)
        dagNodeFn.setIntermediateObject(True)

        data.upstreamNodeSrcAttr = dagNodeFn.attribute("outMesh")
        data.upstreamNodeSrcPlug = dagNodeFn.findPlug("outMesh")

        fDagModifier.deleteNode(data.upstreamNodeTransform)
        fDagModifier.doIt()
Esempio n. 20
0
def connect_to_instancer(transform_node, spore_node):
    """ connect a transform's matrix attribute to a instancer node
    that is connected to the given spore node """

    # get instancer's inputHierarchy plug
    instancer_node = get_instancer(spore_node, False)
    dg_fn = om.MFnDependencyNode(instancer_node)
    in_plug = dg_fn.findPlug('inputHierarchy')

    # get transform's matrix plug
    transform_node = get_mobject_from_name(transform_node)
    dag_fn = om.MFnDagNode(transform_node)
    matrix_plug = dag_fn.findPlug('matrix')

    # get first free plug and connect
    plug_id = in_plug.numElements() + 1
    dag_mod = om.MDagModifier()
    dag_mod.connect(matrix_plug, in_plug.elementByLogicalIndex(plug_id))
    dag_mod.doIt()
Esempio n. 21
0
    def __init__(self):
        OpenMayaMPx.MPxCommand.__init__(self)

        # Asignando un nombre unico a la instancia
        self.instanceName = commandName + str(Plug1Command.instanceId)
        Plug1Command.instanceId += 1

        # Instanciando variables al sistema de particulas
        self.particleSystemName = self.instanceName + '_Particles'
        self.numParticles = Plug1Command.default_numParticles
        self.particlesPositions = OpenMaya.MPointArray()

        # Instanciando variables al campo de turbulencia
        self.turbulenceFieldName = self.instanceName + '_Turbulence'
        self.size_x = Plug1Command.default_dimmensions[0]
        self.size_y = Plug1Command.default_dimmensions[1]
        self.size_z = Plug1Command.default_dimmensions[2]

        self.dagModifier = OpenMaya.MDagModifier()
Esempio n. 22
0
def get_dynamic_attributes(mObject):
    """ return all dynamic attributes of a node """

    result = []

    mFnDep = om.MFnDependencyNode()
    objFn = om.MFnDependencyNode(mObject)
    refObj = mFnDep.create(objFn.typeName())
    refFn = om.MFnDependencyNode(refObj)

    if (objFn.attributeCount() > refFn.attributeCount()):
        for i in range(refFn.attributeCount(), objFn.attributeCount()):
            attr = objFn.attribute(i)
            attrFn = om.MFnAttribute(attr)
            result.append(attrFn.name())

    mDagMod = om.MDagModifier()
    mDagMod.deleteNode(refObj)

    return result
    def __init__(self):
        #constructor
        OpenMayaMPx.MPxCommand.__init__(self)
        #give a unique name to this command instance.
        self.instancename = cmd + str(
            swarm_cmd.instanceid)  #if more tha one exist!!
        swarm_cmd.instanceid += 1
        #particle system instance variables
        self.particle_system_name = self.instancename + '_Particles'
        self.numParticles = 50
        self.particlePositions = OpenMaya.MPointArray()

        #turbulence field instance variables
        self.tur_field_name = self.instancename + '_Turbulence'
        self.size_x = 5
        self.size_y = 5
        self.size_z = 5

        self.dagModifier = OpenMaya.MDagModifier()
        self.volShapeNum = 1  #TEST!
Esempio n. 24
0
    def __init__(self):
        ''' Constructor. '''
        OpenMayaMPx.MPxCommand.__init__(self)

        # Give a unique name to this command instance.
        self.instanceName = commandName + str(SwarmCommand.instanceId)
        SwarmCommand.instanceId += 1

        # Particle system instance variables
        self.particleSystemName = self.instanceName + '_Particles'
        self.numParticles = SwarmCommand.default_numParticles
        self.particlePositions = OpenMaya.MPointArray()

        # Turbulence field instance variables
        self.turbulenceFieldName = self.instanceName + '_Turbulence'
        self.size_x = SwarmCommand.default_dimensions[0]
        self.size_y = SwarmCommand.default_dimensions[1]
        self.size_z = SwarmCommand.default_dimensions[2]

        self.dagModifier = OpenMaya.MDagModifier()
Esempio n. 25
0
    def doIt(self, args):
        ''' doIt() is called once when the command is first executed. '''

        # This MDagModifier object will allow us to undo and redo the creation
        # of DAG nodes in our command.
        self.dagModifier = OpenMaya.MDagModifier()

        # Create the camera transform node.
        self.cameraTransformObj = self.dagModifier.createNode('transform')
        self.dagModifier.renameNode(self.cameraTransformObj,
                                    'myCameraTransform')

        # Create the camera shape node as a child of the camera transform node.
        self.cameraShapeObj = self.dagModifier.createNode(
            'camera', self.cameraTransformObj)
        self.dagModifier.renameNode(self.cameraShapeObj, 'myCameraShape')

        # Call self.redoIt() to perform the command's actual work. This function call flow
        # is useful for code re-use.
        self.redoIt()
Esempio n. 26
0
    def __init__(self):
        super(polyModifierCmd, self).__init__()

        # polymesh
        self._fDagPathInitialized = False
        self._fDagPath = om.MDagPath()
        self._fDuplicateDagPath = om.MDagPath()

        # modifier node type
        self._fModifierNodeTypeInitialized = False
        self._fModifierNodeNameInitialized = False
        self._fModifierNodeType = om.MTypeId()
        self._fModifierNodeName = ""

        # node state

        self._fHasHistory = False
        self._fHasTweaks = False
        self._fHasRecordHistory = False

        # cached tweak data

        self._fTweakIndexArray = om.MIntArray()
        self._fTweakVectorArray = om.MFloatVectorArray()

        # cached mesh data

        self._fMeshData = om.MObject()

        # dg and dag modifier

        self._fDGModifier = om.MDGModifier()
        self._fDagModifier = om.MDagModifier()

        # manual shape management
        self._manual_redo_queue = []

        numDataFn = om.MFnNumericData()
        numDataFn.create(om.MFnNumericData.k3Float)
        numDataFn.setData3Float(0.0, 0.0, 0.0)
        self.__class__.NULL_VECTOR = numDataFn.object()
Esempio n. 27
0
    def __init__(self):
        OpenMayaMPx.MPxCommand.__init__(self)

        # Asignando un nombre unico a la instancia
        self.instanceName = commandName + str(Waterfall.instanceId)
        Waterfall.instanceId += 1

        # Nombres de sistema de particulas de gotas, espuma y agua
        self.dewSystemName = self.instanceName + '_Dew'
        self.spumeSystemName = self.instanceName + '_Spume'
        self.waterSystemName = self.instanceName + '_water'

        self.dewSystemShapeName = self.dewSystemName + 'Shape'
        self.spumeSystemShapeName = self.spumeSystemName + 'Shape'
        self.waterSystemShapeName = self.waterSystemName + 'Shape'

        # Nombres de emisores de particulas de gotas, espuma y agua
        self.dewEmitterName = self.instanceName + '_DewEmiter'
        self.spumeEmitterName = self.instanceName + '_SpumeEmiter'
        self.waterEmitterName = self.instanceName + '_WaterEmiter'

        # Campos de fuerzas
        self.gravityName = self.instanceName + '_Gravity'
        self.turbulenceLowName = self.instanceName + '_TurbulenceLow'
        self.turbulenceHighName = self.instanceName + '_TurbulenceHigh'

        # Values
        self.numTurbulence = Waterfall.default_numTurbulence
        self.dewRate = Waterfall.default_dewRate
        self.spumeRate = Waterfall.default_spumeRate
        self.waterRate = Waterfall.default_waterRate
        self.floor = Waterfall.default_floor
        self.turbulenceLow = Waterfall.default_turbulence_low
        self.turbulenceHigh = Waterfall.default_turbulence_high
        self.gravity = Waterfall.default_gravity

        # Control
        self.controllerName = self.instanceName + '_Control'

        self.dagModifier = OpenMaya.MDagModifier()
Esempio n. 28
0
    def __init__(self):
        super(polyModifierCmd, self).__init__()

        # polymesh
        self._fDagPathInitialized = False
        self._fDagPath = om.MDagPath()
        self._fDuplicateDagPath = om.MDagPath()

        # modifier node type
        self._fModifierNodeTypeInitialized = False
        self._fModifierNodeNameInitialized = False
        self._fModifierNodeType = om.MTypeId()
        self._fModifierNodeName = ""

        # node state

        self._fHasHistory = False
        self._fHasTweaks = False
        self._fHasRecordHistory = False

        # cached tweak data

        self._fTweakIndexArray = om.MIntArray()
        self._fTweakVectorArray = om.MFloatVectorArray()

        # cached mesh data

        self._fMeshData = om.MObject()

        # dg and dag modifier

        self._fDGModifier = om.MDGModifier()
        self._fDagModifier = om.MDagModifier()

        # manual shape management
        self._manual_redo_queue = []
Esempio n. 29
0
    def redoIt(self):

        print "redoIt()"
        self.dagModifier = OpenMaya.MDagModifier()
        selectionList = OpenMaya.MSelectionList()
        OpenMaya.MGlobal.getActiveSelectionList(selectionList)
        dagPath = OpenMaya.MDagPath()
        selectionList.getDagPath(0, dagPath)
        m = MayaMesh(dag=dagPath,
                     vertices=1,
                     faces=1,
                     edges=1,
                     normals=1,
                     build=1)

        edgeIt = OpenMaya.MItMeshEdge(dagPath)
        selection = []

        while not edgeIt.isDone():
            if selectionList.hasItem(dagPath, edgeIt.currentItem()):
                selection += [edgeIt.index()]
            edgeIt.next()
        m.selectionType = kGeotype.edge
        m.flowLoop(selection)
Esempio n. 30
0
 def __init__(self):
     ompx.MPxCommand.__init__(self)
     self.__fDGMod = om.MDGModifier()
     self.__dagMod = om.MDagModifier()
     self.__dagFn = om.MFnDagNode()
     self.__dpFn = om.MFnDependencyNode()