Skip to content

Commit

Permalink
Merge pull request #73 from mottosso/clone
Browse files Browse the repository at this point in the history
Clone
  • Loading branch information
mottosso committed Dec 14, 2023
2 parents 814c7d9 + d789b22 commit ddf276a
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 46 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:

matrix:
include:
- maya: "2017"
pip: "2.7/get-pip.py"
- maya: "2018"
pip: "2.7/get-pip.py"
- maya: "2019"
Expand All @@ -32,6 +30,10 @@ jobs:
pip: "2.7/get-pip.py"
- maya: "2022"
pip: "get-pip.py"
- maya: "2023"
pip: "get-pip.py"
- maya: "2024"
pip: "get-pip.py"

container: mottosso/maya:${{ matrix.maya }}

Expand Down
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a href=/cmdx/><p align=center><img height=140 src=https://user-images.githubusercontent.com/2152766/34321609-f134e0cc-e80a-11e7-8dad-d124fea80e77.png></p></a>

<p align=center>A fast subset of <a href=http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/index.html><code>maya.cmds</code></a><br>For Maya 2017-2022</p>
<p align=center>A fast subset of <a href=http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/index.html><code>maya.cmds</code></a><br>For Maya 2018-2024</p>

<br>

Expand All @@ -23,6 +23,7 @@ On average, `cmdx` is **140x faster** than [PyMEL](https://github.com/LumaPictur

| Date | Version | Event
|:---------|:----------|:----------
| Dec 2023 | 0.6.3 | Cloning of attributes
| Apr 2020 | 0.6.0 | Stable Undo/Redo, dropped support for Maya 2015-2016
| Mar 2020 | 0.5.1 | Support for Maya 2022
| Mar 2020 | 0.5.0 | Stable release
Expand Down Expand Up @@ -528,6 +529,50 @@ The reason for this limitation is because the functions `cmds`

<br>

### Path-like Syntax

Neatly traverse a hierarchy with the `|` syntax.

```py
# Before
group = cmdx.encode("|some_grp")
hand = cmdx.encode(group.path() + "|hand_ctl")

# After
hand = group | "hand_ctl"
```

It can be nested too.

```py
finger = group | "hand_ctl" | "finger_ctl"
```

<br>

### setAttr

Maya's `cmds.setAttr` depends on the UI settings for units.

```py
cmds.setAttr("hand_ctl.translateY", 5)
```

For a user with Maya set to `Centimeters`, this would set `translateY` to 5 centimeters. For any user with any other unit, like `Foot`, it would instead move it 5 feet. That is terrible behaviour for a script, how can you possibly define the length of something if you don't know the unit? A dog is 100 cm tall, not 100 "any unit" tall.

The `cmdx.setAttr` on the other hand does what Maya's API does, which is to treat all units consistently.

```py
cmdx.setAttr("hand_ctl.translateY", 5) # centimeters, always
```

- Distance values are in `centimeters`
- Angular values are in `radians`

So the user is free to choose any unit for their UI without breaking their scripts.

<br>

### Units

`cmdx` takes and returns values in the units used by the UI. For example, Maya's default unit for distances, such as `translateX` is in Centimeters.
Expand Down Expand Up @@ -1018,6 +1063,28 @@ node["myMatrix"] = node["worldMatrix"][0].asMatrix()

<br>

### Cloning

Support for cloning enum attributes.

```py
parent = createNode("transform")
camera = createNode("camera", parent=parent)

# Make new enum attribute
camera["myEnum"] = Enum(fields=["a", "b", "c"])

# Clone it
clone = camera["myEnum"].clone("cloneEnum")
cam.addAttr(clone)

# Compare it
fields = camera["cloneEnum"].fields()
assert fields == ((0, "a"), (1, "b"), (2, "c"))
```

<br>

### Native Types

Maya boasts a library of classes that provide mathematical convenience functionality, such as rotating a vector, multiplying matrices or converting between Euler degrees and Quaternions.
Expand Down
11 changes: 11 additions & 0 deletions build_livedocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def test_{count}_{header}():
# -*- coding: utf-8 -*-
import os
import sys
import nose
from nose.tools import assert_raises
Expand All @@ -115,6 +116,11 @@ def test_{count}_{header}():
from maya import standalone
standalone.initialize()
# For nose
if sys.version_info[0] == 3:
import collections
collections.Callable = collections.abc.Callable
from maya import cmds
import cmdx
Expand All @@ -127,6 +133,11 @@ def test_{count}_{header}():
])
result = nose.main(argv=argv, exit=False)
if os.name == "nt":
# Graceful exit, only Windows seems to like this consistently
standalone.uninitialize()
os._exit(0 if result.success else 1)
""")
f.write("".join(tests))
Loading

0 comments on commit ddf276a

Please sign in to comment.