Question. How can I simplify adding knots to spline using for loop so they can animate?
--Hello,
--I was wondering if someone could give me some advice on how to simplify the last section of this script.
--the script creates a spline with all the knots positioned at the first array value.
--The challenge is setting up the controllers for the knots. This example works but I need to simplify the last part to handle possibilty of greater than 4 values in the array.
--Does anyone have suggestions? If You run this script as I have it just drag only the point helpers to change the spline.
--
--I attached this script to this post if you cant select all and copy paste into your --maxscript editor
resetMaxFile #noPrompt
myarray = #([0,0,20],[20,0,20],[40,0,20],[60,0,20]) --total number of items in array varies. I use 4 items for testing
ScanTail = splineShape name:"ScanTail_Spline" wirecolor:blue --create spline
addnewSpline ScanTail
-------------------------------------------------
m = 0
for m in 1 to myarray.count do
(
addknot ScanTail 1 #smooth #curve myarray[1] ---creates a bunch of knots on spline based on the total number of values in array and place all of them at the 1st value in the array
)
updateShape ScanTail
animateVertex ScanTail #all
-----------------------------------------------
u = (myarray.count * 3) --total number of values in the array * 3 gives you the total number of X,Y Z point controllers you need to make in this loop
for m = 2 to u by 3 do
(
ScanTail[#Object__Editable_Spline][#Master][m].controller = Point3_XYZ()
)
----------------------------------------------------------------------------------------------SECTION BELOW NEED TO SIMPLIFY
-----------Create Point Helpers for all knots on the spline
for s in 1 to myarray.count do
(
nm = "ScanTail_Helper_" + s as string
PointHelperObj name:nm pos:[0,0,0] size:258 centermarker:true axistripod:false cross:false drawnontop:true wirecolor:green
)
--------------------------------This section works but is limited to 4 helpers. I need to simplify it
(
for i = 1 to 3 by 1 do (ScanTail[#Object__Editable_Spline][#Master][2].controller[i].controller = $ScanTail_Helper_1.position.controller[i].controller)
--------------------------------------------------------------------------------------
for i = 1 to 3 by 1 do (ScanTail[#Object__Editable_Spline][#Master][5].controller[i].controller = $ScanTail_Helper_2.position.controller[i].controller)
--------------------------------------------------------------------------------------
for i = 1 to 3 by 1 do (ScanTail[#Object__Editable_Spline][#Master][8].controller[i].controller = $ScanTail_Helper_3.position.controller[i].controller)
------------------------------------------------------------------------------------
for i = 1 to 3 by 1 do (ScanTail[#Object__Editable_Spline][#Master][11].controller[i].controller = $ScanTail_Helper_4.position.controller[i].controller)
)
max zoomext sel all
--I attached this script to this post if you cant select all and copy paste into your --maxscript editor
Attachment | Size |
---|---|
movesplineknotstoadjustspline.ms | 2.79 KB |
Comments
.
you can use <code> ... </code> tag to put your code in