Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement clone #58

Merged
merged 6 commits into from
Jun 16, 2021
Merged

Implement clone #58

merged 6 commits into from
Jun 16, 2021

Conversation

mottosso
Copy link
Owner

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
# )

And fix a few minor issues too
This could *sometimes* throw an error when creating a new node and locking its attributes in the same dg context.
@mottosso
Copy link
Owner Author

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

@mottosso mottosso merged commit 13c5022 into master Jun 16, 2021
@mottosso mottosso deleted the clonePlug branch January 22, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant