Skip to content

Commit ddf276a

Browse files
authored
Merge pull request #73 from mottosso/clone
Clone
2 parents 814c7d9 + d789b22 commit ddf276a

File tree

5 files changed

+434
-46
lines changed

5 files changed

+434
-46
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222

2323
matrix:
2424
include:
25-
- maya: "2017"
26-
pip: "2.7/get-pip.py"
2725
- maya: "2018"
2826
pip: "2.7/get-pip.py"
2927
- maya: "2019"
@@ -32,6 +30,10 @@ jobs:
3230
pip: "2.7/get-pip.py"
3331
- maya: "2022"
3432
pip: "get-pip.py"
33+
- maya: "2023"
34+
pip: "get-pip.py"
35+
- maya: "2024"
36+
pip: "get-pip.py"
3537

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

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<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>
22

3-
<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>
3+
<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>
44

55
<br>
66

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

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

529530
<br>
530531

532+
### Path-like Syntax
533+
534+
Neatly traverse a hierarchy with the `|` syntax.
535+
536+
```py
537+
# Before
538+
group = cmdx.encode("|some_grp")
539+
hand = cmdx.encode(group.path() + "|hand_ctl")
540+
541+
# After
542+
hand = group | "hand_ctl"
543+
```
544+
545+
It can be nested too.
546+
547+
```py
548+
finger = group | "hand_ctl" | "finger_ctl"
549+
```
550+
551+
<br>
552+
553+
### setAttr
554+
555+
Maya's `cmds.setAttr` depends on the UI settings for units.
556+
557+
```py
558+
cmds.setAttr("hand_ctl.translateY", 5)
559+
```
560+
561+
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.
562+
563+
The `cmdx.setAttr` on the other hand does what Maya's API does, which is to treat all units consistently.
564+
565+
```py
566+
cmdx.setAttr("hand_ctl.translateY", 5) # centimeters, always
567+
```
568+
569+
- Distance values are in `centimeters`
570+
- Angular values are in `radians`
571+
572+
So the user is free to choose any unit for their UI without breaking their scripts.
573+
574+
<br>
575+
531576
### Units
532577

533578
`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.
@@ -1018,6 +1063,28 @@ node["myMatrix"] = node["worldMatrix"][0].asMatrix()
10181063

10191064
<br>
10201065

1066+
### Cloning
1067+
1068+
Support for cloning enum attributes.
1069+
1070+
```py
1071+
parent = createNode("transform")
1072+
camera = createNode("camera", parent=parent)
1073+
1074+
# Make new enum attribute
1075+
camera["myEnum"] = Enum(fields=["a", "b", "c"])
1076+
1077+
# Clone it
1078+
clone = camera["myEnum"].clone("cloneEnum")
1079+
cam.addAttr(clone)
1080+
1081+
# Compare it
1082+
fields = camera["cloneEnum"].fields()
1083+
assert fields == ((0, "a"), (1, "b"), (2, "c"))
1084+
```
1085+
1086+
<br>
1087+
10211088
### Native Types
10221089

10231090
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.

build_livedocs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def test_{count}_{header}():
107107
# -*- coding: utf-8 -*-
108108
import os
109109
import sys
110+
110111
import nose
111112
from nose.tools import assert_raises
112113
@@ -115,6 +116,11 @@ def test_{count}_{header}():
115116
from maya import standalone
116117
standalone.initialize()
117118
119+
# For nose
120+
if sys.version_info[0] == 3:
121+
import collections
122+
collections.Callable = collections.abc.Callable
123+
118124
from maya import cmds
119125
import cmdx
120126
@@ -127,6 +133,11 @@ def test_{count}_{header}():
127133
])
128134
129135
result = nose.main(argv=argv, exit=False)
136+
137+
if os.name == "nt":
138+
# Graceful exit, only Windows seems to like this consistently
139+
standalone.uninitialize()
140+
130141
os._exit(0 if result.success else 1)
131142
""")
132143
f.write("".join(tests))

0 commit comments

Comments
 (0)