Comments (3)
Hi @GuidoPollini, thanks and happy to hear you like it. :)
clashes are possible for nodes in the same scene
Indeed, except that leaves out the very next and most important line from the docs.
However different MObjectHandles whose MObjects refer to the same internal Maya object will return the same hash code.
In other words, it always returns the same node in the scene, which is exactly what you want. That's how you can get the same instance of the singleton like this.
instanceA = cmdx.createNode("reverse", name="myNode")
instanceB = cmdx.ls(type="reverse")[0]
assert instanceA is instanceB
Because they will be the same variable.
instanceA._my_special_data = "Hello!"
print(instanceB._my_special_data)
# Hello!
from cmdx.
Indeed:).
if I'm not wrong, in case of clash the Singleton._instance will lose the reference to the original wrapper and (if no cycles are involved) next garbage collection will call Node.del unregistering the callbacks.
It should all be fine:)
from cmdx.
I should hope __del__
is only called when the last reference is lost, rather then once there is a clash. In my code, I call cmdx.uninstall()
on scene open to clear out any references and old commands from undo, which is when I expect __del__
to get called.
In practice it has been working well so far. Have been using this for a few years now in all of my Maya projects, most recently/currently ragdoll.
Thanks for double-checking, if you come up with any optimisations or improvements, feel free to share!
from cmdx.
Related Issues (20)
- cmdx.listRelatives always returns None HOT 18
- Plugs not taking and returning UI units HOT 4
- DagNode.addChild crashes in certain circumstances HOT 6
- Modifiers and data types HOT 2
- design proposition for components HOT 10
- attributes' default value not saved in scene HOT 3
- Support for proxy attributes
- DGModifier.disconnect and Undo
- Attribute reuse and undo
- Multiple versions simultaneously
- How to debug Maya crashes? HOT 9
- Deploy on CI HOT 1
- Direct passing of cmdx.Node to vanilla cmds HOT 3
- Support keyframing of pairBlended attributes
- Two users, one machine
- Thoughts on code formatter such as Black? HOT 5
- Set a nodes transform HOT 7
- Auto offset group
- Add type annotations HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmdx.