Notifications
Clear all

[Closed] bones maxscript help

Hey,

I’ve been trying to copy a set of selected bones using max script, but im going in circles with either the [I] in boneSys is invalid or i can only copy one bone. can anyone help

heres what ive got:

for x in selection do
(
theBones=#(x.pos,(x.transform.row1*x.length+x.pos),(x.transform.row3),x.name)
test=#()
)

print test
append test theBones

fn createBones boAr=
(
nBones=#()
for i = 1 to boAr.count do
(
b=boneSys.createBone boAr[i][1] boAr[i][2] boAr[i][3]
b.name=boAr[i][4]
if i> 1 do
(
b.parent=nBones[nBones.count]
)
append nbones b
)
)
createBones test

Thanks!

4 Replies

I haven’t tested this (I’m not in front of max), but I think it’s failing because you reset “test” to be an empty array inside the “for x in selection” loop.

Try moving “test = #()” above “for x in selection”.

Hope that helps.

Cheers,

Drea

Hey thanks for the quick reply Drea. But sadly its still not working, it only picks up the last bone (the pip) and copys it.

I added the test array to hopfully collect all of the bones, without it i get an error with the index in bone.sys

Ill keep trying!

Havent been able to test yet (working some crunch here and waiting for someone) but i hope this will work. (edit:seems i screwed up the indenting, sorry edit nr2: fixed that bit)

test=#()
  for x in selection do
  (
  	theBones=#(x.pos,(x.transform.row1*x.length+x.pos)	,(x.transform.row3),x.name)
  	append test theBones
  )
  
  print test
  
  fn createBones boAr=
  (
  	nBones=#()
  	for i = 1 to boAr.count do
  	(
  		b=boneSys.createBone boAr[i][1] boAr[i][2] boAr[i][3]
  		b.name=boAr[i][4]
  		if i> 1 do
  		(
  			b.parent=nBones[nBones.count]
  		)
  		append nbones b
  	)
  )
  createBones test

Awesome, now works perfectly thank you for the help.