You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<palign=center>A fast subset of <ahref=http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/index.html><code>maya.cmds</code></a><br>For Maya 2015-2022</p>
3
+
<palign=center>A fast subset of <ahref=http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/index.html><code>maya.cmds</code></a><br>For Maya 2017-2022</p>
4
4
5
5
<br>
6
6
@@ -23,6 +23,7 @@ On average, `cmdx` is **140x faster** than [PyMEL](https://github.com/LumaPictur
23
23
24
24
| Date | Version | Event
25
25
|:---------|:----------|:----------
26
+
| Apr 2020 | 0.6.0 | Stable Undo/Redo, dropped support for Maya 2015-2016
26
27
| Mar 2020 | 0.5.1 | Support for Maya 2022
27
28
| Mar 2020 | 0.5.0 | Stable release
28
29
| Aug 2019 | 0.4.0 | Public release
@@ -35,8 +36,6 @@ On average, `cmdx` is **140x faster** than [PyMEL](https://github.com/LumaPictur
@@ -76,7 +75,6 @@ With [so many options](#comparison) for interacting with Maya, when or why shoul
76
75
-[Node and attribute reuse](#query-reduction)
77
76
-[Transactions](#transactions)
78
77
-[Hashable References](#hashable-references)
79
-
-[Signals](#signals)
80
78
-[PEP8 Dual Syntax](#pep8-dual-syntax)
81
79
82
80
<br>
@@ -157,7 +155,7 @@ With [so many options](#comparison) for interacting with Maya, when or why shoul
157
155
158
156
### System Requirements
159
157
160
-
`cmdx` runs on Maya 2015 SP3 and above (SP2 does *not* work).
158
+
`cmdx` runs on Maya 2017 above.
161
159
162
160
It *may* run on older versions too, but those are not being tested. To bypass the version check, see [`CMDX_IGNORE_VERSION`](#cmdx_ignore_version).
163
161
@@ -597,14 +595,15 @@ For undo, you've got two options.
597
595
node = cmdx.createNode("transform")
598
596
```
599
597
600
-
This operation is undoable, because under the hood it calls`cmdx.DagModifier`.
598
+
This operation is not undoable and is intended for use with`cmdx.commit` and/or within a Python plug-in.
601
599
602
600
```py
603
601
node["translateX"] =5
604
602
node["tx"] >> node["ty"]
603
+
cmdx.delete(node)
605
604
```
606
605
607
-
These operations however is *not* undoable.
606
+
These operations are also not undoable.
608
607
609
608
In order to edit attributes with support for undo, you must use either a modifier or call `commit`. This is how the Maya API normally works, for both Python and C++.
610
609
@@ -638,7 +637,10 @@ With this level of control, you are able to put Maya in a bad state.
638
637
639
638
```py
640
639
a = cmdx.encode("existingNode")
641
-
b = cmdx.createNode("transform", name="newNode")
640
+
641
+
with cmdx.DagModifier() as mod:
642
+
b = mod.createNode("transform", name="newNode")
643
+
642
644
b["ty"] >> a["tx"]
643
645
```
644
646
@@ -753,8 +755,6 @@ for member in objset:
753
755
print(member)
754
756
```
755
757
756
-
> NOTE: `MFnSet` was first introduced to the Maya Python API 2.0 in Maya 2016 and has been backported to work with `cmdx` in Maya 2015, leveraging the equivalent functionality found in API 1.0. It does however mean that there is a performance impact in Maya <2016 of roughly 0.01 ms/node.
757
-
758
758
<br>
759
759
760
760
### Attribute Query and Assignment
@@ -1163,6 +1163,8 @@ assert b.child(contains="nurbsCurve") != c
@@ -1554,7 +1560,7 @@ It's not all roses; in order of severity:
1554
1560
Modifiers in `cmdx` extend the native modifiers with these extras.
1555
1561
1556
1562
1.**Automatically undoable** Like `cmds`
1557
-
2.**Transactional** Changes are automatically rolled back on error, making every modifier atomic
1563
+
2.**Atomic** Changes are automatically rolled back on error, making every modifier atomic
1558
1564
3.**Debuggable** Maya's native modifier throws an error without including what or where it happened. `cmdx` provides detailed diagnostics of what was supposed to happen, what happened, attempts to figure out why and what line number it occurred on.
1559
1565
4.**Name templates** Reduce character count by delegating a "theme" of names across many new nodes.
1560
1566
@@ -1572,24 +1578,14 @@ with cmdx.DagModifier() as mod:
1572
1578
1573
1579
Now when calling `undo`, the above lines will be undone as you'd expect.
@@ -1601,37 +1597,110 @@ with cmdx.DagModifier(template="myName_{type}") as mod:
1601
1597
assert node.name() =="myName_transform"
1602
1598
```
1603
1599
1604
-
This makes it easy to move a block of code into a modifier without changing things around. Perhaps to test performance, or to figure out whether undo support is necessary.
1600
+
##### Connect To Newly Created Attribute
1605
1601
1606
-
##### Limitations
1602
+
Creating a new attribute returns a "promise" of that attribute being created. You can pass that to `connectAttr` to both create and connect attributes in the same modifier.
1607
1603
1608
-
The modifier is quite limited in what features it provides; in general, it can only *modify* the scenegraph, it cannot query it.
Sometimes you're creating a series of utility nodes that you don't want visible in the channel box. So you can either go..
1622
1625
1623
-
Maya offers a large number of callbacks for responding to native events in your code. `cmdx` wraps some of these in an alternative interface akin to Qt Signals and Slots.
..or use the convenience argument to make everything neat.
1627
1635
1628
-
defonDestroyed():
1629
-
pass
1636
+
```py
1637
+
with cmdx.DGModifier(interesting=False) as mod:
1638
+
mod.createNode("reverse")
1639
+
mod.createNode("multMatrix")
1640
+
```
1630
1641
1631
-
node = cmdx.createNode("transform")
1632
-
node.onDestroyed.append(onDestroyed)
1642
+
##### Convenience Try Set Attr
1643
+
1644
+
Sometimes you aren't too concerned whether setting an attribute actually succeeds or not. Perhaps you're writing a bulk-importer, and it'll become obvious to the end-user whether attributes were set or not, or you simply could not care less.
1645
+
1646
+
For that, you can either..
1647
+
1648
+
```py
1649
+
with cmdx.DagModifier() as mod:
1650
+
try:
1651
+
mod.setAttr(node["attr1"], 5.0)
1652
+
except cmdx.LockedError:
1653
+
pass# This is OK
1654
+
try:
1655
+
mod.setAttr(node["attr2"], 5.0)
1656
+
except cmdx.LockedError:
1657
+
pass# This is OK
1658
+
try:
1659
+
mod.setAttr(node["attr3"], 5.0)
1660
+
except cmdx.LockedError:
1661
+
pass# This is OK
1662
+
```
1663
+
1664
+
..or you can use the convenience `trySetAttr` to ease up on readability.
1665
+
1666
+
```py
1667
+
1668
+
with cmdx.DagModifier() as mod:
1669
+
mod.trySetAttr(node["attr1"], 5.0)
1670
+
mod.trySetAttr(node["attr2"], 5.0)
1671
+
mod.trySetAttr(node["attr3"], 5.0)
1672
+
```
1673
+
1674
+
##### Convenience Set Attr
1675
+
1676
+
Sometimes, the attribute you're setting is connected to by another attribute. Maybe driven by some controller on a character rig?
1677
+
1678
+
In such cases, the attribute cannot be set, and must set whichever attribute is feeding into it instead. So you could..
1679
+
1680
+
```py
1681
+
with cmdx.DagModifier() as mod:
1682
+
if node["myAttr"].connected:
1683
+
other = node["myAttr"].connection(destination=False, plug=True)
1684
+
mod.setAttr(other["myAttr"], 5.0)
1685
+
else:
1686
+
mod.setAttr(node["myAttr"], 5.0)
1687
+
```
1688
+
1689
+
Or, you can use the `smart_set_attr` to automate this process.
1690
+
1691
+
```py
1692
+
with cmdx.DagModifier() as mod:
1693
+
mod.smartSetAttr(node["myAttr"], 5.0)
1633
1694
```
1634
1695
1696
+
##### Limitations
1697
+
1698
+
The modifier is quite limited in what features it provides; in general, it can only *modify* the scenegraph, it cannot query it.
1699
+
1700
+
1. It cannot read attributes
1701
+
2. It cannot set complex attribute types, such as meshes or nurbs curves
1702
+
3. It cannot query a future hierarchy, such as asking for the parent or children of a newly created node unless you call `doIt()` first)
0 commit comments