Robinbb Posted March 18, 2020 Posted March 18, 2020 Hello Everyone! I am using vanilla AutoCAD 2017. I have recently done a hydrographic survey, so I have a drawing full of depths (text). Wondering if anyone can point me to a lisp routine that can color code the text based on a range. For example any depths between 10 and 20 is green or any depths between 20 and 30 are red. Thanks in advance. Quote
dlanorh Posted March 18, 2020 Posted March 18, 2020 30 minutes ago, Robinbb said: Hello Everyone! I am using vanilla AutoCAD 2017. I have recently done a hydrographic survey, so I have a drawing full of depths (text). Wondering if anyone can point me to a lisp routine that can color code the text based on a range. For example any depths between 10 and 20 is green or any depths between 20 and 30 are red. Thanks in advance. Simple enough, what layer is the text on, is there any other text on this layer, is the depth denoted with minus sign and is it just Text or is MText or both? Quote
Robinbb Posted March 18, 2020 Author Posted March 18, 2020 16 minutes ago, dlanorh said: Simple enough, what layer is the text on, is there any other text on this layer, is the depth denoted with minus sign and is it just Text or is MText or both? No other text is on the layer and the depths are Text and denoted with a minus sign and on layer "$SHTXT_GRID" Quote
dlanorh Posted March 18, 2020 Posted March 18, 2020 36 minutes ago, Robinbb said: No other text is on the layer and the depths are Text and denoted with a minus sign and on layer "$SHTXT_GRID" OK, try this ;; Autocad colors 1 = red 2 = yellow 3 = green 4 = cyan 5 = blue 6 = magenta 7 = white (defun c:depthtext ( / ss cnt obj depth) (setq ss (ssget "_X" '((0 . "TEXT")(8 . "$SHTXT_GRID" )))) (cond (ss (repeat (setq cnt (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))) depth (atof (vlax-get-property obj 'textstring)) ) (cond ( (< -10.0 depth 0.0)) ; do nothing ( (< -20.0 depth -10.0) (vlax-put-property obj 'color 3)) ; 3 is Green ( (< -30.0 depth -20.0) (vlax-put-property obj 'color 1)) ; 1 is Red ( (< -40.0 depth -30.0)) ; do nothing ) ) ) ) ) Any problems let me know. I'll be around for the next couple of hours Quote
Robinbb Posted March 18, 2020 Author Posted March 18, 2020 6 minutes ago, dlanorh said: OK, try this ;; Autocad colors 1 = red 2 = yellow 3 = green 4 = cyan 5 = blue 6 = magenta 7 = white (defun c:depthtext ( / ss cnt obj depth) (setq ss (ssget "_X" '((0 . "TEXT")(8 . "$SHTXT_GRID" )))) (cond (ss (repeat (setq cnt (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))) depth (atof (vlax-get-property obj 'textstring)) ) (cond ( (< -10.0 depth 0.0)) ; do nothing ( (< -20.0 depth -10.0) (vlax-put-property obj 'color 3)) ; 3 is Green ( (< -30.0 depth -20.0) (vlax-put-property obj 'color 1)) ; 1 is Red ( (< -40.0 depth -30.0)) ; do nothing ) ) ) ) ) Any problems let me know. I'll be around for the next couple of hours Thank you very much, this was exactly what I am looking for, I can work with this and edit it. Quote
BIGAL Posted March 20, 2020 Posted March 20, 2020 Has been asked before, some options number of color ranges determines the elevation range. Color is 1-255 / range for approx color number. If you have access to CIV3D "Rainbow" contour display is built in. 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.