Something like this?
Code:(setvar "CECOLOR" (itoa (- (fix theElevation) 22)))


Registered forum members do not see this ad.
Hi,
How can i sort elevations in different colors for every metres while importing in autocad as block attribute from csv files.
eg. 500,200,23.1
200,300,23.5
400,700,24.2
350,240,25.3
In the above eg. my blocks when importing should have sorted (23.1,23.5 in as color 1) (24.2 in as color)...and so on.
Any help would be highly appreciated.
Regards
Something like this?
Code:(setvar "CECOLOR" (itoa (- (fix theElevation) 22)))
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3


thanks MSasu
I will do the same and let you know...
The above example will give you successive colors; if need to use from a list of preferred colors, then may try:
For sure, both examples consider 23.0 as reference elevation.Code:(setq colorElevations '("1" "23" "45" "67" "89")) (setvar "CECOLOR" (nth (- (fix theElevation) 23) colorElevations))
Also, may want to add a validation to don't exceed 255 as color index.
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3


thanks again
You're welcome!
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3


Hi Mircea,
Need help again to fit your code in the routine i have...
Then, you should post here the said code - please see the code posting guide.
May be useful to mark with a different color the changes that you already did.
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3


thanks below is the code...
For making this routine workable Mr.pBe helped me a lot.Code:(defun c:Bathy (/ tpath fd info Soundings Bs Bsc BSL Pdata data ipt ba tpt x y xs ys) (vl-load-com) (defun *error* (msg) (if msg (princ (strcat "\nError! " msg))) (princ) ) ;//pBe (defun _roundTruncated (a) (setq b (fix a) c (* (abs (- a b)) 10)) (if (= c 0) (setq d 0) (setq d (fix (+ c (/ c (abs c) 2.0)))))) (defun _HiLow (lev lev2 lst) (list (apply lev (mapcar 'car lst)) (apply lev2 (mapcar 'cadr lst)) )) ;// (defun colorelv (lev3 lst) (list (apply lev3 (mapcar 'caddr lst)))) (defun _errormsg ( lst / x ) (if (setq x (vl-some '(lambda ( x ) (if (null (eval (car x))) (cadr x))) lst)) (alert x) ) ) (setvar "cmdecho" 0) (graphscr) (if (and (setq Pdata nil tpath (getfiled "Select XYZ File" "*.*" "txt" 4)) (setq fsz (> (vl-file-size tpath) 0)) (setq Soundings (getfiled "Select Sounding Block" "*.*" "dwg" 4)) (progn (setq Bs (Getreal "\nScale factor for Bathymetry Block <1>:")) (if (= Bs Nil) (setq Bsc 1) (setq Bsc Bs))) ) (progn (setq fd (open tpath "r")) (setq Bsl (rtos Bsc 2 3)) (while (setq info (read-line fd)) (setq Pdata (cons (read (strcat "(" (vl-string-translate "," " " info) ")")) Pdata)) ) (close fd) (command "_.zoom" "w" (_HiLow 'min 'min Pdata)(_HiLow 'max 'max Pdata)) (foreach data Pdata (setq ipt (list (car data) (cadr data)) bat (atof (rtos (caddr data) 2 4)) tpt data) (if (< bat 0) (progn (setq ba (* -1 bat) x (fix ba) y (_roundTruncated bat)) (if (= y 10) (progn (setq x (+ x 1) y 0)) (progn (setq x x y y))) (setq xs (strcat "%%U" (itoa x)) ys (itoa y)) ) (progn (setq x (fix bat) y (_roundTruncated bat)) (if (= y 10) (progn (setq x (+ x 1) y 0)) (progn (setq x x y y))) (setq xs (itoa x) ys (itoa y)) )) (command "insert" Soundings "_scale" Bsl "_non" ipt 0 xs ys) ) ;(command "zoom" "e") (command "regen") ) (_errormsg '( (tpath "Failed to select Data File") (fsz "Bathy file is empty") (Soundings "Failed to select Block") ) ) ) (*error* nil) (princ) )
If require i will insert the block drawing too..
Regards
Aaryan
Registered forum members do not see this ad.
Presuming that Pdata variable store a list of 3D points and the entities inside your block have their color set as ByBlock, then adjust your code:
If there are elevations bigger than 277, then their color will be always red; may need to refine a little the alocation procedure.Code:(if (> (setq theColor (- (fix (caddr data)) 22)) 255) (setq theColor 1)) (command "_insert" Soundings "_scale" Bsl "_non" ipt 0 xs ys "_CHPROP" (entlast) "" "_C" theColor "")
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Bookmarks