Jump to content

Recommended Posts

Posted

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.

Posted
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?

Posted
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"

Posted
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

 

Posted
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.

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...