Max 2010 Array problem
Hey...
Been experiencing problems with max 2010 and maxscript. I started a script in max 2009, and now wanna run it in 2010. The problem occurs when I try to execute this kinda line:
for i in 1 to IK_CTRLs.count do IK_CTRLs[i].transform = spineLookatPoints[i].transform
it doesn't seem to do the transform.
Anybody else had similar problems??
Comments
The MaxscriptListener
The MaxscriptListener returns this:-
FreezeTransform()
sphereCon()
spineRig()
OK
OK
And the script looks like this:-
--freeze transform as function
fn FreezeTransform item =
(
local CurObj = item
if classof CurObj.rotation.controller != Rotation_Layer do
(
-- freeze rotation
CurObj.rotation.controller = Euler_Xyz()
CurObj.rotation.controller = Rotation_list()
CurObj.rotation.controller.available.controller = Euler_xyz()
/* "Localization on" */
CurObj.rotation.controller.setname 1 "Frozen Rotation"
CurObj.rotation.controller.setname 2 "Zero Euler XYZ"
/* "Localization off" */
CurObj.rotation.controller.SetActive 2
)
if classof CurObj.position.controller != Position_Layer do
(
-- freeze position
CurObj.position.controller = Bezier_Position()
CurObj.position.controller = position_list()
CurObj.position.controller.available.controller = Position_XYZ()
/* "Localization on" */
CurObj.position.controller.setname 1 "Frozen Position"
CurObj.position.controller.setname 2 "Zero Pos XYZ"
/* "Localization off" */
CurObj.position.controller.SetActive 2
-- position to zero
CurObj.Position.controller[2].x_Position = 0
CurObj.Position.controller[2].y_Position = 0
CurObj.Position.controller[2].z_Position = 0
)
)
--function for creating sphere control object
fn sphereCon Item wireColor nameCON=
(
shp = splineShape()
select shp
spln = addNewSpline shp
addKnot shp spln #bezierCorner #curve [4.99669,-1.71572e-006,3.43144e-006] [4.99669,-2.75711,3.43144e-006] [4.99669,2.7571,3.43144e-006]
addKnot shp spln #bezierCorner #curve [-1.93413e-006,4.99669,3.43144e-006] [2.7571,4.99669,3.43144e-006] [-2.75711,4.99669,3.43144e-006]
addKnot shp spln #bezierCorner #curve [-4.99669,-2.15254e-006,3.43144e-006] [-4.9967,2.7571,3.43144e-006] [-4.99669,-2.75711,3.43144e-006]
addKnot shp spln #bezierCorner #curve [-1.06048e-006,-4.99669,3.43144e-006] [-2.75711,-4.9967,3.43144e-006] [2.7571,-4.99669,3.43144e-006]
close shp spln
spln = addNewSpline shp
addKnot shp spln #bezierCorner #curve [-1.93413e-006,-1.71572e-006,-4.99669] [-1.93413e-006,-2.75711,-4.99669] [-1.93413e-006,2.7571,-4.99669]
addKnot shp spln #bezierCorner #curve [-1.71572e-006,4.99669,3.64985e-006] [-1.83624e-006,4.99669,-2.7571] [-1.5952e-006,4.99669,2.75711]
addKnot shp spln #bezierCorner #curve [-1.49731e-006,-2.15254e-006,4.9967] [-1.49731e-006,2.7571,4.9967] [-1.49731e-006,-2.75711,4.9967]
addKnot shp spln #bezierCorner #curve [-1.71572e-006,-4.99669,2.7762e-006] [-1.5952e-006,-4.9967,2.75711] [-1.83624e-006,-4.99669,-2.7571]
close shp spln
spln = addNewSpline shp
addKnot shp spln #bezierCorner #curve [4.99669,-1.71572e-006,3.43144e-006] [4.99669,-1.5952e-006,-2.7571] [4.99669,-1.83624e-006,2.75711]
addKnot shp spln #bezierCorner #curve [-1.93413e-006,-1.93413e-006,4.9967] [2.7571,-1.93413e-006,4.9967] [-2.75711,-1.93413e-006,4.9967]
addKnot shp spln #bezierCorner #curve [-4.99669,-1.71572e-006,2.99461e-006] [-4.9967,-1.83624e-006,2.75711] [-4.99669,-1.5952e-006,-2.7571]
addKnot shp spln #bezierCorner #curve [-1.06048e-006,-1.49731e-006,-4.99669] [-2.75711,-1.49731e-006,-4.99669] [2.7571,-1.49731e-006,-4.99669]
close shp spln
shp.thickness=.2
shp.sides=3
shp.steps=3
shp.displayRenderMesh=false
shp.transform = Item.transform
shp.name=nameCON
addModifier shp (xform())
shp.modifiers[#XForm].gizmo.scale *=[(Item.height*0.2),(Item.height*0.2),(Item.height*0.2)]
shp.wireColor = wireColor
converttosplineshape shp
updateShape shp
)
--Knots on spline =< SpineRez
fn spineRig CharName SpineRez =
(
global ChName = CharName+"_"
--collects objects
Hip = getnodebyname "Hip"
Hip_Null = getnodebyname "Hip_Null"
spineSpline = getnodebyname "spineSpline"
Head_Bone = getnodebyname "Head_Bone"
Head_Bone_Null = getnodebyname "Head_Bone_Null"
NeckArray = $Neck* as array
CTRL_Torso = getnodebyname "CTRL_Torso"
Head_Bone_Null.parent = undefined
in coordsys local rotate Head_Bone_Null (angleaxis -90 [1,0,0])
Head_Bone.parent = undefined
in coordsys local rotate Head_Bone (angleaxis -90 [1,0,0])
for i in NeckArray do i.parent = undefined
for i in NeckArray do in coordsys local rotate i (angleaxis -90 [1,0,0])
Head_Bone_Null.parent = Head_Bone
Head_Bone.parent = NeckArray[NeckArray.count]
for i in 1 to NeckArray.count do try(NeckArray[i].parent = NeckArray[i-1]) catch()
spineSplineLookat = copy spineSpline
move spineSplineLookat [0,0,(Hip.width*2.5)]
spineSplineLookat.name = (ChName+"spineSplineLookat")
spineSplineLookat.wirecolor = [135,6,6]
spineSpline.wirecolor = [135,6,6]
FreezeTransform CTRL_Torso
for i in NeckArray do FreezeTransform i
FreezeTransform spineSplineLookat
FreezeTransform Hip
FreezeTransform Hip_Null
FreezeTransform spineSpline
FreezeTransform Head_Bone
FreezeTransform Head_Bone_Null
--adds splineIK
addmodifier spineSpline (Spline_IK_Control helper_size:(Hip.width*4) linktypes:2)
spineSpline.modifiers[1].createHelper (spineSpline.modifiers[1].getKnotCount ()+1)
addmodifier spineSplineLookat (Spline_IK_Control helper_size:(Hip.width*4) linktypes:2)
spineSplineLookat.modifiers[1].createHelper (spineSplineLookat.modifiers[1].getKnotCount ()+1)
--creates points on spline IK
spinePoints = for i in 1 to (spineSpline.modifiers[1].getKnotCount ()) collect (getnodebyname ("Point0"+i as string))
spineLookatPoints = for i in 1 to (spineSpline.modifiers[1].getKnotCount ()) collect (getnodebyname ("Point0"+((i+spineSpline.modifiers[1].getKnotCount ()) as string)))
for m in 1 to spinePoints.count do spinePoints[m].name = ChName+"spinePoint_"+(m as string)
for i in 1 to spinePoints.count do spinePoints[i].wirecolor = [135,6,6]
for m in 1 to spineLookatPoints.count do spineLookatPoints[m].name = ChName+"spineLookatPoints_"+(m as string)
for i in 1 to spineLookatPoints.count do spineLookatPoints[i].wirecolor = [135,6,6]
--creates IK_CTRLs
for i in 1 to spinePoints.count do sphereCon Hip [135,6,6] (ChName+"CTRL_IK_Spine_"+(i as string))
IK_CTRLs = for i in 1 to spinePoints.count collect getnodebyname (ChName+"CTRL_IK_Spine_"+(i as string))
for i in 1 to IK_CTRLs.count do IK_CTRLs[i].transform = spineLookatPoints[i].transform
for i in 1 to IK_CTRLs.count do move IK_CTRLs[i] [0,0,(Hip.width*2.5)]
)
spineRig "T-Rex" 5
Maxscript seems to think it has done a good job, but the control objects "IK_CTRLs" havent moved to the right place.
i doubt this is it
i doubt this is it but...
isnt a for loop supposed to be
for i in myCrazyArray do
(
)
or if you need the index num
for i=1 to myCrazyArray.count do
(
)
no offense if u already knew that.
Your problem doesn't come
Your problem doesn't come from this line.
Open the MaxScriptListener, clear it, run the script and copy the results here.
(probably your array for some reasons is empty)
sinok.gr