davidcuellar.es
  • Home
  • About
  • Contact

Hi everyone,

It´s been a while since my last post. I’ve been very busy and with some important and great changes lately.

I’m not going to talk about that right now, but in the last months I learned so much and I would like to share some of it. I’m currently developing an application, to help me on the common task of my work.

As you probably know, I work as rigger TD, so one of the main tasks is dealing with the skin. In the application that I’m developing I need to store and apply the skin information on different meshes.

In the beginning, and without thinking so much, I jumped straight away to use the common Maya Python commands. Everything worked fine until I started to use high-density meshes, where, I had the surprise that the process was very slow.

It was taking so much time, making that path unworkable
. So I started to dig a little bit, and I decide to start using Maya API.

It’s a been quite interesting and refreshing start learning about it. I need to say that it is my first experience developing something in the API, but I really enjoyed it. So, after all these words, I would like to share with you the first plug-in that I developed.

I know that there are out there more plug-ins with the same functionality, but my objective is to continue learning and also use it inside of the application where I’m working on. And of course, try to share and give something back to this community, after been learning from it for so long.

I created a repository on Bitbucket, where you can find all the information about it, and the latest version of the plug-in. There you can find the code to download.

If you want to know more about on which projects I’m working at the moment, come and visit me on Linkedin and say Hi!!,  or don’t doubt to contact me with any further questions.

 

# python

# --------------------------------------------------------------------------------
#  dcSkin.py
# Author: David Cuellar
# Website: http://www.davidcuellar.es
# Email: david.cuellar@gmail.com
# Wiki: https://bitbucket.org/DavidCuellar/dcskin/wiki/Home
# Date: 20 July 2015
# Version: 1.0
#
# Release Notes:
# 1.0- First release
#
# Autodesk Maya Plug-in to import / export skin weights
# Copyright (C) 2015  David Cuellar
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# --------------------------------------------------------------------------------

import os
import cPickle
import datetime
import logging
import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
import maya.OpenMayaAnim as OpenMayaAnim

pluginName = 'dcSkin'

# --------------------------------------------------------------------------------
# arguments flags
# --------------------------------------------------------------------------------

__aplication__ = 'dcSkin'

logging.getLogger().name = __aplication__

helpFlag = '-h'
helpFlagLong = '-help'

sourceMeshFlag = '-sm'
sourceMeshFlagLong = '-exportMesh'

targetMeshFlag = '-tm'
targetMeshFlagLong = '-importMesh'

pathFlag = '-p'
pathFlagLong = '-path'

# --------------------------------------------------------------------------------
# help information
# --------------------------------------------------------------------------------

helpText = ''
helpText += '\n Description: Import/Export the skin weights of/on a mesh.'
helpText += '\n'
helpText += '\n Flags: dcSkin            -h        -help            <n/a>        help message'
helpText += '\n                          -sm       -sourceMesh      <string>     the name of the source mesh'
helpText += '\n                          -tm       -targetMesh      <string>     the name of the target mesh'
helpText += '\n                          -p        -path            <string>     full path to the skin data file'
helpText += '\n Usage: Execute the command with the following arguments:'
helpText += '\n To Export: dcSkin -em <source mesh> -p <skin data file> '
helpText += '\n To Import: dcSkin -im <target mesh> -p <skin data file> '


# --------------------------------------------------------------------------------
# command
# --------------------------------------------------------------------------------


class dcSkin(OpenMayaMPx.MPxCommand):
    def __init__(self):
        OpenMayaMPx.MPxCommand.__init__(self)
        self.windowName = 'dcSkinWindow'
        self.sourceMesh = None
        self.targetMesh = None
        self.dataFile = None
        self.skinCluster = None
        self.skinData = {}
        self.operation = None

    def doIt(self, argList):
        self.dagModifier = OpenMaya.MDagModifier()
        # --------------------------------------------------------------------------------
        # parse the arguments
        # --------------------------------------------------------------------------------
        argData = OpenMaya.MArgDatabase(self.syntax(), argList)
        # help flag
        if argData.isFlagSet(helpFlag):
            self.setResult(helpText)
            return
        # source mesh flag
        if argData.isFlagSet(sourceMeshFlag):
            self.sourceMesh = argData.flagArgumentString(sourceMeshFlag, 0)
        # target mesh flag
        if argData.isFlagSet(targetMeshFlag):
            self.targetMesh = argData.flagArgumentString(targetMeshFlag, 0)
        # path flag
        if argData.isFlagSet(pathFlag):
            self.dataFile = argData.flagArgumentString(pathFlag, 0)
        # Run it
        self.run()
        return self.redoIt()

    def run(self):
        """Check how to run the command. UI or command mode."""
dcSkin.py view raw
Previous Project
Next Project
davidcuellar.es
  • Home
  • About
  • Contact

Copyright © 2018 David Cuellar David Cuellar