Mackinder
12-14-2010, 12:49 PM
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:
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:
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:
-- 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.
Here's the 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:
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:
-- 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.
