Jump to content

lisp to move text from it's insertion point to the nearest line endpoint


poffenberger

Recommended Posts

I have a very repetitive task where I move a single piece to the nearest line's endpoint. May need to do this hundreds of times in one drawing. Please see attachment. The red text is what needs moved to the nearest line's endpoint. If there was a way to automate this it would be greatly appreciated.

 

Thanks

Paulmove text to nearest endpoint.dwg

Link to comment
Share on other sites

Thanks so much for your reply.

 

I've loaded the pt manager and the txt to point code with no luck. Could I trouble you to help walk me thru this? Been using Cad for years but no experience with code.

 

Paul

Link to comment
Share on other sites

First I opened the Point Manager under input type select lw polyline then picked the individual lines to move the text to. Select points under output type and click ok. It should put points at the start and end points of the lines you selected.

 

Then use the txt2pt lsp and select the red text. Hit enter and they should all move. They are for me at least. Is this where you want them to move ?

 

You may need to go thru the help guide on the PT Manager to help navigate.

 

Capture.jpg

Link to comment
Share on other sites

I looked at this and a lisp can do it all in one go, I was just not sure exactly which line as the pline is on a layer you do a ssget using this layer from the text insertion point with a little search window and find the pline, get its mid point and then move the text to this point. Now I know which line exactly I will see if I can find time to do a auto solution. Do you want a constant offset still ?

Link to comment
Share on other sites

How about to copy it like this:

 

copytest.gif

 


(defun C:test ( / txt p1 blk p2 ralop SS i )
 (and 
   (setq txt (car (entsel "\nPick the source text: ")))
   (setq p1 (cdr (assoc 10 (entget txt))))
   (setq txt (vlax-ename->vla-object txt))
   (setq blk (car (entsel "\nPick the source \"BRKRFSW\" block: ")))
   (setq p2 (cdr (assoc 10 (entget blk))))
   (setq ralop (list (angle p2 p1) (distance p1 p2)))
   (princ "\nSelect \"BRKRFSW\" blocks to copy along: ")
   (setq SS (ssget '((0 . "INSERT")(2 . "BRKRFSW"))))
   (repeat (setq i (sslength SS))
     (vla-Move
       (vla-Copy txt)
       (vlax-3D-point p1)
       (vlax-3D-point (apply 'polar (cons (cdr (assoc 10 (entget (ssname SS (setq i (1- i)))))) ralop)))
     )
   )
 )
 (princ)
) (vl-load-com)

Link to comment
Share on other sites

Nice one Grr next task maybe something like add to top or add to bottom of text. Pick top line in the sample dwg "white text" then window select other text and redo as new text using top text insertion point. Make a list of text sort on Y val (( x y "4.3 afb")( x y "0.1 cal /" )) I am busy at moment else would do.

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