Lisp用于属性提取fro
我从这里得到了下面的大部分代码我试图做的是从块中读取属性值和标记(块有多个属性)。当我(普林斯)它,它返回零。我做错了什么?
谢谢
(defun c:sk (/)
(if (setq ent(entsel "\n Select a Block: "));- Let the user select a block
(progn
(setq en(car ent)) ;- Get the entity name of the block
(setq enlist(entget en)) ;- Get the DXF group codes
(setq blkType(cdr(assoc 0 enlist))) ;- Save the type of entity
(if (= blkType "INSERT") ;- If the entity type is an Insert entity
(progn
(if(= (cdr(assoc 66 enlist)) 1) ;- See if the attribute flag equals one (if so, attributes follow)
(progn
(setq en2(entnext en)) ;- Get the next sub-entity
(setq enlist2(entget en2)) ;- Get the DXF group codes
(while (/= (cdr(assoc 0 enlist2)) "SEQEND");- Start the while loop and keep
(princ "\n ") ;-Print a new line
(princ enlist2) ;- Print the attribute DXF group codes
(setq en2(entnext en2)) ;- Get the next sub-entity
(setq enlist2(entget en2)) ;- Get the DXF group codes
)
)
);- Close the if group code 66 = 1 statement
)
) ;- Close the if block type = "ATTRIB" statement
)
) ;- Close the if an Entity is selected statement
(setq att_value (cdr (assoc 1 enlist2)))
(princ "\nAtt_value:")
(princ att_value)
(setq att_tag (cdr (assoc 2 enlist2)))
(princ "\nAtt_tag:")
(princ att_tag)
)
也许:
(defun c:sk (/ dxf ent)
(defun dxf (code ent) (cdr (assoc code (entget ent))))
(if (and (setq ent (car (entsel "\nSelect an Attributed Block: ")))
(eq "INSERT" (dxf 0 ent))
(= 1 (dxf 66 ent)))
(while (not (eq "SEQEND" (dxf 0 (setq ent (entnext ent)))))
(princ (strcat "\n\nAtt_Tag:" (dxf 2 ent) "\nAtt_Value: " (dxf 1 ent)))))
(princ))
列出这件事真奇怪。双击属性块并查看该编辑器可以查看此信息。
我认为这更像是一种学习练习 也许,这看起来很奇怪。 我只是看了帖子。谢谢李的代码。这就是我想做的。现在我必须研究你的所有代码,因为我要做的事情更复杂。我写的所有帖子都是为同一个项目服务的。
无论如何,我已经开始了。
现在我需要将这些att\u值转移到另一个块(该块尚未在图形上)。所以我必须把这个块叫做“RH”,改变它的att_值(用刚刚读过的替换它们,并将其放在图纸上)。
所以你看,这是学习和锻炼,虽然它可能看起来很奇怪。也许我的问题对你们来说太简单了,以至于看起来很奇怪。
你们俩都帮了大忙。 你能为你的代码添加另一个功能,可以读取和提取子实体(我是指块内的块-一个级别)标记、值并打印它们吗。
子实体-1名称:xxx
子实体-1标签:xxx
子实体-1值:xxx
....
谢谢 这不是一个简单的加法,您必须深入研究块定义。 驾驶室检查 可以明确更改一个块的值,但可以选择另一个块来获取值。你只需要知道你使用的每个块的名称。
我们执行类似于您要求在布局(模型空间)上拾取一个块的操作,然后使用模型中的信息更新另一个块。另一个块可以位于整个Autocad dwg中的任何位置,通常位于布局选项卡中。
它将显示的属性作为公共ID链接读取
页:
[1]
2