乐筑天下

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

[编程交流] Lisp用于属性提取fro

[复制链接]

34

主题

123

帖子

90

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
175
发表于 2022-7-5 18:30:48 | 显示全部楼层 |阅读模式
我从这里得到了下面的大部分代码
我试图做的是从块中读取属性值和标记(块有多个属性)。当我(普林斯)它,它返回零。我做错了什么?
 
谢谢
 
  1. (defun c:sk (/)
  2. (if (setq ent(entsel "\n Select a Block: "))  ;- Let the user select a block
  3. (progn                                                   
  4. (setq en(car ent))                                                        ;- Get the entity name of the block
  5. (setq enlist(entget en))                                          ;- Get the DXF group codes
  6. (setq blkType(cdr(assoc 0 enlist)))                 ;- Save the type of entity
  7. (if (= blkType "INSERT")                                          ;- If the entity type is an Insert entity
  8.   (progn
  9.    (if(= (cdr(assoc 66 enlist)) 1)    ;- See if the attribute flag equals one (if so, attributes follow)
  10.    (progn
  11.      (setq en2(entnext en))                                    ;- Get the next sub-entity
  12.      (setq enlist2(entget en2))                           ;- Get the DXF group codes
  13.      (while (/= (cdr(assoc 0 enlist2)) "SEQEND")  ;- Start the while loop and keep   
  14.        (princ "\n ")                                                 ;-Print a new line
  15.        (princ enlist2)                                               ;- Print the attribute DXF group codes
  16.        (setq en2(entnext en2))                             ;- Get the next sub-entity
  17.        (setq enlist2(entget en2))                      ;- Get the DXF group codes
  18.      )
  19.     )
  20.    )  ;- Close the if group code 66 = 1 statement
  21.   )
  22. )   ;- Close the if block type = "ATTRIB" statement
  23. )
  24. )   ;- Close the if an Entity is selected statement
  25. [color=Red](setq att_value (cdr (assoc 1 enlist2)))
  26. (princ "\nAtt_value  :  ")
  27. (princ att_value)
  28. (setq att_tag (cdr (assoc 2 enlist2)))
  29. (princ "\nAtt_tag  :  ")
  30. (princ att_tag)
  31. [/color]
  32. )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:35:55 | 显示全部楼层
也许:
 
  1. (defun c:sk (/ dxf ent)
  2. (defun dxf (code ent) (cdr (assoc code (entget ent))))
  3. (if (and (setq ent (car (entsel "\nSelect an Attributed Block: ")))
  4.           (eq "INSERT" (dxf 0 ent))
  5.           (= 1 (dxf 66 ent)))
  6.    (while (not (eq "SEQEND" (dxf 0 (setq ent (entnext ent)))))
  7.      (princ (strcat "\n\nAtt_Tag:" (dxf 2 ent) "\nAtt_Value: " (dxf 1 ent)))))
  8. (princ))   
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 18:38:58 | 显示全部楼层
列出这件事真奇怪。双击属性块并查看该编辑器可以查看此信息。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:42:14 | 显示全部楼层
 
我认为这更像是一种学习练习
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 18:45:01 | 显示全部楼层
也许,这看起来很奇怪。
回复

使用道具 举报

34

主题

123

帖子

90

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
175
发表于 2022-7-5 18:46:52 | 显示全部楼层
我只是看了帖子。谢谢李的代码。这就是我想做的。现在我必须研究你的所有代码,因为我要做的事情更复杂。我写的所有帖子都是为同一个项目服务的。
 
无论如何,我已经开始了。
 
现在我需要将这些att\u值转移到另一个块(该块尚未在图形上)。所以我必须把这个块叫做“RH”,改变它的att_值(用刚刚读过的替换它们,并将其放在图纸上)。
 
所以你看,这是学习和锻炼,虽然它可能看起来很奇怪。也许我的问题对你们来说太简单了,以至于看起来很奇怪。
 
你们俩都帮了大忙。
回复

使用道具 举报

34

主题

123

帖子

90

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
175
发表于 2022-7-5 18:52:07 | 显示全部楼层
你能为你的代码添加另一个功能,可以读取和提取子实体(我是指块内的块-一个级别)标记、值并打印它们吗。
 
子实体-1名称:xxx
子实体-1标签:xxx
子实体-1值:xxx
 
....
谢谢
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:54:23 | 显示全部楼层
这不是一个简单的加法,您必须深入研究块定义。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:57:48 | 显示全部楼层
驾驶室检查
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 19:00:31 | 显示全部楼层
可以明确更改一个块的值,但可以选择另一个块来获取值。你只需要知道你使用的每个块的名称。
 
我们执行类似于您要求在布局(模型空间)上拾取一个块的操作,然后使用模型中的信息更新另一个块。另一个块可以位于整个Autocad dwg中的任何位置,通常位于布局选项卡中。
 
它将显示的属性作为公共ID链接读取
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 19:27 , Processed in 0.724827 second(s), 72 queries .

© 2020-2025 乐筑天下

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