乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 33|回复: 7

[编程交流] lisp to move text from it'

[复制链接]

2

主题

13

帖子

11

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:13:50 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 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
 
 
回复

使用道具 举报

2

主题

13

帖子

11

银币

初来乍到

Rank: 1

铜币
10
发表于 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
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 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.
 
171351xd06c8ds8kdckfso.jpg
回复

使用道具 举报

2

主题

13

帖子

11

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:50:49 | 显示全部楼层
Thank You, it works incredibly. I hope some day to return the favor.
 
Paul
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 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 ?
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 17:08:44 | 显示全部楼层
How about to copy it like this:
 

 
  1. (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)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 21:09 , Processed in 0.755159 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表