ok can you be more specific on how that actualy works ? i have to read the text file each milisecond and search for a min distance. if that distance is achieved then ad a new point to the spline right ? until the scrript detects the word End Spline in the text file ? how will the script read the text data each milisecond and update the spline and how the script will know when to stop that and start a new one ? i realy dont know how to do this.
To ansver this question I need know more details. I send u my contact.
about updating: you realy dont need update actions every milisecond
i think for god loking realtime visualization 25 fps is ok “thats mean update every 40ms”
the data would be something like this, but i cant delete it.
"Line01"
1 --Spline Count
7 --Spline Knot Count
false --Spline Closed?
--KNOT LIST FOR SPLINE 1
1, #corner, [-43.5], [-43.5], [-47.8]
2, #corner, [-56.4], [-52.1], [-58.1]
3, #corner, [-61.5], [-59.8], [-61.0]
4, #corner, [-60.0], [-60.5], [-59.1]
5, #corner, [-57.4], [-58.3], [-53.6]
6, #corner, [-46.1], [-49.9], [-38.5]
7, #corner, [-23.4], [-30.9], [-23.4]
-----------------
-- End Of File --
-----------------
i take this from an existing spline esport/import script
the only problem is that i cant erase something in the file so the Spline Knot Count would be a problem for updating , i can write any tipe of file , so tell me how you need it to be
ok u can start here:
- timer tick 1
- open and read file:
fn getFileText fPath =
(
if not doesFileExist fPath do return ""
local data = #()
local f = openFile fPath mode:"r"
while not eof f do
(
data += #(readLine f)
)
flush f
close f
return data
)
-
the last line is what you want, the rest is not important ,but if file is to big , the proces may to slow down, delete file and create it again or use
(f = openFile fPath mode:“w” ; close f) after u get data -
create a knot from last line data
-
to recognize begin and end of spline put markers in test file : etc… “Start” “End”
i hope is clear what I try to tel. You know my english is not to god
se you to morow Juan
- timer tick 2
i find this script for free hand spline creation, is there a way to edit it so it takes the information from a text file instead than from mouse move ?
[left]macroscript FreeSpline category:"HowTo" tooltip:"FreeSpline"
[/left]
[left](
[/left]
[left]local old_pos
[/left]
[left]local new_spline
[/left]
[left]local second_knot_set
[/left]
[left]
[/left]
[left]fn get_mouse_pos pen_pos old_pen_pos =
[/left]
[left](
[/left]
[left]if old_pos == undefined then old_pos = old_pen_pos
[/left]
[left]if distance pen_pos old_pos > 10 then
[/left]
[left](
[/left]
[left]if second_knot_set then
[/left]
[left]addKnot new_spline 1 #smooth #curve pen_pos
[/left]
[left]else
[/left]
[left](
[/left]
[left]setKnotPoint new_spline 1 2 pen_pos
[/left]
[left]second_knot_set = true
[/left]
[left])
[/left]
[left]old_pos = pen_pos
[/left]
[left]updateShape new_spline
[/left]
[left]) -- end if
[/left]
[left]) -- end fn
[/left]
[left]fn draw_new_line old_pen_pos =
[/left]
[left](
[/left]
[left]pickPoint mouseMoveCallback:#(get_mouse_pos,old_pen_pos)
[/left]
[left])
[/left]
[left]
[/left]
[left]undo"Free Spline"on
[/left]
[left](
[/left]
[left]new_spline = splineShape ()
[/left]
[left]old_pen_pos = pickPoint ()
[/left]
[left]if old_pen_pos == #RightClick then
[/left]
[left](
[/left]
[left]delete new_spline
[/left]
[left])
[/left]
[left]else
[/left]
[left](
[/left]
[left]select new_spline
[/left]
[left]new_spline.pos = old_pen_pos
[/left]
[left]addNewSpline new_spline
[/left]
[left]addKnot new_spline 1 #smooth #curve old_pen_pos
[/left]
[left]addKnot new_spline 1 #smooth #curve old_pen_pos
[/left]
[left]second_knot_set = false
[/left]
[left]draw_new_line old_pen_pos
[/left]
[left]q = querybox "Close Spline?" title:"Free Spline"
[/left]
[left]if q then
[/left]
[left](
[/left]
[left]close new_spline 1
[/left]
[left]updateshape new_spline
[/left]
[left])
[/left]
[left]select new_spline
[/left]
[left])--end else
[/left]
[left])--end undo
[/left]
[left])--end script
[/left]
is posible the data in textFile to look like this:
etc........
End --20
[-56.4], -52.1, -58.1] --19
[-61.5], -59.8, -61.0] --18
[-60.0], -60.5, -59.1] --17
[-57.4], -58.3, -53.6] --16
[-46.1], -49.9, -38.5] --15
Begin --14
undefined --13
undefined --12
undefined --11
undefined --10
undefined --9
End --8
[-43.5], -43.5, -47.8] --7
[-56.4], -52.1, -58.1] --6
[-61.5], -59.8, -61.0] --5
[-60.0], -60.5, -59.1] --4
[-57.4], -58.3, -53.6] --3
[-46.1], -49.9, -38.5] --2
Begin --1
This will be faster way of transfering.
if is dificult then we can do it anyway
the start and end chars don’t realy need. Undefined char symbolize the same.
etc…
undefined –20
[-56.4], -52.1, -58.1] –19
[-61.5], -59.8, -61.0] –18
[-60.0], -60.5, -59.1] –17
[-57.4], -58.3, -53.6] –16
[-46.1], -49.9, -38.5] –15
undefined –14
undefined –13
undefined –12
undefined –11
undefined –10
undefined –9
undefined –8
[-43.5], -43.5, -47.8] –7
[-56.4], -52.1, -58.1] –6
[-61.5], -59.8, -61.0] –5
[-60.0], -60.5, -59.1] –4
[-57.4], -58.3, -53.6] –3
[-46.1], -49.9, -38.5] –2
undefined –1
well, remember the text file isnt rewrightable, so it would be possible to use something like this ?
start --1
[-43.5], -43.5, -47.8] --2
[-56.4], -52.1, -58.1] --3
[-61.5], -59.8, -61.0] --4
[-60.0], -60.5, -59.1] --5
[-57.4], -58.3, -53.6] --6
[-46.1], -49.9, -38.5] --7
end --8
start --9
[-43.5], -43.5, -47.8] --10
[-56.4], -52.1, -58.1] --11
[-61.5], -59.8, -61.0] --12
[-60.0], -60.5, -59.1] --13
[-57.4], -58.3, -53.6] --14
[-46.1], -49.9, -38.5] --15
end --16
maybe we can get the same result if we tell the script to start reading from the last line readed so it doesn’t read all the file again.
This is a time-lapse supose it read the file each 20 miliseconds.
if u write the file in inverted order:
End –16
[-43.5], -43.5, -47.8] –15
[-56.4], -52.1, -58.1] –14
[-61.5], -59.8, -61.0] –13
[-60.0], -60.5, -59.1] –12
[-57.4], -58.3, -53.6] –11
[-46.1], -49.9, -38.5] –10
Begin –9
End –8
[-43.5], -43.5, -47.8] –7
[-56.4], -52.1, -58.1] –6
[-61.5], -59.8, -61.0] –5
[-60.0], -60.5, -59.1] –4
[-57.4], -58.3, -53.6] –3
[-46.1], -49.9, -38.5] –2
Begin –1
, is mutch more easy to read last data and avoid dupplicates.
and mutch more faster! –this is what u want?
after… to get the points of every spline u can use:
fn getLastSplineDataFrom filePath =
(
local f = openFile my_file mode:"r"
local str_data = #()
if (skipToString f "End") == undefined do return false
while not eof f do
(
local line = readLine f
--if line == "Start" do exit
if line == "Start" do -- case sensitive
(
flush f
close f
return str_data
)
str_data += #(line) -- mabe here need: #(execute line)
)
flush f
close f
return str_data --this wil return an array from 3Point values
)
fn createLineFrom arr_points =
(
if classOf arr_points != Array or arr_points.count == 0 do return false
local ss = SplineShape pos:arr_points[1]
addNewSpline ss
for i=2 to arr_points.count do
(
addKnot ss 1 #corner #line arr_points[i]
)
updateshape ss
)
createLineFrom (getLastSplineDataFrom "c:\ emp\\scan.dat")
if u can’t wrire in invert order let me know we can find other solution.
No i dont think i can write the file inverted, did you think is possible to do what i say ? to read only from the last readed line? or maybe the script can invert the file, i dunno… btw my icq is working again