2011년 6월 29일 수요일

파일경로설정

fileObject = MFileObject()
fileObject.setRawFullName(filename)
fileObject.resolvedFullName()

filename을 상대경로로 입력하면 FullPathName을 출력한다.

2011년 6월 20일 월요일

Get Attribute

def nameToNodePlug( attrName, nodeObject ):
    depNodeFn = OpenMaya.MFnDependencyNode( nodeObject )
    attrObject = depNodeFn.attribute( attrName )
    plug = OpenMaya.MPlug( MObject, attrName )
    return plug
nodeObject = MObject type

MDagPath를 MObject type으로 변환하려면 MDagPath.node() Function을 사용.

dagPath = OpenMaya.MDagPath()
depFn = OpenMaya.MFnDependencyNode()
dagIt = OpenMaya.MItDag(OpenMaya.MItDag.kBreadthFirst, OpenMaya.MFn.kSurface)
while not dagIt.isDone():
    dagIt.getPath(dagPath)
    depFn.setObject(dagPath.node())
    arrtObject = depFn.attribute('intermediateObject')
    plug = OpenMaya.MPlug(dagPath.node(), arrtObject)
    print plug.asInt()
    dagIt.next()
뭐 대충 으런식으로 object shape attribute을 가져온다.

2011년 6월 19일 일요일

Scripted plug-in initialization

When a scripted plug-in is loaded, Maya searches for an initializePlugin() function in its definition. Within this function, all proxy nodes are registered:
# Initialize the script plug-in
def initializePlugin(mobject):
    mplugin = OpenMayaMPx.MFnPlugin(mobject)
    try:
        mplugin.registerCommand( kPluginCmdName, cmdCreator )
    except:
        sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName )
        raise

Writing a scripted plug-in


Writing a scripted plug-in requires the definition of some specialized functions within the plug-in. The scripted plug-in must:

Define initializePlugin and uninitializePlugin entry points.
Register and unregister the proxy class within these entry points.
Implement creator and initialize methods (as required) which Maya calls to build the proxy class.
Implement the required functionality of the proxy class. This requires importing the necessary modules.

Writing scripts


The Maya Python API modules contain the classes that are available for Python programming. These classes are separated into different categories and have appropriate naming conventions to signify their association. Classes include:

MFn
Any class with this prefix is a function set used to operate on MObjects of a particular type.

MIt
These classes are iterators and work on MObjects similar to the way a function set does. For example, MItCurveCV is used to operate on an individual NURBS curve CV (there is no MFnNurbsCurveCV), or, iteratively, on all the CVs of a curve.

MPx
Classes with this prefix are all "Proxies", that is, API classes designed for you to derive from and create your own object types.

Help on a module or class


help(maya.OpenMaya.MVector)
help(maya.OpenMaya)

2011년 6월 14일 화요일

Slim Tcl Expression for color, vector, point


Color and Point Functions
rgb(r,g,b), rgbi(ir,ig,ib)
Allow the specification of color (vector) parameters. r,g,b in the range [0,1], ir,ig,ib in the range [0,255].

hsv(h,s,v), hsvi(ih,is,iv)
Allow the specification of color (vector) parameters in the HSV color space. h,s,v in the range [0,1], ih,is,iv in the range [0,255]. Note that this will immediately convert the hsv values to rgb values.

xyz(x,y,z)
Allow the specification of point (vector) parameters.

2011년 6월 9일 목요일

Slim co-shader attach Bug!


Add slim.ini
SetPref SlimAttachableMap(class) {surface coshader}