poffenberger 发表于 2022-7-5 16:13:50

lisp to move text from it'

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

foster5476 发表于 2022-7-5 16:29:54

Actually, was able to make it work pretty nice using both of these. Point manager to set the points, then this text to point code to move the text.
 
http://lee-mac.com/ptmanager.html
 
http://www.cadtutor.net/forum/showthread.php?67654-Moving-Text-Block-to-adjacent-point&highlight=nearest+end+point
 
 

poffenberger 发表于 2022-7-5 16:33:58

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

foster5476 发表于 2022-7-5 16:43:54

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.
 

poffenberger 发表于 2022-7-5 16:50:49

Thank You, it works incredibly. I hope some day to return the favor.
 
Paul

BIGAL 发表于 2022-7-5 17:03:41

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 ?

Grrr 发表于 2022-7-5 17:08:44

How about to copy it like this:
 

 

(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)

BIGAL 发表于 2022-7-5 17:22:13

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.
页: [1]
查看完整版本: lisp to move text from it'