This script to build bones based on selected objects works perfect if you are going to use it only once in the scene.
It gives error when using it again for the second time in the scene, apparently it is the way your array is built, as I do not have enough knowledge to solve it public here the question.
Is it possible to correct it to be able to use it as many times as one wants in a same scene?
[code]
fn creaHuesoEntreSelecciones ancho alto tapersito=
(
bns=#()
pts = selection as array
for i = 1 to pts.count-1 do
(
crearHuesos= bonesys.createbone (pts[i].pos) (pts[i+1].pos) [0,0,1]
crearHuesos.name = ("huesito_"+i as string)
)
creaHuesoFinal=bonesys.createbone (pts[pts.count].pos) (pts[pts.count].pos) [0,0,1]
creaHuesoFinal.name= ("huesito_"+pts.count as string)
bns = $huesito_* as array
pts= selection as array
bns.width= ancho
bns.Height= alto
bns.taper= tapersito
for i = 1 to bns.count do
(
if bns[i] != bns[1] then bns[i].parent = bns[i-1]
bns[i].position.controller =position_constraint()
bns[i].position.controller.appendtarget pts[i] 100
if bns[i]!= bns[bns.count] then bns[i].rotation.controller =lookAt_constraint target_axis:0 upnode_axis:2 StoUP_axis:2 lookat_vector_length:0 else bns[i].rotation.controller= Euler_XYZ()
if bns[i] != bns[bns.count] then bns[i].rotation.controller.appendtarget pts[i+1] 100 else 0
if bns[i]!= bns[bns.count] then bns[i].rotation.controller.pickupnode=pts[i] else 0
if bns[i]!= bns[bns.count] then bns[i].rotation.controller.upnode_world=false else 0
)
--ROTACION DEL HUESO FINAL
in coordsys bns[bns.count-1] bns[bns.count].rotation = eulerangles 0 0 0
--TAMAÑO DEL HUESO FINAL
bns[bns.count].length=bns[bns.count-1].length/20
bns[bns.count].width= bns[bns.count-1].width/20
bns[bns.count].height= bns[bns.count-1].height/20
select bns
)
rollout CreaCadenaEntreSelecciones "CreateBones"
(
spinner UI_width "width" range:[1,100,2]
spinner UI_height "height"range:[1,100,2]
spinner UI_taper "taper" range:[1,100,2]
button CreateBones "CreateBones"
on CreateBones pressed do
(
if selection.count > 0 then
(
creaHuesoEntreSelecciones (UI_width.value) (UI_height.value) (UI_taper.value)
)
else messagebox "Seleccione mas de un objeto"
)
)
createDialog CreaCadenaEntreSelecciones
[/code]
Replies