View Full Version : Spline_IK_control: select the createhelper point

03 March 2009, 04:13 AM
when I created a spline_IK_control,and created 10 points, how I can use for loop to select the points and update their postion?
JHN give me the method

getProperty $.modifiers[1] #helper_list

Assuming modifiers[1] is the modifier. If you create a modifier in script you could also directly call the getProperty on the modifier like

getProperty theSplineIKMod #helper_list

Provided theSplineIKMod is the variable pointing to the modifier.

It will return an array of helpers, which you can use to apply the data to.

and what I want to do:
addModifier $MySpline01 SC
SC.createhelper 10
getProperty SC #helper_list
--dont know how to get the following through
with animation on
for i=1 to 10 do
read data from dat file
get point[i]
point[i].pos=readvalue of file


03 March 2009, 07:27 AM
theSpline = selection[1]
numSplinePoints = numKnots theSpline

-- I have no clue on how your data looks, so can't help with that.
-- I'm using a sample array of arrays to get data, will generate a 10 row array (time) in wich each row has 8 position values
timeStep = 10
dataArray = for t = 0 to 100 by dataArray collect for o = 1 to numSplinePoints collect [random -100 100,random -100 100,random -100 100]

sc = Spline_IK_Control()
addModifier theSpline sc
sc.createhelper numSplinePoints
thePoints = getProperty sc #helper_list

with animate on
for i = 1 to dataArray.count do -- time loop
--read data from dat file
for j = 1 to dataArray[i].count do -- data loop
at time ((i - 1) * timeStep) -- start at 0 (-1) and times (*) timeStep
thePoints[j].pos = dataArray[i][j]

I would recommend chewing on this a bit and read through the manual and on this forum about retreiving data from a file, there's plenty of info on that.
Also try to keep related posts in the same thread, you shouldn't have to create a new thread for each "clearly related to the original problem" request/question.

Hope this helps,


04 April 2009, 12:29 AM
Hi ,JHN , thanks for take time to solve my questions and I will take care next time;)
the data was created by random function ,but we can make it fuitable , isnt it?
here I give the link that the code to create the data I will use to animate the points

04 April 2009, 11:37 AM
My code as follow,when I excute it , it got a erro:
-- Compile error: Unexpected end-of-script
-- In line: 

theSpline = splineShape name:(uniqueName #MySpline) wirecolor:orange -- create a base spline
addNewSpline theSpline -- add a spline
for i = 1 to 10 do
addKnot theSpline 1 #smooth #curve [30*i,0,0] -- add some knots
updateShape theSpline -- Now draw the shape in the viewport
addModifier $MySpline01 SC
SC.createhelper 10
thePoints =getProperty SC #helper_list
with animate on(
f=getopenfilename types:"data(*.dat)|*.dat|all|*.*"
thefile=openfile f
for t = 0 to 100 by 5 do (
at time t
for i = 1 to thePoints.count do (
local theLine = readLine thefile
if (eof thefile) do ( seek thefile 0 )
local mySet
if (matchPattern theLine pattern:"set *") then (
mySet = (filterString theLine " ")[2] as integer
else if (matchPattern theLine pattern:"end set *") then ( )
else if (theLine == "") then ( )
else (
local myPoint3Array = filterString theLine " "
local myPoint3 = point3 (myPoint3Array[1] as float) (myPoint3Array[2] as float) (myPoint3Array[3] as float)
thePoints[i].pos += myPoint3

the data was created by random and the code was given by losbellos as follow
function writeout = (
extfile = createfile "d:/randomdata.dat"
for i= 1 to 44 do (
format "set %\n" i to:extfile
for k=1 to 500 do (
format "% % %\n" (random a b) (random a b) (random a b) to:extfile
format "end set %\n" i to:extfile
format "\n" i to:extfile
close extfile

some one can figure out why I got the erro ,thanks

CGTalk Moderation
04 April 2009, 11:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.