View Full Version : Duplicate command

09 September 2010, 11:22 PM

I'm having problems returning an array of LONG names from the duplicate command.

For example:
- Create 2 spheres, pSphere1 and pSphere2
- Link pSphere2 to pSphere1
- Select them and run this MEL:

string $objs[] = `ls -l -sl`;
string $newObjs[] = `duplicate $objs`;
select $newObjs;

// Error: More than one object matches name: pSphere2 //

It fails to select as $newObjs is not returning the long name of the duplicate objects (only returns pSphere2). I don't see any flag from the duplicate command that would return the full path of their names. Is there some sort of trick to this that I'm missing?


09 September 2010, 08:27 AM
No trick to it, it just doesn't return the long name. What you end up doing is just defining the new objects after the duplicate on the basis that those duplicates are left selected

string $objs=`ls -sl -l`;
string $newObjs=`ls -sl -l`;

Or use Pymel ;)

09 September 2010, 05:51 PM
That seems to work good! Just need to make sure that the objects that are going to be duplicated are selected or it doesn't select the duplicates.

09 September 2010, 10:25 PM
string $dupCmd[] = (duplicate(`ls -sl -l`))
string $sel[] = `ls -sl -l`;

09 September 2010, 12:00 AM
Good too, thanks Nobert :)

09 September 2010, 12:30 PM
If you actually only want the resulting array, why create more? And why tell duplicate to do stuff it does by default? i.e.: duplicating whats selected:
string $objects[] = duplicate();
$objects = `ls -sl -l`;

CGTalk Moderation
09 September 2010, 12:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.