Apply elevation text to points/lines automatic from text

Apply elevation text to points/lines automatic from text

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

Apply elevation text to points/lines automatic from text

jocke.o92
Enthusiast
Enthusiast

Hello, folks. I have a question regarding automatic extraction of text and apply to points/lines.

Sometimes I get a drawing with text of elevation, points and lines. The biggest problem is that the points and lines doesn't have any Z value. That makes it painfully slow to not be able to extract the points/lines right away with correct Z value, so then I need do fill in every point with the elevation text.

So I was wondering if there is a way to do it "automatic" with maybe some lisp or some 3d plug in.
What I am looking for is something that would all elevation text and apply it to the nearest point and lines(if there are any).

 

So first step would be something like, put in radius around the points to search for text ex: 50 mm, and after that the plugin/lisp would apply the elevation text to points/lines that closest. If there would be clutter with points, I would just select all, reduce and move the text close to the point.

I will attatch a dwg just for an example.

I saw a demonstration in Trimble Business Center doing something like this. This would be a time saver if possible.
I can't code yet (learning now) or else I would have tried myself to figure it out.

0 Likes
Accepted solutions (2)
8,375 Views
8 Replies
Replies (8)
Message 2 of 9

TerryDotson
Mentor
Mentor
Accepted solution

Attached is your drawing converted to point blocks, I left your text and point objects in place so you can pan and compare.  This was done using DotSoft's MapWorks (an AutoCAD Add-In) that provides numerous methods of reassembling points.  In this case your node was a point object, it could have been crossing line objects and it could have still handled it.  Thousands of points could have been processed in only a few seconds. Here is an example of the dialog.

 

capture.png

0 Likes
Message 3 of 9

3wood
Advisor
Advisor
Accepted solution

You can also try ALTEXT and  use attached lsp file as its formula.

Result dwg as in the attachment.

ALTEXT3.gif

;;; This is an example formula for ALTEXT.vlx
;;; Select POINT and LINE nearby TEXT objects and change their z value to the number value of the text object.
(defun ALTEXT_FORMULA (/ b0 Bint d0 d1 D-Min e0 e1 fc1 i1 MaxPoint MinPoint old-osnap P1 P2 s1 s2 sc1 vc1 vh2 vobj vw2 vx1 vy1)
  (setq D-Min 2.0) ;This value defines the range around text insert point 
  (if (equal (cdr (assoc 0 ALTEXT_BLK_ENT)) "TEXT")
    (progn
      (setq old-osnap (getvar "OSMODE"))
      (setvar "OSMODE" 0)
      (setq vobj (vlax-ename->vla-object (cdar ALTEXT_BLK_ENT))) 
      (vla-getboundingbox vobj 'MinPoint 'MaxPoint)
      (setq
	MinPoint (trans (vlax-safearray->list MinPoint) 0 1)
	MaxPoint (trans (vlax-safearray->list MaxPoint) 0 1)
	)
      (vl-cmdf "._zoom" MinPoint MaxPoint)
      (vl-cmdf "._zoom" "0.8x")
      (setq vc1 (getvar "viewctr")
	    vx1 (car vc1)
	    vy1 (cadr vc1)
	    sc1 (getvar "screensize")
	    fc1 (/ (car sc1)(cadr sc1))
	    vh2 (/ (getvar "viewsize") 2.0)
	    vw2 (* vh2 fc1)
	    )
      
      (setq s1 (ssget "C" (list (- vx1 vw2) (- vy1 vh2)) (list (+ vx1 vw2) (+ vy1 vh2)) '((0 . "POINT"))))
      (if s1
	(progn
	  (repeat (setq i1 (sslength s1))
	    (setq i1 (1- i1))
	    (setq b0 (ssname s1 i1)
		  e0 (entget b0)
		  Bint (cdr (assoc 10 e0))
		  d1 (distance Bint (cdr (assoc 11 ALTEXT_BLK_ENT)))
		  )
	    (if (or (not d0) (< d1 d0))
	      (setq d0 d1
		    e1 e0
		    )
	      ) ;Find out the nearest point object
	    )
	  (entmod (subst (cons 10 (list (car Bint) (cadr Bint) (atof (vl-string-subst "." "," (cdr (assoc 1 ALTEXT_BLK_ENT)))))) (assoc 10 e1) e1))
	  (entupd (cdr (assoc -1 e1)))
	  )
	);Change point elevation
      
      (setq s2 (ssget "C" (list (- vx1 vw2) (- vy1 vh2)) (list (+ vx1 vw2) (+ vy1 vh2)) '((0 . "LINE"))))
      (if s2
	(progn
	  (repeat (setq i1 (sslength s2))
	    (setq i1 (1- i1))
	    (setq b0 (ssname s2 i1)
		  e0 (entget b0)
		  P1 (cdr (assoc 10 e0))
		  P2 (cdr (assoc 11 e0))
		  )
	    (if (< (distance P1 (cdr (assoc 11 ALTEXT_BLK_ENT))) D-Min)
	      (entmod (subst (cons 10 (list (car P1) (cadr P1) (atof (vl-string-subst "." "," (cdr (assoc 1 ALTEXT_BLK_ENT)))))) (assoc 10 e0) e0))
	      (entupd (cdr (assoc -1 e0)))
	      )
	    (if (< (distance P2 (cdr (assoc 11 ALTEXT_BLK_ENT))) D-Min)
	      (entmod (subst (cons 11 (list (car P2) (cadr P2) (atof (vl-string-subst "." "," (cdr (assoc 1 ALTEXT_BLK_ENT)))))) (assoc 11 e0) e0))
	      (entupd (cdr (assoc -1 e0)))
	      )
	    )
	  )
	);Change line elevation
      
      (vl-cmdf "._zoom" "p")
      (vl-cmdf "._zoom" "p")
      (setvar "OSMODE" old-osnap)
      nil
      )
    )
  )

 

0 Likes
Message 4 of 9

jocke.o92
Enthusiast
Enthusiast

I tried out the demo and it worked good! This is a good solution. Thank you!

0 Likes
Message 5 of 9

jocke.o92
Enthusiast
Enthusiast
This also work really good for me. I tried some examples of elevation data and it got good results. Thank you!
0 Likes
Message 6 of 9

shokitali1980
Contributor
Contributor

@3wood its not working in AutoCAD 2022

0 Likes
Message 7 of 9

pendean
Community Legend
Community Legend

@shokitali1980 wrote:

@3wood its not working in AutoCAD 2022


Elaborate with more details and information please: starting with how does it not work? Provide screenshots and more words please.

0 Likes
Message 8 of 9

shokitali1980
Contributor
Contributor
I copied code and saved as a lisp file and its loaded successfully in
AutoCAD but when im entering command ALTEXT its not showing in AutoCAD
0 Likes
Message 9 of 9

pendean
Community Legend
Community Legend

The code (ALTEXT_FORMULA is what you use to called it) you downloaded/copies is an add-on to ALTEXT (a for purchase, not free VLX that must be running first) from a few replies earlier.

pendean_0-1739805790522.png

 

Did you actually purchase ALTEXT then install/run it? Here is the page again 

https://sites.google.com/site/cadkits/home/altext

 

 

0 Likes