乐筑天下

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

[编程交流] 注释块属性

[复制链接]
bcr

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 12:10:52 | 显示全部楼层 |阅读模式
我是论坛新手,没有编写lisp例程的经验。我有一个例程,它使用块名作为标签来注释块。我想做的是修改这个例程,对块的一个属性进行注释。该属性的标记当前称为“KEY”,但我假设可以对其进行修改,以便可以标记任何属性。
 
如果有人能帮我,我将不胜感激。
 
(定义c:1()
 
(命令“undo”“end”“undo”“begin”)
 
(setvar“luprec”0)
 
 
 
(setq ss(ssget)
(列表
'(0.“插入”)
)))
 
 
(setq bnum(sslength ss))
(setq ent(ssname ss 0))
 
(setq名称(entget ent))
(setq bname(cdr(assoc 2名称)))
 
 
(setvar“orthomode”0)
 
 
 
(setq a(rtos bnum))
 
 
(setq b(strcat bname)(“a”))
 
 
(命令“leader”pause pause“b”)
 
(setvar“orthomode”0)
 
 
(setvar“luprec”2)
 
)
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 2022-7-6 12:38:16 | 显示全部楼层
你能更详细地解释一下吗?我真的不明白你想要实现什么。
你写了张贴的代码吗?
 
下面是发布代码的功能分解。
 
  1. [font=Times New Roman][font=Times New Roman](defun c:1x ( / ss bnum ent bname a b );_need to locolize variables[/font]
  2. [font=Times New Roman]; (command "undo" "end" "undo" "begin");_this is wrong it shound be[/font]
  3. [font=Times New Roman]  (command "undo""begin");_this marks the beginning of a group to be undon if the undo command is involked[/font]
  4. [font=Times New Roman](setvar "luprec" 0);_sets # of zeros after desimal point (this is not needed)[/font]
  5. [font=Times New Roman];_prompts user to select a block[/font]
  6. [font=Times New Roman](setq ss (ssget[/font]
  7. [font=Times New Roman](list[/font]
  8. [font=Times New Roman]'(0 . "INSERT")[/font]
  9. [font=Times New Roman])))[/font]
  10. [font=Times New Roman](setq bnum (sslength ss));_# of selected blocks in drawing[/font]
  11. [font=Times New Roman](setq ent (ssname ss 0));_gets first item in the selection set[/font]
  12. [font=Times New Roman](setq name (entget ent));_# gets block entity info[/font]
  13. [font=Times New Roman](setq bname (cdr (assoc 2 name)));_gets block name[/font]
  14. [font=Times New Roman](setvar "orthomode" 0);_turns ortho mode off[/font]
  15. [font=Times New Roman](setq a (rtos bnum ));_# of selected blocks in the drawing[/font]
  16. [font=Times New Roman](setq b (strcat bname "(" a ")"));_puts the block name and the # of occurences of that block together[/font]
  17. [font=Times New Roman](command "leader" pause pause "" b "") ;_makse the leader with block anme and number of occurenced of that block in the drawing[/font]
  18. [font=Times New Roman](setvar "orthomode" 0);_turns ortho mode off[/font]
  19. [font=Times New Roman](setvar "luprec" 2);_sets # of zeros after desimal point (this is not needed)[/font]
  20. [font=Times New Roman]  (command "undo" "end");_this marks the end of a group to be undon if the undo command is involked[/font]
  21. [font=Times New Roman]  (princ)[/font]
  22. [font=Times New Roman]);_defun[/font]
  23. [/font]
回复

使用道具 举报

bcr

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 13:09:11 | 显示全部楼层
厕所,
 
非常感谢您的回复。它真的帮助我了解了不同的线路的功能。在回答你的问题时。。。
 
1) 不,我没有写例程。一个朋友提供给我的。他是从别人那里得到的。因此,我对这个例程中存在不相关的元素并不感到惊讶。
 
2) 我想做的是修改这个例程,以便生成一个领导者。该引线的文本将是块特定属性的值,而不是块名称的值。
 
谢谢
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 13:23:22 | 显示全部楼层
 
不确定你到底需要什么
试试看
 
  1. (defun c:11 ()
  2. (command "undo" "end" "undo" "begin")
  3. (setvar "luprec" 0)
  4. (setvar "orthomode" 0)
  5. (while
  6. (setq ent (nentsel "\nSelect arribute only (or press Enter to Exit) >>"))
  7. (setq en (car ent)
  8.      elist (entget en)
  9.      attvalue (cdr (assoc 1 elist))
  10.      pt (cadr ent)
  11.      )
  12. (command "leader" pt pause "" attvalue "")
  13. )
  14. (setvar "orthomode" 0)
  15. (setvar "luprec" 2)
  16. (command "undo" "end")
  17. )

 
~'J'~
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:25 , Processed in 0.822559 second(s), 60 queries .

© 2020-2025 乐筑天下

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