mottosso / cmdx

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

cmdx.DgNode: sample usage? #12

Closed benoit-fouletier closed 4 years ago

benoit-fouletier commented 4 years ago

I'm trying to use your declarative plugin syntax. I pasted your sample class, but then I'm not sure how to instantiate it?

I tried: node = cmdx.create_node(MyNode) but Maya complains: TypeError: '<class 'MyNode'>' is not a valid node type

I then tried: node = cmdx.create_node("MyNode") but now: TypeError: 'MyNode' is not a valid node type

I can simply do: node = MyNode() ... but then I don't know what to do with the node (how to register it in the DAG).

Apologies for being quite the Maya noob, so what I'm trying to do might be misguided. What I really want to do is create my own node type, so I can add it to the scene, and serialize it/store information in it. I'm not sure it's easily done, I could I guess use custom attributes for this, but I was looking for a more "strongly typed" approach.

Oh, and I believe there's a typo in your example, there's no MTypeId in cmdx, IMO it should be simply typeid = cmdx.TypeId(0x85006) (no M).

mottosso commented 4 years ago

Hi @benoit-fouletier, that is true the example doesn't include how to actually use it! My apologies. I've added some now, hope it helps.