aaryan Posted June 1, 2012 Posted June 1, 2012 Hi All, I am quite new to an autolisp programming and trying to make a lisp routine which reads xyz from external file and import its z value as a block attribute. So far i've reached is as follows. (defun c:bthy (/ tpath fd info Bs Bsc BSL eas nor ipt ba tpt x y xs ys) (setq tpath (getfiled "Select XYZ File" "*.*" "" 4)) (setvar "cmdecho" 0) (graphscr) (setq fd (open tpath "r") info (read-line fd) ) (if (/= info nil) (progn (setq Soundings (getfiled "Select Bathymetry Block" "*.*" "dwg" 4)) (setq Bs (Getreal "\nScale factor for Bathymetry Block <1>:")) (if (= Bs Nil) (setq Bsc 1) (setq Bsc Bs) ) ) (progn (alert "Bathy file is empty") (exit)) ) (setq BSL (rtos Bsc 2 3)) (while (/= info nil) (setq eas (atof (substr info 1 10)) nor (atof (substr info 12 11)) ipt (list eas nor) ba (atof (substr info 24 5)) tpt (list eas nor ba) x (fix ba) y (fix (* (- ba x) 10)) xs (itoa x) ys (itoa y) ) (command "insert" Soundings ipt BSL BSL 0 xs ys) (setq info (read-line fd)) ) (close fd) (COMMAND "zoom" "0.8x") (COMMAND "regen") (princ) ) Here is the dwg for Block. [ATTACH]35101[/ATTACH] A file for this code should contain a line as (eg. 500000.000,2150000.000,23.5) any delimiter can be used but X and Y decimal must be 3 and for Z it must be 1. My request and question here is: 1, i always get a text file which has easting northing and elevation with different decimals on every line, how can i make my code to read the file as i get without changing its decimals from excel. 2, I also get files which includes elevations as positive and even negative (i.e 500000.23, 2154356.355, -25.1 and 500101.2, 2155389.24, 24.1), how can i filter all negatives (-) and insert as (%%.1). 3, Can i give colors for different values as interval in interger given by user.. I hope i am not expecting too big but Please i need help. Thanks and Regards Sorry by mistake i have posted the thread two times Please ignore the previous one. Quote
BIGAL Posted June 4, 2012 Posted June 4, 2012 moderator this is twice http://www.cadtutor.net/forum/showthread.php?69781-Help-(List)-to-quot-string-quot 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.