Jump to content

MAXscript Q: Copying groups..


quizzy
 Share

Recommended Posts

Use the maxops.clonenodes as shown in Maxscript reference below

Regards

Bill Wood

CloneNodes nodes offset: expandHierarchy: cloneType: actualNodeList: newNodes:

This method will return true if successful, otherwise it will return false.

nodes

This is the list of nodes that you want to clone. nodes is In parameter.

offset

The positional offset that will be applied to the cloned nodes. offset is In parameter.

expandHierarchy:

expandHierarchy default value: false

Indicates if children will be cloned in hierarchies. Default is false.

cloneType:

cloneType enums: {#copy|#instance|#reference}

cloneType default value: #copy

actualNodeList:

actualNodeList default value: #()

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.

newNodes:

newNodes default value: #()

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.

Notes:

actualNodeList and newNodes take an argument of , and are Out parameters. This is important because:

1) the variables should be passed by reference, and

2) we don't need to intitialize the variables to arrays since they are only Out parameters (MAXScript doesn't try to convert the value passed in to an array).

For example:

s=sphere()

-- variables not passed by reference, does not work rightmaxops.clonenodes s actualNodeList:a newNodes:b

a --> undefined

b --> undefined

-- variables passed by reference without initializing, works rightmaxops.clonenodes s actualNodeList:&c newNodes:&d

c --> #($sphere01)

d --> #($sphere03)

Also note that the first argument type is specifed as nodes, In parameter. Since it is an In parameter, we know that the method does not change the contents of the array passed, so there is no point in passing this array by reference.

In addition, MAXScript automatically wraps the single argument passed into a temporary array, so we can use s instead of #(s) to supply the node array.

WARNING: You may not use maxOps.cloneNodes inside an undo off context. Doing so will crash 3ds max when using the Undo function!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...