Thursday, April 18, 2013

My own "Hello, World!" Maya plug-in


Yestarday, I used Maya devkit example to learn Maya plug-ins. Today, I will create my own alternative Hello World plug-in!
import maya.OpenMaya as om
import maya.OpenMayaMPx as ommpx

class AR_HelloWorldCmd(ommpx.MPxCommand):
    """
    A command that prints a string to the console.
    """
    
    ## the name of the command
    kPluginCmdName = 'ar_helloWorld'
   
    def __init__(self):
        """
        Initialize the instance.
        """
        ommpx.MPxCommand.__init__(self)
   
    def doIt(self, args):
        """
        Print string to the console.
        """
        print('Hello, world!')
   
    @classmethod
    def cmdCreator(cls):
        """
        Return pointer to proxy object.It has to always call this method when creating MPx objects in scripted plug-ins.
        """
        return ommpx.asMPxPtr(cls())

def initializePlugin(obj):
    """
    Initialize the plug-in.
    """
    plugin = ommpx.MFnPlugin(
        obj,
        'Meng',
        '1.0',
        'Any'
    )
    try:
        plugin.registerCommand(
            AR_HelloWorldCmd.kPluginCmdName,
            AR_HelloWorldCmd.cmdCreator
        )
    except:
        raise Exception(
            'Failed to register command: %s'%
            AR_HelloWorldCmd.kPluginCmdName
        )

def uninitializePlugin(obj):
    """
    Uninitialize the plug-in.
    """
    plugin = ommpx.MFnPlugin(obj)
    try:
        plugin.deregisterCommand(AR_HelloWorldCmd.kPluginCmdName)      
    except:
        raise Exception(
            'Failed to unregister command: %s'%
            AR_HelloWorldCmd.kPluginCmdName
        )

It is critical to note again that you must unload and then reload a plug-in to see changes that you are making in an external text editor become active in Maya.

Wednesday, April 17, 2013

Maya Plug-In

The simplest way to start developing commands by using plug-ins is to look at the simplest possible example. The Maya devkit folder contains sevel example commands.

So I add helloworld plug-in by using Plug-in Manager:
Then print “Hello World!” should be as simple as type:

import maya.cmds as cmds;
cmds.spHelloWorld()

Sunday, April 14, 2013

Formal Categorization of Problem solving Strategies


The following is a more Formal Categorization of Problem solving Strategies:

 Abstraction: solving the problem in a model of the system before applying it to the real system
 Analogy: using a solution that solves an analogous problem
• Brainstorming: (especially among groups of people) suggesting a large number of solutions or ideas and combining and developing them until an optimum is found
• Divide and conquer: breaking down a large, complex problem into smaller, solvable problems
• Hypothesis testing: assuming a possible explanation to the problem and trying to prove (or, in some contexts, disprove) the assumption
 Lateral thinking: approaching solutions indirectly and creatively
• Means-ends analysis: choosing an action at each step to move closer to the goal
• Method of focal objects: synthesizing seemingly non-matching characteristics of different objects into something new
• Morphological analysis: assessing the output and interactions of an entire system
• Proof: try to prove that the problem cannot be solved. The point where the proof fails will be the starting point for solving it
• Reduction: transforming the problem into another problem for which solutions exist
• Research: employing existing ideas or adapting existing solutions to similar problems
• Root cause analysis: identifying the cause of a problem
 Trial-and-error: testing possible solutions until the right one is found

Thursday, April 11, 2013

General Problem Solving Strategies


General Problem Solving Strategies: 

1. Read and try to understand asserts diagnostics or symptoms if available.
2. Form clear hypothesis about cause of problem.
3. Compare and contrast a working case with a non-working case.
4. Trace flow if possible.
5. Isolate working and non-working parts. (Divide and conquer)  This is different from 3 above in that 3 describes comparing a working whole vs. a non-working whole.  Here, we are separating parts of a non-working whole into working and non-working parts.
6. Time Box Trouble Shooting Efforts and ask for help
7. Form new hypothesis if necessary --walk away and return after a break.

Saturday, April 6, 2013

Reading Material


Since I'm a little ahead of my schedule, so, I decided to read more materials related to technical artist instead of keep reading Maya Python. Here are some materials I read.

1.       A great book to read on controlling flow in complex systems. This book helps me to naturally involve objective analysis, economics and an understanding of flow in my problem solving process.

2.       Several links describing Technical Art: Since reality is composed of multiple perspectives, it’s important to encounter multiple points of view.  No single description is definitive.