乐筑天下

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

[编程交流] Convert block+text -----> bloc

[复制链接]

17

主题

87

帖子

70

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 06:07:40 | 显示全部楼层 |阅读模式
Hi everybody,
 
I have a plan with 250 blocks with the same name.
and each block has a text with number (001,002,003,...248,249,250)
 
Now i would like to have a lisp to convert those text to attribute in his own block.
 
So maybe a lisp who ask to select a block...then select text....result block+ attribute.
 
Can anyone help me?
 
Many thanks!
 
Bono.
回复

使用道具 举报

51

主题

481

帖子

457

银币

后起之秀

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

铜币
262
发表于 2022-7-6 06:13:58 | 显示全部楼层
please upload a sample
 
I think that its better to edit the block then atta atribute in it then ATTSYNC the block then use this lisp to renumber the attribute.
http://www.theswamp.org/index.php?topic=40483.msg457902#msg457902
DONOT forget to delete the old text
回复

使用道具 举报

17

主题

87

帖子

70

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 06:14:31 | 显示全部楼层
But i really need to re-use my default text on the plan...
001,002,003 was a (bad) sample...In reality is something like that:
 
GFT001->003
GFT004->009
GFT010->013 .......
 
No logical sequence!!
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 06:18:43 | 显示全部楼层
its easy bono25, but i think you're going about it the wrong way. why not use one attribute block. instead of re-defining all 250 of them.
Can you explain this line ..
 
 
The TEXT and BLOCK are a separate entities? or the TEXT is already a part of the block?
回复

使用道具 举报

17

主题

87

帖子

70

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 06:21:26 | 显示全部楼层
TEXT and BLOCK are a separate entities
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 06:26:04 | 显示全部楼层
 
I see, and i suppose the TEXT entities are not always on the same spot in relation with the block? then you really need to do the transformation one by one, but then again, use one (1) attribute block.
 
Redefine the block [250 blocks with the same name.] to include the attribute entity.
Use a code to copy TEXT string to attribute.
 
  1. (defun c:cst (/ txt blk) ;; copy string(vl-load-com) (prompt "\nSelect Text to transfer:") (if (and (setq txt (ssget "_+.:S:E" '((0 . "*TEXT"))))   (princ "\nSelect block with attribute")   (setq blk (ssget ":S" '((0 . "INSERT")(66 . 1))))     )   (vla-put-textstring     (car (vlax-invoke     (setq blk (vlax-ename->vla-object (ssname blk 0)))     'GetAttributes   )     )     (cdr (assoc 1 (entget (ssname txt 0))))   ) )(princ))
 
The code can be modified to target a specific TAG. but with the absence of a sample block, you going to have to deal with it yourself.
 
HTH
回复

使用道具 举报

17

主题

87

帖子

70

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 06:29:45 | 显示全部楼层
Thanks PBE,
 
I'm waiting this morning a mail with the plan....and i'll test it!!
you'll certainly receive a feed back from me.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 06:32:05 | 显示全部楼层
 
  1. (princ "\n Select block with attribute")'((0 . "INSERT")(66 . 1))
回复

使用道具 举报

17

主题

87

帖子

70

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-6 06:35:56 | 显示全部楼层
 
Hi Tharwat,
 
I don't know what to do with your code?
Please explain me?
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 06:37:06 | 显示全部楼层
 
I'm getting really rusty..
 
Good catch Tharwat.
 
 
Post #4  updated
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:41 , Processed in 0.487323 second(s), 72 queries .

© 2020-2025 乐筑天下

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