Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tahv/attribs
A experimental Python library for creating Maya Attributes
https://github.com/tahv/attribs
maya python
Last synced: 10 days ago
JSON representation
A experimental Python library for creating Maya Attributes
- Host: GitHub
- URL: https://github.com/tahv/attribs
- Owner: tahv
- License: mit
- Created: 2024-12-04T20:20:13.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-12-22T13:48:05.000Z (17 days ago)
- Last Synced: 2024-12-22T14:29:47.575Z (17 days ago)
- Topics: maya, python
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# attribs
An experimental Python library for creating Maya Attributes.
## Installation
Install attribs with pip:
```bash
pip install maya-attribs
```## Quickstart
Use `attribs.add_attribute` to create an new attributes
on an `OpenMaya.MFnDependencyNode`.
This function also returns the newly created `OpenMaya.MPlug`.```python
from maya import cmds
from maya.api import OpenMaya
import attribsdef create_node(node_type: str) -> OpenMaya.MObject:
name = cmds.createNode(node_type)
return OpenMaya.MSelectionList().add(name).getDependNode(0)node = OpenMaya.MFnDependencyNode(create_node("transform"))
modifier = OpenMaya.MDGModifier()attribute = attribs.Bool("foo", default=False)
plug = attribs.add_attribute(node, attribute, modifier=modifier)
```Set attribute flags either as keyword argument or later as properties.
```python
from maya import cmds
from maya.api import OpenMaya
import attribsdef create_node(node_type: str) -> OpenMaya.MObject:
name = cmds.createNode(node_type)
return OpenMaya.MSelectionList().add(name).getDependNode(0)node = OpenMaya.MFnDependencyNode(create_node("transform"))
modifier = OpenMaya.MDGModifier()attribute = attribs.Double3(
"MyDouble",
default=(1.0, 2.0, 3.0),
channel_box=True,
)
attribute.keyable = Trueplug = attribs.add_attribute(node, attribute, modifier=modifier)
```Compounds are also supported.
```python
from maya import cmds
from maya.api import OpenMaya
import attribsdef create_node(node_type: str) -> OpenMaya.MObject:
name = cmds.createNode(node_type)
return OpenMaya.MSelectionList().add(name).getDependNode(0)node = OpenMaya.MFnDependencyNode(create_node("transform"))
modifier = OpenMaya.MDGModifier()attribute = attribs.Compound("foo")
attribute.append(attribs.Bool("bar"))
attribute.append(attribs.String("baz"))plug = attribs.add_attribute(node, attribute, modifier=modifier)
```