scampymoogin Posted October 10, 2011 Share Posted October 10, 2011 I have received a CAD file direct from specialist software that contains 3d polylines. The software I am using (Microdrainage Windes) accepts csv files so that I can create a 3d tin. What I am doing at the moment is painstakingly dividing the individual lines into a number of points (I don’t really care how many, it doesn’t have to be that accurate), once they have been divided I use the data extraction tool. So my questions are: · Is there any way to extract the 3d polyline information as individual points without dividing the line first. · Is there any way to divide multiple lines at once (lisp routine perhaps), · Can anybody think of a better way for me to do this. Any help really appreciated!! Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 10, 2011 Share Posted October 10, 2011 Hello! Try this quick one. It will process all the "Old style" polylines found in the drawing. Run it, copy the relevant part from the text screen (F2) and paste in Excel or even in Notepad. From there you can save as CSV. It should be simple to adjust the lisp to save directly in a CSV file, but I really don't have the time right now. Maybe tomorrow -if in the mean time you wont get better help. (defun c:test() (setq ss (ssget "X" (list '(0 . "POLYLINE")))) (princ (strcat "\n" (itoa (setq i (sslength ss))) " polilines found")) (repeat i (setq en (entnext (ssname ss (setq i (1- i)))) el (entget en)) (while (= (cdr (assoc 0 el)) "VERTEX") (setq a (mapcar 'rtos (cdr (assoc 10 el))) st (strcat (car a) "," (cadr a) "," (caddr a))) (princ (strcat "\n" st)) (setq el (entget (setq en (entnext en)))) ) (princ "\n") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
scampymoogin Posted October 11, 2011 Author Share Posted October 11, 2011 Thanks a lot for the reply! Is there any way I can specify how many points the polyline divides into. For example every 5m? Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 11, 2011 Share Posted October 11, 2011 This should work better. Don't divide the polylines; just run the Lisp and see in the CSV file the coords (defun c:Plist( / s ss file f i en el a st) ;| Grabs the 3DPolylines found in the drawing and saves the vertices in a CSV file mfuccaro@hotmail.com 11 Oct 2011 |; (setq s ",") ;separator can be ";" or "," -Change to suit ;(setq s ";") (setq ss (ssget "X" '((0 . "POLYLINE")(-4 . "&=")(70 . ))) (setq file (getfiled "Output file" (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 3)) "Csv" 5)) (setq f (open file "w")) (princ (strcat "\n" (itoa (setq i (sslength ss))) " polilines found \nX" s "Y" s "Z") f) (repeat i (setq en (entnext (ssname ss (setq i (1- i)))) el (entget en)) (while (= (cdr (assoc 0 el)) "VERTEX") (setq a (mapcar 'rtos (cdr (assoc 10 el))) st (strcat (car a) s (cadr a) s (caddr a))) (princ (strcat "\n" st) f) (setq el (entget (setq en (entnext en)))) ) (princ "\n" f) ) (close f) (setq s "File saved") ) Quote Link to comment Share on other sites More sharing options...
scampymoogin Posted October 11, 2011 Author Share Posted October 11, 2011 Thanks alot, that works. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 11, 2011 Share Posted October 11, 2011 You are more than welcome, Scampymoogin! Quote Link to comment Share on other sites More sharing options...
scampymoogin Posted November 16, 2011 Author Share Posted November 16, 2011 Bump. The solution above is dividing my 3d polyline at the points where the polyline has a change in its 3d value. When I import the csv file into my software the interpolation between the points isn't accurate enough. I am looking for a slight edit to the lisp above the divides the 3d polyline's in the CAD file into points every 5m. Having these extra points should give me the accuracy I need. Any Ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 17, 2011 Share Posted November 17, 2011 Fuccaro maybe just add a divide to the code to create POINTS plus vertice's as points then just write a full points list to a csv. Only question would be a inc factor. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted November 18, 2011 Share Posted November 18, 2011 Sorry for the delay, I had no time for programming these days. I rewrote the program, give it a try: (defun c:test( / sep f file ss pn) (setq sep ";") (setq f (getfiled "Output file" "" "CSV" 1) file (open f "w")) (setq ss (ssget "X" '((0 . "POLYLINE")))) (repeat (setq pn (sslength ss)) (pl1 (ssname ss (setq pn (1- pn))) file sep) (princ "\n" file) ) (close file) ) (defun pl1(en file sep / prev m el) (setq en (entnext en) el (entget en) prev nil) (while (= "VERTEX" (cdr (assoc 0 el))) (setq a (cdr (assoc 10 el))) (if prev (slice prev a file sep)) (setq prev a) (setq en (entnext en) el (entget en)) ) (setq m (mapcar 'rtos prev) m (strcat (car m) sep (cadr m) sep (caddr m) "\n")) (princ m file) ) (defun slice(x y file sep / dist n d1 d2 p) (setq m (mapcar 'rtos x) m (strcat (car m) sep (cadr m) sep (caddr m) "\n")) (princ m file) (setq dist 150) ;change here the desired distance (setq n (fix (/ (distance x y) (* 0.99 dist)))) (setq d1 (mapcar '/ (mapcar '- y x) (list n n n))) (setq i 0) (repeat (1- n) (setq i (1+ i)) (setq d2 (mapcar '* d1 (list i i i))) (setq p (mapcar '+ x d2)) (setq m (mapcar 'rtos p) m (strcat (car m) sep (cadr m) sep (caddr m) "\n")) (princ m file) ) ) Quote Link to comment Share on other sites More sharing options...
scampymoogin Posted December 1, 2011 Author Share Posted December 1, 2011 Thanks for the above reponse but it just outputs a blank csv file To confirm I am after a lisp routine that can pick up all the 3d polylines in a drawing and divide them into points every 5m. This is to save me using the divide command over and over again. Thanks for all your efforts and any more help will be gretaly appreaciated! Quote Link to comment Share on other sites More sharing options...
fuccaro Posted December 2, 2011 Share Posted December 2, 2011 Well, I just tested it in AutoCAD 2006 and it exported as expected all the 3DPolylines found in the drawing. Sorry if it doesn't work in AutoCAD 2011, it seems that you will have to wait somebody else -using up to day software- to help you. Are you sure that your drawing is made of 3dPolylines? Select one of them and see in the Properties window what it says. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted December 2, 2011 Share Posted December 2, 2011 I sent the lisp to a friend and he just sent me a positive feed-back; the program worked in AutoCAD 2012. Scampymoogin, is that CSV file *really* empty? Open it in Notepad. Quote Link to comment Share on other sites More sharing options...
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.