Propain Posted November 11, 2009 Posted November 11, 2009 Hello to all! I started looking for topics regarding LISP because of an urgent need, so I am not familiar with it at all. I would like to ask if there is a routine that can open an ascii file, read the first two columns which are X and Y coordinates and draw circles with a radius taken from the third column. Also I would like to find a routine to read again Xa,Ya from the first two columns, Xb,Yb from the 3rd and 4th column and draw a line between them with a width given from the 5th line. I do not know if I am asking to much, but I did the same story manually for 2000 points and 6000 connection and just a few points before I was finished, computer crashed losing everything. I cannot do it again manually!!!! Any help is appreciated! Thank you very much in advance. Quote
David Bethel Posted November 11, 2009 Posted November 11, 2009 Your request isn't too hard but very specific. One of the secrets to this type of routine is the format of the ascii text. I suggest that use you use an autolisp format for the data if possible (12 34 5 67 89) (23 45 6 78 90) That way the routine can use (eval) and (read) to interpret the data easily. -David Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 Thank you very much for the reply. The problem is that I am looking for such a routine. I do not know how to make it myself this is why I am asking if anyone knows whether there is something already made. With your comment, you mean that instead of using columns, I should use rows? Quote
Freerefill Posted November 11, 2009 Posted November 11, 2009 If you've got it as a text file already, try using Excel or a find-replace to turn it into a .scr file. Quote
jammie Posted November 11, 2009 Posted November 11, 2009 If you've got it as a text file already, try using Excel or a find-replace to turn it into a .scr file. This would be my preffered way of importing the info I would like to ask if there is a routine that can open an ascii file, read the first two columns which are X and Y coordinates and draw circles with a radius taken from the third column. Not heavily tested, save the info as a CSV file (defun C:DrawCircle () (IF ;File to import (setq FileI (getfiled "Import Circle Data Files" "\nSelect file :" "csv;*" 2)) (progn (setq Stream (open FileI "r")) (while (setq String (read-line Stream)) ;Remova Commas (while (vl-string-search "," String ) (setq String (vl-string-subst " " "," String))) ;Convert to list (SETQ TempList (read (strcat "(" String ")"))) (setq BasePoint (list (car TempList) (cadr TempList))) (setq Radius (nth 2 TempList)) ;Create circle (entmake (list (cons 0 "circle") (cons 10 BasePoint) (cons 40 Radius) ) ) ) ;Close stream (close Stream) ) ) ) Quote
fixo Posted November 11, 2009 Posted November 11, 2009 Hello to all! I started looking for topics regarding LISP because of an urgent need, so I am not familiar with it at all. I would like to ask if there is a routine that can open an ascii file, read the first two columns which are X and Y coordinates and draw circles with a radius taken from the third column. Also I would like to find a routine to read again Xa,Ya from the first two columns, Xb,Yb from the 3rd and 4th column and draw a line between them with a width given from the 5th line. I do not know if I am asking to much, but I did the same story manually for 2000 points and 6000 connection and just a few points before I was finished, computer crashed losing everything. I cannot do it again manually!!!! Any help is appreciated! Thank you very much in advance. If your file is looks like space-separated lines of strings you can try another one: ;; convert string to list of strings (defun strlist (strExp strDel / strLst) (while (setq pos (vl-string-position (ascii strDel) strExp)) (setq itm (substr strExp 1 pos)) (setq strLst (append strLst (list itm))) (setq strExp (substr strExp (+ pos 2))) ) (setq strLst (append strLst (list strExp))) ) ;;by VovKa (defun readfile (fname / line) (if (setq line (read-line fname)) (if (eq "" line) (readfile fname) (cons ( strlist (vl-string-trim " " line) " ") (readfile fname)) ) ) ) ;main prog (defun C:demo() (setq fd (getfiled "Select a Text/Data File" (getvar "dwgprefix") "txt" ) (setq fname (open fd "R")) (setq data (readfile fname)) (close fname) (foreach item data (command "._circle" "_non" (list (atof (car item))(atof (cadr item)));point (atof (caddr item));radius ) ) (princ) ) (princ "\nType DEMO to execute") (princ) ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 Thank you all very much! I will try it and see what I can get. Thanks! Quote
fixo Posted November 11, 2009 Posted November 11, 2009 Thank you all very much!I will try it and see what I can get. Thanks! I need your data file for testing Can you upload it on http://www.yousendit.com or somewhere else and give me link on this file ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 I cannot upload links!!! Is there an email address to send them? Quote
fixo Posted November 11, 2009 Posted November 11, 2009 I cannot upload links!!!Is there an email address to send them? Ok, forget about yousendit.com What is the size of this file in zip form? Perhaps you can send it here partially Use "Manage Attacments" button below the message window ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 In pointA you will find three columns: Xa,Ya,diameter of the circle around Xa,Ya In pointB: Xb,Yb,diameter of the circle around Xb,Yb In connection A and B: the width of the connection between A and B. The same rows represent the same connection. This means that for row 1 in all files, (Xa,Ya) with diameter of the circle equal to the third column in pointA is connected to (Xb,Yb) and there is a circle with diameter equal to the third column of poinB and the connection has a width equal to the column in connection A and B. Looking through the rows you may find the same point more than once. This happens because each point is connected to more than one. If you get something, please let me know! pointΑ.zip pointΒ.zip connection A and B.zip Quote
fixo Posted November 11, 2009 Posted November 11, 2009 In pointA you will find three columns: Xa,Ya,diameter of the circle around Xa,YaIn pointB: Xb,Yb,diameter of the circle around Xb,Yb In connection A and B: the width of the connection between A and B. The same rows represent the same connection. This means that for row 1 in all files, (Xa,Ya) with diameter of the circle equal to the third column in pointA is connected to (Xb,Yb) and there is a circle with diameter equal to the third column of poinB and the connection has a width equal to the column in connection A and B. Looking through the rows you may find the same point more than once. This happens because each point is connected to more than one. If you get something, please let me know! OK I will write it but not so quickly as you want because of my mashine works slowly - it's very old one Oops I couldn't unzip pointA and pointB Just connection A and B was unzipped succesfully Please, resend pointA and pointB without compressing ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 Whatever you do is more than welcome and appreciated! Quote
fixo Posted November 11, 2009 Posted November 11, 2009 Whatever you do is more than welcome and appreciated! Please, resend pointA and pointB without compressing I don't like to work without existing files ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 It is impossible to send them without compressing because it will not let me. They are bigger than 50 Kb. The zip files are not working? Quote
Freerefill Posted November 11, 2009 Posted November 11, 2009 Since it's only a test, you can try sending only a few necessary pieces of each text file. That should reduce the size a lot. Quote
fixo Posted November 11, 2009 Posted November 11, 2009 It is impossible to send them without compressing because it will not let me.They are bigger than 50 Kb. The zip files are not working? I have a got an error message "Archive is lost" or "archive is hurt" (I can't translate it right) ~'J'~ Quote
fixo Posted November 11, 2009 Posted November 11, 2009 Since it's only a test, you can try sending only a few necessary pieces of each text file. That should reduce the size a lot. Agreed, thanks ~'J'~ Quote
Propain Posted November 11, 2009 Author Posted November 11, 2009 Here they are. pointΑ.txt pointΒ.txt connection A and B.txt Quote
fixo Posted November 11, 2009 Posted November 11, 2009 Here they are. Ok, it's much better I will be back in 1 hour or so ~'J'~ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.