Spline Knot Position Array output as txt or print
1.Each 4 Spline as a group
2.Output Spline Knot Position (Pos.X Pos.Y Pos.Z )such as :
splinel.kont1.Pos.Y spline2.kont1.Pos.Y spline3.kont1.Pos.Y spline4.kont1.Pos.Y spline1.kont1.Pos.Z spline2.kont1.Pos.Z spline3.kont1.Pos.Z spline4.kont1.Pos.Z spline1.kont1.Pos.X spline2.kont1.Pos.X spline3.kont1.Pos.X spline4.kont1.Pos.X splinel.kont2.Pos.Y spline2.kont2.Pos.Y spline3.kont2.Pos.Y spline4.kont2.Pos.Y spline1.kont2.Pos.Z spline2.kont2.Pos.Z spline3.kont2.Pos.Z spline4.kont2.Pos.Z spline1.kont2.Pos.X spline2.kont2.Pos.X spline3.kont2.Pos.X spline4.kont2.Pos.X
......
The four spline Knot Position output order is 1、3、5、7...2、4、6、8...
The sample Spline.rar final is:-11.005 -13.772 -16.225 -10.059 0 0 0 0 3.694 -8.541 -12.463 -14.982 -11.005 -13.772 -16.225 -10.059 2.220 2.220 2.220 2.220 1.667 -8.541 -12.463 -14.982 -11.005 -13.772 -16.225 -10.059 4.439 4.439 4.439 4.439 1.667 -8.541 -12.463 -14.982 -11.005 -13.772 -16.225 -10.059 6.659 6.659 6.659 6.659 1.667 -8.541 -12.463 -14.982 .......
Please help Tanks!
Comments (12)
Comment policy
Please print the knot array such as the Attachment!
Thank you very much barigazy!
Attachments
Please print the knot array such as the Attachment
Thank you barigazy !!!
Attachments
I don't undertand your order. Why do you start with Y pos.
You mean like this?
#1 knot of each spline
s1.k1.pos.X | s2.k1.pos.X | s3.k1.pos.X | s4.k1.pos.X -- x pos
s1.k1.pos.Y | s2.k1.pos.Y | s3.k1.pos.Y | s4.k1.pos.Y -- y pos
s1.k1.pos.Z | s2.k1.pos.Z | s3.k1.pos.Z | s4.k1.pos.Z -- z pos
#2 knot of each spline
s1.k2.pos.X | s2.k2.pos.X | s3.k2.pos.X | s4.k2.pos.X
s1.k2.pos.Y | s2.k2.pos.Y | s3.k2.pos.Y | s4.k2.pos.Y
s1.k2.pos.Z | s2.k2.pos.Z | s3.k2.pos.Z | s4.k2.pos.Z
#3 knot of each spline
s1.k3.pos.X | s2.k3.pos.X | s3.k3.pos.X | s4.k3.pos.X
s1.k3.pos.Y | s2.k3.pos.Y | s3.k3.pos.Y | s4.k3.pos.Y
s1.k3.pos.Z | s2.k3.pos.Z | s3.k3.pos.Z | s4.k3.pos.Z
#4 knot of each spline
s1.k4.pos.X | s2.k4.pos.X | s3.k4.pos.X | s4.k4.pos.X
s1.k4.pos.Y | s2.k4.pos.Y | s3.k4.pos.Y | s4.k4.pos.Y
s1.k4.pos.Z | s2.k4.pos.Z | s3.k4.pos.Z | s4.k4.pos.Z
One software import need this order
#1 knot of each spline
s1.k1.pos.Y | s2.k1.pos.Y | s3.k1.pos.Y | s4.k1.pos.Y -- y pos
s1.k1.pos.Z | s2.k1.pos.Z | s3.k1.pos.Z | s4.k1.pos.Z -- z pos
s1.k1.pos.X | s2.k1.pos.X | s3.k1.pos.X | s4.k1.pos.X -- x pos
#2 knot of each spline
s1.k2.pos.Y | s2.k2.pos.Y | s3.k2.pos.Y | s4.k2.pos.Y
s1.k2.pos.Z | s2.k2.pos.Z | s3.k2.pos.Z | s4.k2.pos.Z
s1.k2.pos.X | s2.k2.pos.X | s3.k2.pos.X | s4.k2.pos.X
#3 knot of each spline
s1.k3.pos.Y | s2.k3.pos.Y | s3.k3.pos.Y | s4.k3.pos.Y
s1.k3.pos.Z | s2.k3.pos.Z | s3.k3.pos.Z | s4.k3.pos.Z
s1.k3.pos.X | s2.k3.pos.X | s3.k3.pos.X | s4.k3.pos.X
#4 knot of each spline
s1.k4.pos.Y | s2.k4.pos.Y | s3.k4.pos.Y | s4.k4.pos.Y
s1.k4.pos.Z | s2.k4.pos.Z | s3.k4.pos.Z | s4.k4.pos.Z
s1.k4.pos.X | s2.k4.pos.X | s3.k4.pos.X | s4.k4.pos.X
Thanks!
Here we go
Because output of this fn is the text file path you can at the and use this ...
... to open result in the maxscript editor
Thank you barigazy !
Your script is so cool !
Please print the knot array such as the Attachment!
Thank you barigazy!
Attachments
The spline selected on or off never mind !
This fn works only for your example (all splines must have same number of knots)
fn storeKnotsPosToTxt spl txtFile: =
(
if isKindOf spl Line or isKindOf spl splineshape do
(
fn breakUp arr idx = (if idx > arr.count do return #() ; for i = idx to arr.count collect arr[i])
fn roundP3 val = (for a in #("x","y","z") where abs (getProperty val a) < .0001 do (setProperty val a 0) ; val)
local fStream = createFile txtFile
local minKnots = amin (for s = 1 to numsplines spl collect numknots spl s)
local oddArr = #(), evenArr = #(), cnt = 1, coords = #()
while cnt <= minKnots do
(
kpos = (for s = 1 to numsplines spl collect roundP3 (getKnotPoint spl s cnt))
if mod cnt 2 != 0 then append oddArr kpos else append evenArr kpos ; cnt += 1
)
coords = #(oddArr, evenArr)
for arr in coords do
(
for i = 1 to arr.count do
(
while arr[i].count != 0 do
(
format "% % % %\n" arr[i][1].y arr[i][2].y arr[i][3].y arr[i][4].y to:fStream
format "% % % %\n" arr[i][1].z arr[i][2].z arr[i][3].z arr[i][4].z to:fStream
format "% % % %\n" arr[i][1].x arr[i][2].x arr[i][3].x arr[i][4].x to:fStream
arr[i] = breakUp arr[i] 5
)
)
)
flush fStream ; close fStream ; free coords ; free oddArr ; free evenArr
)
)
storeKnotsPosToTxt selection[1] txtFile:@"c:\temp\test.txt"
Thank you barigazy!
The script is so Perfect!
Yep. This function works only if you have spline shape object with 4,8,12,16 etc. splines but if you have different number then you need to change formating part in the code.
ok ,Tank you !