Skip to content

Commit ee73d07

Browse files
authored
Merge pull request #50 from mottosso/animate
Animate
2 parents f84b3c5 + f5dadea commit ee73d07

File tree

2 files changed

+281
-67
lines changed

2 files changed

+281
-67
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,41 @@ assert node["tx"] == 10
849849

850850
Using `cmdx.Cached` is a lot faster than recomputing the value, sometimes by several orders of magnitude depending on the type of value being queried.
851851

852+
#### Animation
853+
854+
Assigning a dictionary to any numerical attribute turns those values into animation, with an appropriate curve type.
855+
856+
```py
857+
node = createNode("transform")
858+
node["translateX"] = {1: 0.0, 5: 1.0, 10: 0.0} # animCurveTL
859+
node["rotateX"] = {1: 0.0, 5: 1.0, 10: 0.0} # animCurveTA
860+
node["scaleX"] = {1: 0.0, 5: 1.0, 10: 0.0} # animCurveTL
861+
node["visibility"] = {1: True, 5: False, 10: True} # animCurveTU
862+
863+
# Alternatively
864+
node["v"].animate({1: False, 5: True, 10: False})
865+
```
866+
867+
Where the `key` is the frame number (can be fractional) and `value` is the value at that frame. Interpolation is `cmdx.Linear` per default, but can be customised with..
868+
869+
```py
870+
node["rotateX"].animate({1: 0.0, 5: 1.0, 10: 0.0}, cmdx.Smooth)
871+
```
872+
873+
Currently available options:
874+
875+
- `cmdx.Stepped`
876+
- `cmdx.Linear`
877+
- `cmdx.Smooth`
878+
879+
Animation is *undoable* if used with a modifier.
880+
881+
```py
882+
with cmdx.DagModifier() as mod:
883+
node = mod.createNode("transform")
884+
node["tx"] = {1: 0.0, 2: 5.0}
885+
```
886+
852887
#### Time
853888

854889
The `time` argument of `cmdx.getAttr` enables a query to yield results relative a specific point in time. The `time` argument of `Plug.read` offers this same convenience, only faster.
@@ -859,8 +894,7 @@ from maya import cmds
859894
node = cmdx.createNode("transform")
860895

861896
# Make some animation
862-
tx = cmdx.create_node("animCurveTL")
863-
tx.keys(times=[1, 50, 100], values=[0.0, 10.0, 0.0], interpolation=cmdx.Linear)
897+
node["tx"] = {1: 0.0, 50: 10.0, 100: 0.0}
864898

865899
# Query it
866900
node = cmdx.create_node("transform")

0 commit comments

Comments
 (0)