robertbon Posted June 4, 2015 Share Posted June 4, 2015 I have a text file containing thousands of coordinates, each with its own r,g,b color information (laser scan data, if you're interested), and I would like to be able to load them into AutoCAD. The filename suffix is .pts and has the following format (space separates values): x_coordinate y_coordinate z_coordinate intensity red green blue A few example lines of the data are: -2.069443 10.948227 -0.348312 464 203 164 167 -2.070145 10.951035 -0.348282 484 204 165 170 -2.069534 10.951004 -0.345657 582 196 152 153 -2.072372 10.961594 -0.348465 427 194 158 160 -2.071030 10.956039 -0.348373 323 200 161 166 -2.071915 10.958939 -0.348434 485 200 161 166 Can somebody help me with a lisp routine to select the .pts file and create points with the coordinates x,y,z and the point colour r,g,b? (the intensity column can be ignored) And what is the most efficient way to create these point, bearing in mind that there will be thousands in any text file? Any help, as always, gratefully received! Rob Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 4, 2015 Share Posted June 4, 2015 Hi Rob, Try the following: (defun c:ptin ( / des lst str txt ) (if (setq txt (getfiled "Select file" "" "pts;txt" 16)) (if (setq des (open txt "r")) (progn (while (setq str (read-line des)) (if (and (setq lst (read (strcat "(" str ")"))) (= 7 (length lst))) (entmake (list '(0 . "POINT") (list 010 (car lst) (cadr lst) (caddr lst)) (cons 420 (apply 'LM:RGB->True (cddddr lst))) ) ) ) ) (close des) ) (princ "\nUnable to open file for reading.") ) ) (princ) ) ;; RGB -> True - Lee Mac ;; Args: r,g,b - [int] Red, Green, Blue values (defun LM:RGB->True ( r g b ) (logior (lsh (fix r) 16) (lsh (fix g) (fix b)) ) (princ) RGB to True function is from my site here. Quote Link to comment Share on other sites More sharing options...
robertbon Posted June 7, 2015 Author Share Posted June 7, 2015 Thanks Lee, that's exactly what I was after! Rob Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2015 Share Posted June 7, 2015 You're welcome Rob - happy to help. 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.