Jump to content

Move text to end of a line or polyline (multiple texts and multiple lines)


Noor-Cad

Recommended Posts

Hi All,

I am looking for a lisp code that will move all the selected texts VERTICALLY to the polyline or move the text to the end of the lines or polylines on which they are present.

I have attached a drawing explaining the methods I am using and request for some way to reduce the steps involved. As I have lots of drawings to work.

Thanking you allMOVETEXT.dwg

Link to comment
Share on other sites

@Noor-Cad Give this a try. It will maintain the differing Z vales of your text.
 

(defun c:foo (/ ln o p pl s txt)
  ;; RJP » 2024-06-24
  (cond	((setq s (ssget ":L" '((0 . "*TEXT,LWPOLYLINE"))))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (if (= "AcDbPolyline" (vla-get-objectname (setq o (vlax-ename->vla-object e))))
	     (setq pl o)
	     (setq txt (cons (list o (vlax-get o 'textalignmentpoint)) txt))
	   )
	 )
	 (if pl
	   (foreach tx txt
	     (setq ln (entmakex	(list '(0 . "LINE")
				      (cons 10 (cadr tx))
				      (cons 11 (mapcar '+ (cadr tx) '(0 1 0)))
				      '(8 . "TEMPLINE")
				)
		      )
	     )
	     (vla-put-elevation pl (last (cadr tx)))
	     (if (setq p (vlax-invoke (vlax-ename->vla-object ln) 'intersectwith pl 3))
	       (progn (vlax-put (car tx) 'textalignmentpoint p) (entdel ln))
	     )
	   )
	 )
	)
  )
  (princ)
)

2024-06-24_16-22-08.thumb.gif.dbf6b936da5b2210bd87a7d49d75ebb7.gif

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

On 6/25/2024 at 1:23 AM, ronjonp said:

@Noor-Cad Give this a try. It will maintain the differing Z vales of your text.
 

(defun c:foo (/ ln o p pl s txt)
  ;; RJP » 2024-06-24
  (cond	((setq s (ssget ":L" '((0 . "*TEXT,LWPOLYLINE"))))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (if (= "AcDbPolyline" (vla-get-objectname (setq o (vlax-ename->vla-object e))))
	     (setq pl o)
	     (setq txt (cons (list o (vlax-get o 'textalignmentpoint)) txt))
	   )
	 )
	 (if pl
	   (foreach tx txt
	     (setq ln (entmakex	(list '(0 . "LINE")
				      (cons 10 (cadr tx))
				      (cons 11 (mapcar '+ (cadr tx) '(0 1 0)))
				      '(8 . "TEMPLINE")
				)
		      )
	     )
	     (vla-put-elevation pl (last (cadr tx)))
	     (if (setq p (vlax-invoke (vlax-ename->vla-object ln) 'intersectwith pl 3))
	       (progn (vlax-put (car tx) 'textalignmentpoint p) (entdel ln))
	     )
	   )
	 )
	)
  )
  (princ)
)

2024-06-24_16-22-08.thumb.gif.dbf6b936da5b2210bd87a7d49d75ebb7.gif

Excellent !

Thank you Ronjonp

Link to comment
Share on other sites

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