How can i duplicate DG node to use maya api?

918 views
Skip to first unread message

ktj428

unread,
Aug 18, 2014, 4:55:36 AM8/18/14
to python_in...@googlegroups.com


  Hello

  first my English is not good... ^^;; sorry about my english..

  My question is that.

  I want to copy any dependency node.

  It seems like to use duplication command in Mel or Python command.
  
  If it is DAG node, MFnDagNode class will provide duplication function.

  But I couldn't find duplication function for dependency node in api document.

  How can i duplicate dependency node?
Message has been deleted
Message has been deleted

Janos Hunyadi

unread,
Aug 18, 2014, 5:37:26 PM8/18/14
to python_in...@googlegroups.com
Look into MFnMesh - copy to copy meshed

and

MDagModifier - createNode for the rest - attributes you have to copy them manually

J

ktj428

unread,
Aug 18, 2014, 10:16:11 PM8/18/14
to python_in...@googlegroups.com

thank you for your reply!!

I would like to know something..

If I use MDagModifier or MDGModifier, Do i have to connect all of value or plugs by myself???

Such as, if animation curve node is duplicated, does the new animation curve node get all of keyframes from source node after got them?

Does it same progress as duplicate command in Mel?

Janos Hunyadi

unread,
Aug 19, 2014, 12:49:24 PM8/19/14
to python_in...@googlegroups.com
You have to query, find and copy the values manually. You could run a mel command through MGlobal, and it will set up all the connections for you but that way you're getting out of the API, and you can only hope to trust maya that It's going to do what you would like to do :)

ktj428

unread,
Aug 20, 2014, 6:25:09 AM8/20/14
to python_in...@googlegroups.com
Ah.. so I have to copy all of values manually... It is not easy way ^^

thank you for your answer!!!

Marcus Ottosson

unread,
Aug 20, 2014, 6:45:48 AM8/20/14
to python_in...@googlegroups.com

Does it have to be using the API?

How about:

from maya import cmds
cmds.duplicate('MyNode')

It’s got flags to also copy connections, or to duplicate the nodes leading into it.



On 20 August 2014 12:25, ktj428 <ktj...@gmail.com> wrote:
Ah.. so I have to copy all of values manually... It is not easy way ^^

thank you for your answer!!!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fab722b6-9b5f-4f77-b10f-fd40a5b112e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

ktj428

unread,
Aug 21, 2014, 1:10:52 AM8/21/14
to python_in...@googlegroups.com

Yes, also python command is used for my project..

In my opinion, it is easy way to find solution. cmds.duplicate() is posiible to copy all of nodes in maya.

But I took a problem to speed, when I duplicate too many objects. So just i want to make a code for duplicate to use api..


Thank you for your advice. people are too kind ^^

Marcus Ottosson

unread,
Aug 21, 2014, 2:25:54 AM8/21/14
to python_in...@googlegroups.com
Ah, I see.

Well, for speed, it might help to export selected nodes or hierarchies and import them back in. That would essentially rely on Maya's serialisation/deserialisation mechanism for duplicating, which is pretty fast and solid.

You'd have a namespace to deal with if you do, but that shouldn't be much different from how you would otherwise have to take care of names by manually duplicating.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

ktj428

unread,
Aug 21, 2014, 10:48:58 AM8/21/14
to python_in...@googlegroups.com

  Wow It is awesome!! 

  Thank you for give me good solution!!!

  Your advice is possible to apply some of my projects..

  appreciate your answer!!

Marcus Ottosson

unread,
Aug 21, 2014, 11:03:35 AM8/21/14
to python_in...@googlegroups.com
No problem, glad to help!


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages