hotknife
06-25-2008, 10:45 AM
I have a script that reads a text file of xyz coordinates & creates dummy objects at these points. I have also read the max script help and got a 2nd script that creates a spline between 2 points. I am however having trouble marrying the 2 together to read a file, create a start & end point and join the 2 with a spline. If anyone could point my thicky head towards a no doubt simple solution I would be very gratefull. (scripts below)
cheers
Simon
script 1
-- open the file as text, read mode
f = openFile "c:\\temp\MeshOutputTest.txt" mode:"rt"
-- if it opened successfully (exists, etc)...
if f != undefined do
(
while not eof f do
(
-- Read a line from the file
l = readline f
-- turn that line into an array of strings using commas as delimiters
lf = filterString l ","
-- Create a Point3 from the array
p = [ lf[ 1 ] as Float, lf [ 2 ] as Float, lf[ 3 ] as Float ]
-- Make a dummy object using that point as pos
d = Dummy pos:p
-- Do whatever else you need to from here on out
-- ...
)
close f
)
script 2
fn drawLineBetweenTwoPoints pointA pointB =
(
ss = SplineShape pos:pointA
addNewSpline ss
addKnot ss 1 #corner #line PointA
addKnot ss 1 #corner #line PointB
updateShape ss
ss
)
newSpline = drawLineBetweenTwoPoints [10,20,30] [100,200,10]
cheers
Simon
script 1
-- open the file as text, read mode
f = openFile "c:\\temp\MeshOutputTest.txt" mode:"rt"
-- if it opened successfully (exists, etc)...
if f != undefined do
(
while not eof f do
(
-- Read a line from the file
l = readline f
-- turn that line into an array of strings using commas as delimiters
lf = filterString l ","
-- Create a Point3 from the array
p = [ lf[ 1 ] as Float, lf [ 2 ] as Float, lf[ 3 ] as Float ]
-- Make a dummy object using that point as pos
d = Dummy pos:p
-- Do whatever else you need to from here on out
-- ...
)
close f
)
script 2
fn drawLineBetweenTwoPoints pointA pointB =
(
ss = SplineShape pos:pointA
addNewSpline ss
addKnot ss 1 #corner #line PointA
addKnot ss 1 #corner #line PointB
updateShape ss
ss
)
newSpline = drawLineBetweenTwoPoints [10,20,30] [100,200,10]
