Animation copy script won't work on multiple selection

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2010   #1
Animation copy script won't work on multiple selection

Hey folks, I'm new to MAXScript and have created a simple bit of code to copy an object's animation and apply it to a new bone, which it is then skinned to.

Here's the code:
Code:
gunPart = $ gunBone = bonesys.createbone [0,0,0] [10,0,0] [1,1,1] gunBone.height=3 gunBone.width=3 gunBone.name = gunPart.name + "Bone" gunBone.position.controller = copy gunPart.position.controller deleteKeys gunPart.position.controller gunSkin=(skin()) addModifier gunPart gunSkin skinOps.addBone gunPart.modifiers[#Skin] gunBone 1


To to make it work with multiple objects that have been selected I just added this to it:
Code:
for i = 1 to selection.count do ( select selection[i] gunPart = $ gunBone = bonesys.createbone [0,0,0] [10,0,0] [1,1,1] gunBone.height=3 gunBone.width=3 gunBone.name = gunPart.name + "Bone" gunBone.position.controller = copy gunPart.position.controller deleteKeys gunPart.position.controller gunSkin=(skin()) addModifier gunPart gunSkin skinOps.addBone gunPart.modifiers[#Skin] gunBone 1 )


And it just gives me this error:
Code:
-- Error occurred in i loop; filename: C:\Work\3dsmax\MAXScript\boneCreatorMulti.ms; position: 57; line: 3 -- Frame: -- i: 2 -- No ""select"" function for undefined


I don't know what I'm missing here and any help would be greatly appreciated.
 
Old 12 December 2010   #2
the first time you enter the i loop, you are changing the selection to the first object selected.

So when it's time to enter the loop again, i is 2, and it is trying to access selection[2], which does not exist anymore, because the selection count is only 1.

do this instead:

Code:
theSel = selection as array for i = 1 to theSel.count do ( select theSel[i] gunPart = $ gunBone = bonesys.createbone [0,0,0] [10,0,0] [1,1,1] gunBone.height=3 gunBone.width=3 gunBone.name = gunPart.name + "Bone" gunBone.position.controller = copy gunPart.position.controller deleteKeys gunPart.position.controller gunSkin=(skin()) addModifier gunPart gunSkin skinOps.addBone gunPart.modifiers[#Skin] gunBone 1 )
 
Old 12 December 2010   #3
Awesome!

I can't believe I didn't see that, so simple.

Thanks man!
 
Old 12 December 2010   #4
Thread automatically closed

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.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:13 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.