Clone Options (Instance Controllers)

I'm trying to write a code that does the equivelant of selecting and object and pressing Ctrl+V. Which brings up the Clone Options dialog.

I want to copy a selection of objects with the option of either copying or instancing the controllers of any possible objects.

In the max help I came across a few things and this was the closest which still did not have the option of the controllers.

maxOps.CloneNodes <&node array>nodes offset: expandHierarchy: cloneType: actualNodeList: newNodes:

I'm ultimately trying to copy a rig. My example scene consists of 3 spheres all just linked one to another so Sphere01 > Sphere02 > Sphere03.

Selecting all of them and then copying the rig with instanced controllers

function selectHierarchy = --//Selects both children/parents of obj's heirarchy
(
    for obj in selection do
    (
		if obj.children != undefined do
		(
			selectmore obj.children
		)
	)
)
 
for obj in selection do (
	CON = selection[1]
	selectHierarchy()
 
	newObj = copy obj
	newController = obj.controller 
 
	newObj.controller = newController
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

so is there an easy way to

so is there an easy way to retain the skinning of the newly copied object along with the controllers

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

I think its going to take a

I think its going to take a little more work than i expected.
With the initial copy (as seen in the attached image)
it retains hierarchy a skinny properties of the newly created copy.

Where as the copy method does not do that.....bummer

I've got it to retain hierarchy and whatnot but not the skinning.
This is what I've got so far.

numCopy = 4
 
fn fnFindCON = (
	for obj in selection do (
		if (findString obj.name "CON_") != undefined do
		return obj
	)	
)
CON = fnFindCON()
 
for i=1 to numCopy do
(
	maxOps.CloneNodes CON offset:[i*40,0,0] expandHierarchy:on cloneType:#copy actualNodeList:&anl newNodes:&nnl
)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

Hi John

Where is the problem with instance() function or maxOps.CloneNodes() function? As your clone type is #instance, your controllers will be instanced.

instance selection -- mapped
 
--OR...
 
maxOps.CloneNodes selection[1] \
expandHierarchy:on \ -- clone all children
cloneType:#instance \ -- instance them
actualNodeList:&srcNodes newNodes:&outNodes

my recent MAXScripts RSS (archive here)

JokerMartini's picture

It results in allowing the

It results in allowing the meshes or spline shapes to be copies but their controllers to be instances of each other.

So if I rotate the spline shape the one i copied it from also rotates.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

Image

Image attached to show what I'm after settings wise.

AttachmentSize
ctrlers.jpg 61.3 KB

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

i see...

so, you wish to instance transform controllers, its easy: $Obj1.controller = $Obj2.controller, but that will instancing whole transform (pos/rot/scale) tracks. If this is the case, you can do this step after cloning process - selection.controller = selection[1].controller, but if you whant to instancing to say just rotation tracks, then should supply more options to your tool. Ah, and if you do this, the process w'd a bit different 'cause subAnims are not mapped, for ex.: theTrack = selection[1][3][2].controller; for obj in selection do obj[3][2].controller = theTrack

hope this help

my recent MAXScripts RSS (archive here)

JokerMartini's picture

Yeah this definitely helps.

Yeah this definitely helps. It makes complete sense. I will start compiling things together and see what I come up with here.
Thanks Anubis for the explanation and help on this.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.