[maya] duplicating node networks

Hey guys!

Originally I asked this on cgsociety, but haven’t had any conducive replies.
In addition to my original text below, I looked into using assets/containers to duplicate a network, but also here all internal connections get lost when I duplicate the asset/container. :(:
If really necessary, I’ll write a script, but I want to rely on existing solutions where possible, at least for basic things like duplicating things.
Do you guys know a reliable way of doing this?:?:

here’s the original post:

My scene contains a cloth setup that allows me to change the mesh’s resolution/topology without having to rebuild the entire nCloth setup.

What I’m struggling with now is duplicating the whole setup, so that I can quickly create multiple pieces of cloth with the same rig.
I’ve had some success with duplicate special with the “duplicate input graph” flag turned on, but I end up duplicating too many things. for instance I don’t want to duplicate all the nRigid nodes that my cloth will be colliding with - I’d like to reuse the ones that the other cloth solver uses.
When this flag is off, my new cloth will still be constrained to the same nodes as the old cloth, even though I also duplicated the constraint’s targets.

So the tricky part is telling maya which nodes need to be duplicated and which need to be kept and piped into the new graph.
Is there a way to duplicate a graph so that all selected nodes maintain their relative connections to the new nodes, but also get connected to nodes that weren’t selected/duplicated?

I think this is a perfect example of when you WOULD want to use a script to duplicate something since you DO need to specify which nodes need to be duplicated and which not.

Hello Matt, Sacha,

On Cgtalk someone have mention to make a copy of your scene ,deleting unwanted node then merging it back where you need. Why is it not a “conducive reply”.If your nodes are " group" in an asset this setup is easy has you can list its content, remove from all node in maya some special item like scene configuration and delete the remaining junk.

Your best bet might be to build your setup in a separate scene, and reference in as many copies as you like.

In your separate scene, you’d have everything connected to one a single instance of a nucleus. Then, when they’re all referenced into your shot, you can re-target all of them into a local nucleus to that scene. Effectively reusing all colliders and other ncloth objects you might already have there.

It’s also a bit more friendly this way in case you’d like to make changes to your original setup and have those changes reflect to your other instances.

I have added Asset bugs 3 years on the trot.

Assets are a great concept but they fall over in many scenarios when you want to duplicate them or dynamically create them. I wanted to use them as a way to encapsulate maya files from a asset data base. I’d store paths in a DB (with other production data). Be it FBX, Collada or MA, MB files. Users would publish them into the db and after import I’d asset them up dynamically and store the metaData on them. This was for a game asset pipeline. We didn’t use referencing because of a cgfx issue and a general feeling that referencing was bad from the art guys. Also, when artist were dressing a scene and really busy they want simplicity. They wanted just a CTRL + D workflow once the asset was in Maya. (This was very important to them)

Duplicating a Asset with transform works, for a while. Then all of a sudden the materials would get screwed. Also any custom nodes would end up outside of the Asset, so the integrity of a Asset is a loose concept. Duplicate with inputs solved some of the problems but we only want 1 copy of a material. Including the material in the Asset solved the bad Material after x number of dups but wasn’t good for our export pipeline (multiple material issue). If the imported file was made of multiple objects the Black box feature runs a callback that makes the root the selected item. This is also a nice feature. I later noticed you can break a black box asset by changing the display mode in the outliner and duplicating them. Your duplicate is not an Asset. You’ve broken the asset apart by duplicating it. Also if you group the assets then duplicate them with the filter mode set to “Both” your assets get renamed with a prefix “_PrenotatoPerDuplicare”. Some of these issues may have been fixed, but I’ve not seen it on the woeful descriptive bug fix list. I just tried to duplicate a simple black box cube asset and the dup was black boxed but completely not black boxed. I had to toggle the state to get dup working correctly.

With so many issues that I wasn’t able to solve without serious bloated code or dev help I wrote my own system. In my case this was enough for the guys.

Also the asset command only works on short names (who writes code based on short names?). So dynamically creating assets was fine until I imported a file twice. Then this issue came up. The devs thought that you’d only create an asset in a single file and then save it for production. This meant ensuring all node names are unique before I ran the command.

In my opinion when you say Asset and then Black box. Maya should be asset aware, so duplicate should be asset aware too. Your essentially encapsulating your structure in concrete. I have 1 line of code in my system called .EncapsulateMAssetInMayaAsset(), One day I hope I can turn it on, but until then my MetaAsset works fine. I just don’t have the black box facility.

What can you do?

You write your own duplicate callback that __postDup is fixing your issues, that is if the other Asset duplicate issues no longer exist or you can create an asset that doesn’t have them.
You reference or import your asset multiple times.

-Dave

Hey guys - thanks for all the replies!

I’m still learning maya’s underlying philosophy, coming from 3dsmax, and this problem is keeping me busy for a while now and I have a hard time explaining it even to long-time maya-users.
Maybe my approach is not maya-esque or it’s not necessary grasp maya down to its guts to work with it efficiently.

The scenario that I’m trying to solve is this:
[ul]
[li]I play around with nCloth, or something similar and end up with a setup that I like.
[/li][li]I might have fiddled with the DG nodes a bit, so just duplicating the DAG nodes won’t cut it.
[/li][li]I want to duplicate that setup, to get more cloth-pieces or use it as a base and extend it.
[/li][li]For this, all selected nodes need to maintain their relative connections AND stay connected to unselected nodes without duplicating those
[/li][li]I need a solution that works on any DG/DAG setup, not just nCloth.
[/li][/ul]

I’m working on a script now to duplicate the entire graph and then delete former unselected nodes and rebuild the connections properly.
However this is quite complicated already. I need to work with callbacks to identify nodes that were created during the copy and I cannot duplicate DG nodes and DAG nodes in one operation.
With so many hoops to jump through, I get the impression that I’m approaching this from the wrong angle.

[QUOTE=mattanimation;16723]I think this is a perfect example of when you WOULD want to use a script to duplicate something since you DO need to specify which nodes need to be duplicated and which not.[/QUOTE]
I want the selected nodes to be duplicated - nothing else and I get that far with duplicate or assets, but it breaks most connections.

[QUOTE=cedricB;16726]On Cgtalk someone have mention to make a copy of your scene ,deleting unwanted node then merging it back where you need.[/QUOTE]
That seems like a more complicated way to achieve the same result as “duplicate special” with “duplicate input graph” enabled. I still need to go in, delete dozens of nodes and manually rebuild dozens of connections.

[QUOTE=marcuso;16730]Your best bet might be to build your setup in a separate scene, and reference in as many copies as you like.[/QUOTE]
In this case, I’m just copying the nodes as a base to build upon - a quick way to use one graph as the starting point for another. I might duplicate the solver, but want it to connect to the same colliders as the first solver.
In my attached screenshot from thinking particles, you can see how it keeps duplicated nodes connected relative to each other - I only need to rebuild reconnect nodes that weren’t duplicated. It’s not exactly what I need, but it allows for quick iteration and experimentation.

[QUOTE=thirstydevil;16734]What can you do?

You write your own duplicate callback that __postDup is fixing your issues, that is if the other Asset duplicate issues no longer exist or you can create an asset that doesn’t have them.
You reference or import your asset multiple times.[/QUOTE]
Yep, I’m working on that script now, but like I mentioned above, it seems like an unnatural way of working with maya, like I’m forcing it to do something that it’s not supposed to do.
Assets would’ve been exactly what I was looking for - if only they could be duplicated without falling apart. :frowning:

In my case, the duplicate scene process was the safer way to do it, and it was also less amount of scripting ( you can process this scene in a background maya batch mode ).

I have been working on a tool called Rigenerator for similar problems, however leaning more towards rigging. The idea was to do a rule based graph traversal and extract a network of nodes and recreate them. I have not tested it for very complex networks but it works for some basic tasks like extracting an IK arm rig from the full rig. I have not been able to work on this tool for many months now so it’s still unfinished, otherwise I would have liked to share it. Such tool would be very helpful because we can focus on creating the rig and then use Rigenerator to recreate it or get raw code ready to be converted into proper functions and scripts.