How can I clone an object in 3dsmax by maxscript without pop-out menu?

14.6k views Asked by At

How can I clone an object in 3dsmax by maxscript without showing the popup dialog?

The macro printed in maxscript listener when doing it manually is:

actionMan.executeAction 0 \" 40213\"  -- Edit: Clone
maxOps.cloneNodes $ cloneType:# instance newNodes:&nnl

There is a menu to choose the name of the new object, can I assign the name?

I know something like #noPromt can be used when Importing .3ds files.

2

There are 2 answers

0
Mario Morais On

One line solution

newNodes = for myobj in (selection as array) collect (instance myobj )

Change instance to copy or reference for clone type

3
IAmNoone On

This works for me without any dialog. I also added so that you can clone any number of selected objects, it will rename then uniquely, and add a number to the back of them (001,002 and so on). Just change the "changethis" to whatever you like.

--clone the selected objects
maxOps.cloneNodes (selection as array) cloneType:#instance newNodes:&nnl #nodialog

--Loop through the array of object it returns
for i = 1 to nnl.count do
(
    --rename the objects to a unique name
    nnl[i].name = uniqueName "changethis" numDigits:3
)