Add + sign to altitude/height of number text

Add + sign to altitude/height of number text

jocke.o92
Enthusiast Enthusiast
1,058 Views
8 Replies
Message 1 of 9

Add + sign to altitude/height of number text

jocke.o92
Enthusiast
Enthusiast

Hello

I got a 3d application that I export survey points of elevation to Autocad file. I export height and code. When exporting this heights the text is ex 24.001 and if it is under 0.00 it will print it out with a "-" like -24.001. So all negative elevations get a "-" infront of the height text but heights above 0 doesn't get a "+" sign. 

For most of the cases this work fine and there is no need to seperate them with the +, but sometime I need write out the + sign i front of all elevation above 0. This takes time to do i manually. 

So my question is, if there is a way to add a "+" sign to all z-values that are above 0? I have talked to the support of the 3d application and there is nog option to add + sign in export to dwg. 

And also if this could be applied to all text, Mtext, multileader and text?

0 Likes
Accepted solutions (2)
1,059 Views
8 Replies
  • text
Replies (8)
Message 2 of 9

pendean
Community Legend
Community Legend
Can you share a sample DWG file with these entries in them?
0 Likes
Message 3 of 9

jocke.o92
Enthusiast
Enthusiast

Here is an example 

0 Likes
Message 4 of 9

hak_vz
Advisor
Advisor
Accepted solution

Try this

 

 

(defun c:plus_sign_elev ( / ss o eo val)
(setq ss (ssget '((0 . "TEXT")(8 . "VG*"))) i -1)
(while (< (setq i (1+ i))(sslength ss))
(setq eo (vlax-ename->vla-object (ssname ss i)))
(setq val (atof (vla-get-textstring eo)))
(if (> val 0.0) (vlax-put eo 'TextString (strcat "+" (vla-get-textstring eo))))
)
(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)
(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 9

3wood
Advisor
Advisor
Accepted solution

You can also try ALTEXT to add prefix "+" in front of select numbers great than 0.00.

ALTEXT2.gif

0 Likes
Message 6 of 9

jocke.o92
Enthusiast
Enthusiast

This works perfect!

0 Likes
Message 7 of 9

jocke.o92
Enthusiast
Enthusiast

I tried this to and it works good :)!

0 Likes
Message 8 of 9

hak_vz
Advisor
Advisor

@jocke.o92 wrote:

This works perfect!


Glad to be of help! You have to be careful when using this script. It will collect all text entities from any layer whose name starts with "VG", In some other circumstances you will have to change selection filter. But if layer names are standard then this simple script will work without error. You can add this to your autolisp startup suite or assign to menu button.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 9 of 9

pbejse
Mentor
Mentor

@jocke.o92 wrote:

..
For most of the cases this work fine and there is no need to seperate them with the +, but sometime I need write out the + sign i front of all elevation above 0. This takes time to do i manually. 


(defun c:symbiotic (/ ss i e zed str)
  (if
    (setq ss (ssget '((0 . "MTEXT,TEXT"))))
     (repeat (setq i (sslength ss))
       (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
       (setq zed (last (vlax-get e 'Insertionpoint)))
       (setq str (vlax-get e 'Textstring))
       (if
	 (numberp (read str))
	 (vlax-put e
		   'Textstring
		   (strcat (if (minusp zed)  ""  "+" )
			   (rtos zed 2)
		   )
	 )
       )
     )
  )
  (princ)
)
0 Likes