[Closed] Loft Twist from CSV
Does anyone know how I can import a CSV file into Max to specify a Twist value for a loft? I’ve scoured the tutorials and web for a solution, but I’m not sure what parameters to enter into maxscript in order to achieve this.
Thank you,
Adam
[b][b][size=2]From mem[size=2]ory:
MyCS[size=2]VFil[size=2]e = [/size][/size][/size]openFile[/b][/size][/b] @"c:\bla.[size=2]csv" [/size][b][b]mode[/b][/b]:"[size=2]r"
[size=2]DidNotHitEnd = [size=2]true
[size=2]Fi[size=2]leContents = ""[/size]
[/size][/size][/size]
While [/size][size=2][size=2][font='Courier New'][size=2][size=2]DidNotHitEnd do ([/size][/size][/size]
[/font][/size][b][b][size=2][font='Courier New'][size=2][size=2][size=2][size=2]Fi[size=2]leContents[/size][/size][/size][/size][/size] += readLine[/b][/font][/size][/b] [b][b][size=2]My[size=2]CS[size=2]VFil[size=2]e
[/size][/size][/size][/b][/size][/b]if [b][b][size=2][size=2][size=2][size=2][b][size=2][font='Courier New'][b]eof[/b][/b] [/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][b][size=2][font='Courier New'][b][size=2]My[size=2]CS[size=2]VFil[size=2]e then [/size][/size][/size][/b][/size][/b][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][b][size=2][font='Courier New'][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][size=2][size=2][font='Courier New'][size=2][size=2]DidNotHitEnd = false
[size=2])
closefile [/size][/size][/size][/size][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][b][size=2][font='Courier New'][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][size=2][size=2][font='Courier New'][size=2][size=2][size=2][b][size=2][font='Courier New'][b][size=2]My[size=2]CS[size=2]VFil[size=2]e
[/size][/size][/size][/b][/size][/b]ArrayOfCSV[size=2]values = [/size][/size][/size][/size][/font][/size][/size][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][b][size=2][font='Courier New'][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][size=2][size=2][font='Courier New'][size=2][size=2][size=2][size=2][size=2][b][size=2][font='Courier New'][b]filterString[/b][/b] [/size][/size][/size][/size][/size][/font][/size][/size][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][b][size=2][font='Courier New'][b][size=2][size=2][size=2][size=2][size=2][font='Courier New'][size=2][size=2][font='Courier New'][size=2][size=2][size=2][size=2][size=2][size=2][font='Courier New'][size=2][font='Courier New'][size=2][size=2][size=2][size=2]Fi[size=2]leContents [/size][/size][/size][/size][/size]"\"," [/font][/size][b][b]splitEmptyTokens[/b][/b][b][b]:[/b][/b]true[/size][/size]
[/size][/size][/size][/font][/size][/size][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][/font][/size][/size][/size][/size][/size][/b][/font][/size][/b][b][b][size=2]
[/b][/size][/b]
I thought you were just asking for help on how to get data. I’m not trying to write your script for you. There should be sufficient information in the help documentation of maxscript on how to apply your array to a series of values in an object but it’s going to take both you and me the same amount of time to find that information.
The sad short answer is – you cannot do that with MAXScript.
You can only access points of the twist curve if they already exist AND are animated.
You cannot create new ones to set them according to your file.
In that case, you can say
$Loft001.Def_twist.numsubs --> returns the number of points, default 2
$Loft001.Def_twist[1].value --> returns the first point's value as a Point3
$Loft001.Def_twist[2].value = [100,42,0] --set the second (last) point to +42
$Loft001.Def_twist[1].keys --> returns the anim.keys array of first point, e.g. #keys(0f, 100f)
$Loft001.Def_twist[1].keys[1] --> #Bezier Point3 key(1 @ 0f)
$Loft001.Def_twist[1].keys[1].time --> the key's time
$Loft001.Def_twist[1].keys[1].value --> the key's value
If you would pre-create and pre-animate as many keys as you have in the CSV file, you could set each one of them to the desired value, but you cannot create or delete the keys via MAXScript.
You will have to make sure all keys at all times are set to the same value to avoid animated twist over time (unless you want it to happen).
that’s true. the Loft is not creatable by mxs, and it doesn’t provide any interface to its editing.
but… is there really no way to code the Loft?
Thank you all for your replies. I was afraid of the truth, but thus are the limitations of maxscript. I often have between 300 and 400 definition points for a twist. I can make these points in excel, but I wanted a quicker method for entering them into MAX. It doesn’t seem like there is a good solution, so I’ll just continue plugging away at the data. I appreciate the help!
Adam