mottosso / cmdx

Fast and persistent subset of maya.cmds
https://mottosso.com/cmdx
BSD 2-Clause "Simplified" License
193 stars 36 forks source link

Implement clone #58

Closed mottosso closed 3 years ago

mottosso commented 3 years ago

And fix a few minor issues too.

This can be used to reproduce one plug on another node, including special properties of said plug like min/max values, whether or not it shows up in the channel box, is it stored alongside the scene and so on.

>>> parent = createNode("transform")
>>> cam = createNode("camera", parent=parent)
>>> original = cam["focalLength"]
>>> clone = original.clone("focalClone")

# Original setup is preserved
>>> clone["min"]
2.5
>>> clone["max"]
100000.0

>>> cam.addAttr(clone)
>>> cam["focalClone"].read()
35.0

# Also works with modifiers
>>> with DagModifier() as mod:
...   clone = cam["fStop"].clone("fClone")
...   _ = mod.addAttr(cam, clone)
...
>>> cam["fClone"].read()
5.6

Matrices are now also pretty-printed.

print(cmdx.Mat4())
# 1.00 0.00 0.00 0.00
# 0.00 1.00 0.00 0.00
# 0.00 0.00 1.00 0.00
# 0.00 0.00 0.00 1.00

print(repr(cmdx.Mat4()))
# cmdx.Matrix4(
#   1.00 0.00 0.00 0.00
#   0.00 1.00 0.00 0.00
#   0.00 0.00 1.00 0.00
#   0.00 0.00 0.00 1.00
# )
mottosso commented 3 years ago

This has been solid for a few months now, go go go!