[Closed] Simple question, how to clone?
I am completely new to MS, and I have a quick question for you guys.
I want to take the object I have selected and clone it in place, NOT INSTANCE, and set the new objects name to something. I am having troubling finding the syntax to clone in the help files.
copy <array>
copy (selection as array) -- Copies the selection
The only problem with this is that it returns OK instead of the new objects that were created. A way to get the new objects is this:
sceneObjects = (objects as array) -- Get a snapshot of the scene before copying
copy (selection as array) -- Do your copies
newObjs = for obj in objects where (findItem sceneObjects obj) == 0 collect obj -- Compare with sceneObjects to figure out what the new objects are
…or you could just run the copying in a for loop. Copy on a single object returns the new object
sel = selection as array
for obj in sel do
(
thecopy = copy obj
thecopy.name = obj.name + "_COPIED"
)
Wow… your post is before mine… love it when that happens. Yeah sorry it’s not complicated enough, let me use some crazy dotnet stuff to loop through every vertex checking for floating point errors after the copy. 😈
lol, thanks guys. I am going through a DVD and haven’t gotten to array stuff yet, so I was a bit worried about the first answer, but I am itching to put a script together and couldn’t wait!
Or just use the built in maxOps.CloneNodes:
[left]<bool>maxOps.CloneNodes <&node array>nodesoffset:<point3>expandHierarchy:<boolean> cloneType:<enum> actualNodeList:<node array> newNodes:<node array>
[/left]
[left]This method will return true if successful, otherwise it will return false.
[/left]
[left]<&node array>nodes
[/left]
[left]This is the list of nodes that you want to clone. nodes is In parameter.
[/left]
[left]<&point3>offset
[/left]
[left]The positional offset that will be applied to the cloned nodes. offset is In parameter.
[/left]
[left]expandHierarchy:<boolean>
[/left]
[left]expandHierarchy default value: false
[/left]
[left]Indicates if children will be cloned in hierarchies. Default is false.
[/left]
[left]cloneType:<enum>
[/left]
[left]cloneType enums: {#copy|#instance|#reference}
[/left]
[left]cloneType default value: #copy
[/left]
[left]actualNodeList:<node array>
[/left]
[left]actualNodeList default value: #()
[/left]
[left]This node array will be filled in with the original nodes to be cloned. The reason for this is that there can be dependencies between nodes that causes other nodes to be added to the list. For example light/camera targets, nodes part of systems, part of groups or expanded hierarchies etc.
[/left]
[left]newNodes:<node array>
[/left]
[left]newNodes default value: #()
[/left]
[left]This node array will be filled in with the new cloned nodes. There is a one to one relationship between the nodes returned in the actualNodeList array and the newNodes array.
theArr = selection as array
maxOps.CloneNodes &theArr cloneType:#copy actualNodeList:&oldArr newNodes:&newArr
The original selection will be passed to the oldArr array and the copies will be passed to the newArr array. From there you could loop through newArr and do what you want to the names.
-Eric
[/left]