コード例 #1
0
    def _createCurves(self, objs=None, axis=None, num=None):
        '''
        Create two curves using .getTranslation() of passed in objects
        '''
        _name = '_createCurves'
        pymelLogger.info('Started: %s' % _name)
        
        positions = []
        for obj in objs:
            loc = pm.spaceLocator()
            pm.parentConstraint(obj, loc, mo=0)
            positions.append(pm.PyNode(loc).getTranslation())
            pm.delete(loc)
        crv1 = pm.PyNode(pm.curve(p=positions, d=1))
        crv2 = pm.PyNode(pm.curve(p=positions, d=1))
        
        move = 0.05
        if axis == 1:
            pm.move(crv1, move, r=1, moveX=1)
            pm.move(crv2, -move, r=1, moveX=1)
        elif axis == 2:
            pm.move(crv1, move, r=1, moveY=1)
            pm.move(crv2, -move, r=1, moveY=1)
        elif axis == 3:
            pm.move(crv1, move, r=1, moveZ=1)
            pm.move(crv2, -move, r=1, moveZ=1)

        pm.rebuildCurve( crv1, rt=0, s=num )
        pm.rebuildCurve( crv2, rt=0, s=num )
    
        pymelLogger.info('Ended: %s' % _name)       
        return crv1, crv2
コード例 #2
0
ファイル: libGeo.py プロジェクト: mds-dev/mds_repository
 def import_heirachy_geo(self):
     """Import all the obj objects"""
     fileInfo = self.geo_file_info
     for self.current_target in fileInfo.keys():
         cmds.file(fileInfo[self.current_target],
                   rpr="PKD_Temp",
                   i=1,
                   type="OBJ",
                   loadReferenceDepth="all",
                   ra=True,
                   mergeNamespacesOnClash=False,
                   options="mo=1")
         # Delete Existing geo if it exists
         if not self.cleansing_mode:
             if pm.objExists(self.current_target):
                 pm.delete(self.current_target)
         pyLog.info("Importing\n%s" % fileInfo[self.current_target])
         if self.cleansing_mode:
             os.remove(fileInfo[self.current_target])
         for top in pm.ls(assemblies=True, ud=True):
             if top.getShape():
                 if top.getShape().type() == "mesh" and top.name() == "PKD_Temp_Mesh":
                     # pm.parent(top, self.top_node)
                     top.rename(self.current_target)
                     pm.select(self.current_target)
                     mel.eval("polySoftEdge -a 180 -ch 1 %s" % self.current_target)
                     mel.eval("polySetToFaceNormal")
                     mel.eval("polySoftEdge -a 180 -ch 1 %s" % self.current_target)
                     pm.delete(self.current_target, ch=1)
                     pm.refresh()
         self.update_progress()
コード例 #3
0
ファイル: libGeo.py プロジェクト: mds-dev/mds_repository
    def export_heirachy_obj(self):
        """Export the individual meshes in the heirachy"""
        fileInfo = {}
        # Reverse the geo list so that the deepest geo is deleted first in case there is a geo inside geo
        geo_list = self.geo_list
        geo_list.reverse()
        for self.current_target in geo_list:
            pm.delete(self.current_target, ch=1)
            parent = pm.listRelatives(self.current_target, parent=True)
            pm.parent(self.current_target, w=True)
            pm.select(self.current_target)
            path = libFile.linux_path(libFile.join(self.export_dir, self.current_target + ".obj"))
            # Load the obj plugin
            cmds.file(path,
                      pr=1,
                      typ="OBJexport",
                      force=1,
                      options="groups=0;ptgroups=0;materials=0;smoothing=0;normals=0",
                      es=1)
            fileInfo[self.current_target] = path
            pyLog.info("Exporting\n%s" % fileInfo[self.current_target])
            if not self.new_scene and self.cleansing_mode:
                pm.delete(self.current_target)
                pm.refresh()
            else:
                pm.parent(self.current_target, parent)

            self.update_progress()

        # Write the geo file_info
        self.geo_file_info = fileInfo
コード例 #4
0
 def _organize(self):
     '''
     Setup hierarchy for setup
     '''
     _name = '_organize'
     pymelLogger.info('Started: %s' % _name)
     
     
     pymelLogger.info('Ended: %s' % _name)
コード例 #5
0
def change_tangents(tangent):
    """Function to change the default tangent based
    @param tangent (string) the type of default in and out tangent
    """
    pm.keyTangent(g=True, ott=tangent)
    if tangent == "step":
        pm.keyTangent(itt="clamped", g=True)
    else:
        pm.keyTangent(g=True, itt=tangent)
    pyLog.info("Current Tangents: %s" % tangent.capitalize())
コード例 #6
0
ファイル: libGeo.py プロジェクト: mds-dev/mds_repository
def convert_joint_to_cluster(targetGeo, skipList=[]):
    """
    Convert a skin cluster to a cluster based setup on a target geometery
    @param targetGeo: the geometery which has the skin cluster
    @param skipList: any joints which should not processed such as a base joint
    @return A dictonary of cluster with the name of the joints as keys

    """
    # Convert to PyNode
    targetGeo = pm.PyNode(targetGeo)
    skin = libUtilities.get_target_defomer(targetGeo, "skinCluster")

    # Create the dictionary
    clusterInfo = {}
    # Progress Info
    pm.progressWindow(title='Converting Skin To Cluster', progress=0, status='Progress: 0%')
    totalJnts = len(skin.getInfluence()) - len(skipList)
    currentJnt = 0.0

    # Go through Each Joint
    for jnt in sorted(skin.getInfluence()):
        if jnt.name() in skipList:
            continue
        # Get the vertex affected and the weight
        vertZip, weightList = skin.getPointsAffectedByInfluence(jnt)
        if not vertZip:
            raise Exception("Current Joint Has No Vertices:%s" % jnt)
        pm.select(vertZip)

        # Iterate through selection and decompress vertic group  into individual index
        vertices = libUtilities.indexize_vertice_group(pm.selected())
        # Select Vertices
        libUtilities.select_vertices(targetGeo, vertices)
        # Make a cluster
        cltr, cTransform = pm.cluster(rel=1)
        jntPos = pm.xform(jnt, q=1, ws=1, rp=1)
        pm.setAttr(cTransform.scalePivot, jntPos)
        pm.setAttr(cTransform.rotatePivot, jntPos)

        # Set the weight
        for index, weight in zip(vertices, weightList):
            cltr.weightList[0].weights[index].set(weight)

        # Add to dictionary
        clusterInfo[jnt.name()] = {"cluster": cltr, "clusterHandle": cTransform}

        # Update Progress
        currentJnt = currentJnt + 1.0
        currentProgress = (currentJnt / totalJnts) * 100
        pm.progressWindow(edit=True, progress=currentProgress, status=('Progress: ' + str(int(currentProgress)) + '%'))
        pm.refresh()
        pyLog.info("Converted: " + jnt.name())

    pm.progressWindow(endProgress=1)
    return clusterInfo
コード例 #7
0
 def _createPlane(self, name=None, crv1=None, crv2=None):
     '''
     Plane made by lofting two curves
     '''
     _name = '_createPlane'
     pymelLogger.info('Started: %s' % _name)
     
     plane = pm.loft( crv1, crv2, ch=False, rn=True)[0]
     plane.rename('%s_plane' % name)
     
     pymelLogger.info('Ended: %s' % _name)        
     return plane
コード例 #8
0
 def _createJoints(self, name=None, follicles=None, rad=None):
     '''
     Create a joint parented to each follicle
     '''
     _name = '_createJoints'
     pymelLogger.info('Started: %s' % _name)        
     
     count = 1
     for f in follicles:
         j = pm.joint(name='%s_jnt_%s' % (name, count), rad=rad)
         pm.parent(j, f)
         j.setTranslation(0)
         count += 1
         
     pymelLogger.info('Ended: %s' % _name) 
コード例 #9
0
ファイル: _utils_global.py プロジェクト: adamfok/afok_toolset
def PRINT(msg='', item='', type='info'):
    printMsg = '|| %s || %s' %(msg.ljust(65), item.ljust(20))
    
    if type == 'debug':
        pymelLogger.debug('\t\t\t%s'%printMsg)
    elif type == 'info':
        pymelLogger.info('\t\t\t%s'%printMsg)
    elif type == 'warning':
        pymelLogger.warning('\t%s'%printMsg)
    elif type == 'error':
        pymelLogger.error('\t%s'%printMsg)
    elif type == 'critical':
        pymelLogger.critical('\t%s'%printMsg)
    else:
        pymelLogger.error('Cannot Print Message: Invalid Type')
        
    return
コード例 #10
0
ファイル: MDSShotgun.py プロジェクト: mds-dev/mds_repository
def write_yeti_cache(yetiShapeDictionary, substep):
    project = cmds.workspace(q=1, rd=1)
    minRange, maxRange = libUtilities.get_animation_time_range()
    for character in yetiShapeDictionary:
        # Iterate through the yeti node per characte
        for yeti in yetiShapeDictionary[character]:
            cacheLocation = project
            for folder in ["cache", "fur", character, yeti.stripNamespace()]:
                cacheLocation = libFile.join(cacheLocation, folder)

            cacheLocation = libFile.folder_check(cacheLocation)

            # NEED TO CREATE CACHE LOCATION IF DOES NOT EXIST
            cacheName = libFile.linux_path(libFile.join(cacheLocation,
                                                        "%s_Cache_%s.fur" % (yeti.stripNamespace(), "%04d")))

            # Set cache name fields

            yeti.outputCacheFileName.set(cacheName)
            yeti.cacheFileName.set(cacheName)

            # Cache out using time sldier range and given sample count
            pm.select(yeti, r=1)

            # Set the grooms simulation
            # Turn off the all the sims

            for allGroom in pm.ls(type='pgYetiGroom'):
                allGroom.doSimulation.set(False)

            # Turn on the relavent
            if yetiShapeDictionary[character][yeti]:
                pyLog.info("Turning on simulation the following groom during the caching of %s" % (yeti))
            for groom in yetiShapeDictionary[character][yeti]:
                print groom
                groom.doSimulation.set(True)

            yeti.fileMode.set(0)
            cmd = 'pgYetiCommand -updateViewport false -writeCache "%s" -range %i %i -samples %i' \
                  % (cacheName, minRange, maxRange, substep)
            pyLog.info("Setting Fur Cache for: %s" % yeti.name())
            libUtilities.melEval(cmd, echo=True)
            yeti.fileMode.set(2)
コード例 #11
0
    def _createFollicles(self, name=None, plane=None, num=None):
        '''
        Create num follicles evenly spaced along nurbs plane
        '''
        _name = '_createFollicles'
        pymelLogger.info('Started: %s' % _name) 
        
        #--- Create the follicles
        pm.select(clear=True)
        follicles = []
        for i in range(0, num):
            follicles.append( self._create_follicle( obj=plane, name=name, count=i+1, uPos=0.5, vPos=i/(num-1.00)) )
            
        grp = pm.group(n=name+'_rbbnFollicles_grp', em=True)
        for each in follicles:
            pm.parent(pm.listRelatives(each, parent=True)[0], grp)

        pymelLogger.info('Ended: %s' % _name)        
        return follicles    
コード例 #12
0
ファイル: libPySide.py プロジェクト: mds-dev/mds_repository
    def show(self, *args, **kwargs):
        """Create Dockable UI"""

        # Set the docked object name
        dockedName = (self.objectName() + "Dock")
        # Set the default docked object name
        floatingState = self.init_float_state
        if cmds.dockControl(dockedName, q=1, ex=1):
            # If the docked UI exists get the float status before deleting
            floatingState = cmds.dockControl(dockedName, q=1, floating=1)
            # Delete the UI
            cmds.deleteUI(dockedName)
        try:
            self._dockedwidget_ = cmds.dockControl(dockedName, label=self.windowTitle(), allowedArea='all',
                                                   area='right',
                                                   floating=floatingState,
                                                   content=self.objectName(),
                                                   floatChangeCommand=self._auto_resize_
                                                   )
        except Exception, e:
            pyLog.info(str(e))
            pyLog.info("Maya dock window failed")
コード例 #13
0
ファイル: libPySide.py プロジェクト: mds-dev/mds_repository
    def _setup_(self):
        super(TestGUI, self)._setup_()
        pyLog.info("Child Info Called")
        # Create a series of rows, and in each row, put our buttons
        for row in self.rows:

            self.row_Hbox = QtGui.QGroupBox()
            self.layout = QtGui.QGridLayout()

            for button in self.buttons:
                # Label the button with it's list name
                self.push_button = QtGui.QPushButton(button, self)

                # Give each button a unique object name
                self.b_name = row + "_" + button
                self.push_button.setObjectName(self.b_name)

                # Add a QLine Edit to each particular button
                self.q_line_name = self.b_name + "_TextEdit"
                self.my_line_edit = QtGui.QLineEdit()
                self.my_line_edit.setText("Hi! I'm " + self.q_line_name)

                # Also give it a unique name
                self.my_line_edit.setObjectName(self.q_line_name)

                # Offset each button in the layout by it's index number
                self.layout.addWidget(self.push_button, 0, self.buttons.index(button))

                # Offset each QLine Edit in the layout to be underneath each button
                self.layout.addWidget(self.my_line_edit, 1, self.buttons.index(button))

                # Connect the button to an event
                self.push_button.clicked.connect(self.on_button_event)

            # Add the buttons to our layout
            self.row_Hbox.setLayout(self.layout)
            self.main_layout.addWidget(self.row_Hbox)
コード例 #14
0
 def ui(self):
     '''
     Create UI
     '''
     _name = 'ui'
     pymelLogger.info('Started: %s' % _name)
     
     winName = 'ms_jointsOnNurbsPlaneWin'
     if(pm.window(winName, exists=True)):
         pm.deleteUI(winName, window=True)
     win = pm.window(winName)
     
     with pm.formLayout() as form:
         self.nameFld = pm.textFieldGrp(l='Name')
         self.numFld = pm.intFieldGrp(l='Joints (3-50)', v1=3)
         self.radFld = pm.floatFieldGrp(l='Radius (0.01 - 10)', v1=0.5, pre=2)
         self.buildFld = pm.radioButtonGrp(l='Plane Curve Duplicate', labelArray3=['x', 'y', 'z'], nrb=3, sl=3)
         pm.text('Select objects to create plane along, then press "Build"')
         pm.button(l='>> Build <<', c=self.build)
         
     form.redistribute()
     
     pm.showWindow()
     pymelLogger.info('Ended: %s' % _name)
コード例 #15
0
    def build(self, *args):
        '''
        Call methods to build the joints on nurbs plane setup
        '''
        _name = 'build'
        pymelLogger.info('Started: %s' % _name)
        
        # Validate user input
        name = pm.textFieldGrp(self.nameFld, q=1, text=1)
        num = pm.intFieldGrp(self.numFld, q=1, v=1)[0]
        rad = pm.floatFieldGrp(self.radFld, q=1, v=1)[0]
        axis = pm.radioButtonGrp(self.buildFld, q=1, sl=1)
        objs = pm.ls(sl=1)
        
        if not name:
            pymelLogger.error('No name entered by user. Must enter a name. Exiting.')
            return            
        if num < 1 or num > 50:
            pymelLogger.error('%s is an invalid value for number of joints. Must be between 3 - 50. Exiting.' % num)
            return    
        if rad < 0.009 or rad > 10:
            pymelLogger.error('%s is an invalid value for joint radius. Must be between 0.01 - 10. Exiting.' % rad)
            return    
        if not objs:
            pymelLogger.error('No objects selected. Must select objects to build curve along. Exiting.')
            return

        # Call build methods
        crv1, crv2 = self._createCurves(objs=objs, axis=axis, num=num)
        plane = self._createPlane(name=name, crv1=crv1, crv2=crv2)
        follicles = self._createFollicles(name=name, plane=plane, num=num)
        self._createJoints(name=name, follicles=follicles, rad=rad)
        
        pm.delete(crv1, crv2)

        pymelLogger.info('Ended: %s' % _name)
        pymelLogger.info('Build successful!')
コード例 #16
0

# command wrapper
sphere_nodes = pymel.core.polySphere()
g = pymel.core.group()

# class instance
polySphere_node = pymel.core.nodetypes.PolySphere(n=temp.constants.SPHERE)
trans = polySphere_node.outputs()[0]

trans = pymel.core.nodetypes.Transform()


# Path
filepath = pymel.core.sceneName()
filepath.basename()
filepath.name
filepath.parent
filepath.parent.parent
filepath.exists()


# logging
from pymel.internal.plogging import pymelLogger

pymelLogger.info("test")

from pymel.tools import loggingControl

loggingControl.initMenu()
コード例 #17
0
 def __init__(self):
     _name = '__init__'
     pymelLogger.info('Started: %s' % _name)
     self.ui()
     pymelLogger.info('Ended: %s' % _name)  
コード例 #18
0
ファイル: libGeo.py プロジェクト: mds-dev/mds_repository
 def cleanse_geo(self):
     """Cleanse the model of all issues with the help of obj"""
     self.export_all()
     self.setup_cleanse_scene()
     self.import_all()
     pyLog.info("Scene Is Cleansed")
コード例 #19
0
if isinstance(sphereT, pymel.core.nodetypes.DependNode):
    print "yep, it inherits from DependNode"

# command wrapper
sphere_nodes = pymel.core.polySphere()
g = pymel.core.group()

# class instance
polySphere_node = pymel.core.nodetypes.PolySphere(n=temp.constants.SPHERE)
trans = polySphere_node.outputs()[0]

trans = pymel.core.nodetypes.Transform()

# Path
filepath = pymel.core.sceneName()
filepath.basename()
filepath.name
filepath.parent
filepath.parent.parent
filepath.exists()

# logging
from pymel.internal.plogging import pymelLogger

pymelLogger.info('test')

from pymel.tools import loggingControl

loggingControl.initMenu()