mrv.maya.mdb

Epydoc: mrv.maya.mdb

Provides classes and functions operating on the MayaAPI class database

note:This module must not be auto-initialized as it assumes its parent package to be present already
note:The implementation is considered internal and may change any time unless stated otherwise.

Functions

mrv.maya.mdb._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
mrv.maya.mdb._iterAllNodeTypes()

Returns iterator which yield tuple(nodeTypeName, MObject, modifier) triplets of nodeTypes, with an MObjects instance of it, created with the given modifier, one for each node type available to maya.

Note:skips manipulators as they tend to crash maya on creation ( perhaps its only one which does that, but its not that important )
mrv.maya.mdb.apiModules()
Returns:tuple of api modules containing MayaAPI classes
Note:This takes a moment to load as it will import many api modules. Delay the call as much as possible
mrv.maya.mdb.cacheFilePath(filename, ext, use_version=False)

Return path to cache file from which you would initialize data structures

Parameter:use_version – if true, the maya version will be appended to the filename
mrv.maya.mdb.createDagNodeHierarchy()
Parse the nodes hierarchy file and return a DAGTree with its data :return: DAGTree
mrv.maya.mdb.createTypeNameToMfnClsMap()

Parse a file associating node type names with the best compatible MFn function set and return a dictionary with the data

Returns:dict(((nodeTypeNameStr : api.MFnCls), ...)) dictionary with nodetypeName MFn class mapping
mrv.maya.mdb.extractMFnFunctions(mfncls)
Extract callables from mfncls, sorted into static methods and instance methods :return: tuple(list(callable_staticmethod, ...), list(callable_instancemethod, ...))
mrv.maya.mdb.generateNodeHierarchy()

Generate the node-hierarchy for the current version based on all node types which can be created in maya.

Returns:

tuple(DAGTree, typeToMFnClsNameList)

  • DAGTree representing the type hierarchy
  • list represents typeName to MFnClassName associations
Note:

should only be run as part of the upgrade process to prepare MRV for a new maya release. Otherwise the nodetype tree will be read from a cache

mrv.maya.mdb.hasMEnumeration(mfncls)
Returns:True if the given mfncls has at least one enumeration
mrv.maya.mdb.headerPath(apiname)
Returns:Path to file containing the c++ header of the given apiclass’ name. The file will not be verified, hence it may be inaccessible
Parameter:apiname – string name, like ‘MFnBase’
Raises ValueError:
 if MAYA_LOCATION is not set
mrv.maya.mdb.make_path(path)
Returns:A path instance of the correct type
Note:use this constructor if you use the Path.set_separator method at runtime to assure you will always create instances of the actual type, and not only of the type you imported last
mrv.maya.mdb.mfnDBPath(mfnclsname)
Generate a path to a database file containing mfn wrapping information
mrv.maya.mdb.nodeHierarchyFile()
Returns:Path to the node hierarchy file of the currently active maya version
mrv.maya.mdb.writeMfnDBCacheFiles()

Create a simple Memberlist of available mfn classes and their members to allow a simple human-editable way of adjusting which methods will be added to the Nodes.

Note:currently writes information about all known api modules

Classes

Epydoc: mrv.maya.mdb.CppHeaderParser

class mrv.maya.mdb.CppHeaderParser

Bases: object

Simplistic regex based parser which will extract information from the file it was initialized with.

For now its so simple that there is no more than one method

classmethod parseAndExtract(header_filepath, parse_enums=True)

Parse the given header file and return the parsed information

Parameters:
  • header_filepath – Path pointing to the given header file. Its currently assumed to be 7 bit ascii
  • parse_enums – If True, enumerations will be parsed from the file. If False, the enumeration tuple in the return value will be empty.
Note:

Currently we can only parse non-anonymous enumerations !

Returns:

tuple(tuple(MEnumDescriptor, ...), )

Epydoc: mrv.maya.mdb.MEnumDescriptor

class mrv.maya.mdb.MEnumDescriptor(name)

Bases: list

Is an ordered list of enumeration names without its values, together with the name of the enumeration type

append
L.append(object) – append object to end
count
L.count(value) -> integer – return number of occurrences of value
extend
L.extend(iterable) – extend list by appending elements from the iterable
index
L.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
insert
L.insert(index, object) – insert object before index
name
pop
L.pop([index]) -> item – remove and return item at index (default last). Raises IndexError if list is empty or index is out of range.
remove
L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.
reverse
L.reverse() – reverse IN PLACE
sort
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

Epydoc: mrv.maya.mdb.MFnCodeGeneratorBase

class mrv.maya.mdb.MFnCodeGeneratorBase(module_dict)

Bases: object

Define the interface and common utility methods to generate a string defining code for a given MFnMethod according to the meta data provided by an MMethodDescriptor.

Once instantiated, it can create any number of methods

generateMFnClsMethodWrapper(source_method_name, target_method_name, mfn_fun_name, method_descriptor, flags=0)
Returns:

string containing the code for the wrapper method as configured by the method descriptor

Parameters:
  • source_method_name – Original name of the method - this is the name under which it was requested.
  • target_method_name – Name of the method in the returned code string
  • mfn_fun_name – original name of the MFn function
  • method_descriptor – instance of MMethodDescriptor
  • flags – bit flags providing additional information, depending on the actual implementation. Unsupported flags are ignored.
module_dict

Epydoc: mrv.maya.mdb.MMemberMap

class mrv.maya.mdb.MMemberMap(filepath=None, parse_enums=False)

Bases: UserDict.UserDict

Simple accessor for MFnDatabase access Direct access like db[funcname] returns an entry object with all values

Globals: The __globals__ entry in MFn db files allows to pass additional options. Currently there are no supported flags

clear()
copy()
createEntry(funcname)

Create an entry for the given function, or return the existing one

Returns:Entry object for funcname
classmethod fromkeys(iterable, value=None)
get(key, failobj=None)
has_key(key)
items()
iteritems()
iterkeys()
itervalues()
keys()
methodByName(funcname)
Returns:Tuple( mfnfuncname, entry ) original mfnclass function name paired with the db entry containing more information
Raises KeyError:
 if no such function exists
mfnFunc(funcname)
Returns:mfn functionname corresponding to the ( possibly renamed ) funcname
pop(key, *args)
popitem()
setdefault(key, failobj=None)
update(dict=None, **kwargs)
values()
writeToFile(filepath)
Write our database contents to the given file

Epydoc: mrv.maya.mdb.MMethodDescriptor

class mrv.maya.mdb.MMethodDescriptor(flag='', rvalfunc=None, newname='')

Bases: object

Contains meta-information about a given method according to data read from the MFnDatabase

flag
newname
rvalfunc

Epydoc: mrv.maya.mdb

class mrv.maya.mdb.PipeSeparatedFile(fileobj)

Bases: object

Read and write simple pipe separated files.

The number of column must remain the same per line Format:

val11 | val2 | valn ...
beginReading()
Start reading the file
beginWriting(columnSizes)

intiialize the writing process

Parameter:columnSizes – list of ints defining the size in characters for each column you plan to feed
Note:When done writing, you have to close the file object yourself (there is no endWriting method here)
readColumnLine()

Generator reading one line after another, returning the stripped columns

Returns:tuple of stripped column strings
Raises ValueError:
 if the column count changes between the lines
writeTokens(tokens)

Write the list of tokens to the file accordingly

Parameter:tokens – one token per column that you want to write
Raises TypeError:
 If column count changed between successive calls

Epydoc: mrv.maya.mdb.PythonMFnCodeGenerator

class mrv.maya.mdb.PythonMFnCodeGenerator(module_dict)

Bases: mrv.maya.mdb.MFnCodeGeneratorBase

Specialization to generate python code

Flags:

  • kDirectCall:

    If set, the call return the actual mfn method in the best case, which is a call as direct as it gets. A possibly negative side-effect would be that it the MFnMethod caches the function set and actual MObject/MDagPath, which can be dangerous if held too long

  • kIsMObject:

    If set, the type we create the method for is not derived from Node, but from MObject. This hint is required in order to generate correct calling code.

  • kIsDagNode:

    If set, the type we create the method for is derived from DagNode

  • kIsStatic:

    If set, the method to be wrapped is considered static, no self is needed, nor any object. NOTE: This flag is likely to be removed as it should be part of the method_descriptor, for now though it does not provide that information so we pass it in.

  • kWithDocs:

    If set, a doc string will be generated the method. In future, this information will come from the method descriptor. Please note that docs should only be attaced in interactive modes, otherwise its a waste of memory.

generateMFnClsMethodWrapper(source_method_name, target_method_name, mfn_fun_name, method_descriptor, flags=0)

Generates code as python string which can be used to compile a function. It assumes the following globals to be existing once evaluated: mfncls, mfn_fun, [rvalfunc] Currently supports the following data within method_descriptor:

  • method_descriptor.rvalfunc

as well as all flags except kIsStatic. :raise ValueError: if flags are incompatible with each other

generateMFnClsMethodWrapperMethod(source_method_name, target_method_name, mfncls, mfn_fun, method_descriptor, flags=0)
Returns:

python function suitable to be installed on a class

Parameters:
  • mfncls – MFnFunction set class from which the method was retrieved.
  • mfn_fun – function as retrieved from the function set’s dict. Its a bare function.
Note:

For all other args, see MFnCodeGeneratorBase.generateMFnClsMethodWrapper

module_dict

Table Of Contents

Previous topic

mrv.info

Next topic

mrv.maya.util

This Page