pyfrost.api.maya

Maya Node API.

author

Benoit Gielly <benoit.gielly@gmail.com>

The intention here is to build a node API specific to each DDC (here, Maya), so in the main.py we can call that and remove the cmds calls.

When a DCC is started, the relevant API is injected in the Main one.

Note

This is a Work in Progress for now and not in use.

Example

If we were to rewrite the pyfrost.main.Graph.validate_board method, we could like that:

def __init__(self):
    self.api = Api()

def validate_board(self, name=None):
    node = self.api[name]
    if node.exists and node.type == "bifrostBoard":
        return name
    name = name if name else "bifrostGraph"
    board = api.create("bifrostBoard", name)
    return board.name

That way, all the main code remains clean of DCC commands. Obviously, each DCCs APIs must be implemented the same way for this to work.

class MayaAPI[source]

Bases: object

Create a Maya API object.

__repr__()[source]

Return repr(self).

__getitem__(key)[source]
create(nodetype, name=None)[source]

Create new node.

get(name)[source]

Get existing node.

class MayaNode(api, node)[source]

Bases: object

Get MayaNode object.

__init__(api, node)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__(*args, **kwargs)[source]

Return repr(self).

__str__()[source]

Return str(self).

__getitem__(key)[source]
type()[source]

Get node type.

rename(name)[source]

Rename node.

class MayaAttr(node, name)[source]

Bases: object

Create a Maya Attribute class.

__init__(node, name)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

property plug

Get plug.

exists()[source]

Check if node exists.

property value

Get & set attribute’s value.

property type

Get & set attribute’s type.

add(type_, **kwargs)[source]

Add attribute on node.

get()[source]

Set node’s attribute value.

set(value)[source]

Set node’s attribute value.

connect(target)[source]

Connect current node to target.

disconnect(target)[source]

Disconnect current node from target.