yorke67 Posted December 21, 2011 Posted December 21, 2011 Hi All I have been searching for a way of exporting multiple polyline or spline coordinates to txt file and all I can find is ones that write out as a single continuous list of coordinates with nothing denoting which one is which. I really need it to be able to export each polyline as a group, and I would also love for it to be able to include the number of points and name of the layer eg: polyline 'number of points' 'layername' 0.0 0.0 0.0 1.0 1.0 0.0 2.0 2.0 0.0 polyline 'number of points' 'layername' 0.0 0.0 0.0 1.0 4.0 0.0 2.0 8.0 0.0 and so on..... Any help with this would be much appreciated Quote
Tharwat Posted December 21, 2011 Posted December 21, 2011 My version .... (defun c:TesT (/ filename selectionset running integer selectionsetname points strings param ) (if (and (setq filename (getfiled "Save file as ... " (getvar 'dwgprefix) "txt" 1 ) ) (progn (prompt "** << Select Polylines to export their coordinates >> **" ) (setq selectionset (ssget '((0 . "POLYLINE,LWPOLYLINE")))) ) ) (progn (setq filename (open filename "w")) (repeat (setq integer (sslength selectionset)) (setq selectionsetname (ssname selectionset (setq integer (1- integer)) ) ) (setq running -1 points (1+ (abs (fix (vlax-curve-getendparam selectionsetname))) ) ) (write-line (strcat "Polyline" "\t" (itoa points) "\t" (cdr (assoc 8 (entget selectionsetname))) ) filename ) (repeat points (write-line (strcat (rtos (car (setq strings (apply 'list (vlax-curve-getpointatparam selectionsetname (setq running (1+ running)) ) ) ) ) 2 ) " " (rtos (cadr strings) 2) " " (rtos (caddr strings) 2) ) filename ) ) ) (setq filename (close filename)) ) (princ) ) (princ) ) Quote
yorke67 Posted December 21, 2011 Author Posted December 21, 2011 Thank you Tharwat that's brilliant!!! One thing I didn't think about though, is that the software I'm importing into uses flipped Y-Z coordinates, so is it possible to write out the coordinates : X Z Y as a simple way of getting around it? And it also requires a fixed value at the end, eg. 300. Sorry I should have been more descriptive in my first post which would have been more helpful, I guess I was just checking if it was achievable at that stage. Here is an example of the input required: polyline 6 layername [28915.3 0 11351.9 300] [28775 0 18893.1 300] [27149.8 0 19937.8 300] [16340.3 0 19834.8 300] [15175.2 0 18456 300] [15125.7 0 13593.9 300] Thanks again Quote
Tharwat Posted December 22, 2011 Posted December 22, 2011 You're welcome ... Check this link for more expansion of your request . http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Multiple-Polyline-Export-Challenge/td-p/3270377 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.