Creating polyline according to text file change

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm creating an AutoCAD .Net app that will enable me to draw objects (polyline and points at the moment) in AutoCAD.
I'm receiving real time informations from another program (.exe i can edit) via .txt file (maybe i will need to go from this format to a database ? but that's not the main point).
I have two text files :
- The first one is updating every time something change in the other program (e.g. when i start a new line, when i add a new vertex or when i close the line).
- The second one contain all the informations of the last created object once he is complete (e.g. type of object, coordinates, eof).
I'm able to open and read those files on every change without problem (uing fileSystemWatcher).
For the second file I don't have problem creating the given object because it contain all the needed informations.
My problem is that I don't know how to do it with the first file.
Indeed, when i start the creation of a new object in the other program, the first .txt file contain the type of object to creat (e.g. Point, Polyline,...). I'm curently able to send the right command to AutoCAD according to the type of the object (e.g. PLINE, POINT,...) but when the file update (and therefore contain the first point coordinates), i can't complete my previously launch command because at each file change i can see that there is 2 lines where it is written "*cancel*". I really would like this function to work cause it's the only way (I can see) to draw in real time from the external programm into AutoCAD.
Any idea how i can get it work ?
Thank you,
Bellow is the part of my code that is supposed to deal with the drawing part for the first text file :
(I just tried to draw the polyligne for the moment as i think it will be easy to draw other object if i can get this to work)
private async void dessinFichierTxt(Editor ed) { FileStream fs = new FileStream(path + "\\transferfile.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader sr = new StreamReader(fs); List<String> liste = new List<string>(); while (!sr.EndOfStream) liste.Add(sr.ReadLine()); try { if (liste[0] == "Distance") { await ed.CommandAsync("_.PLINE"); } else if (liste[0] == "X") { await ed.CommandAsync(String.Format("{0},{1} ", liste[1], liste[3])); } } catch (IOException e) { ed.WriteMessage("The file could not be read."); ed.WriteMessage(e.Message); } }