你好
我以前没有写过任何lisps,现在已经读了大约2周了,正在看代码等等。我设法拼凑了一个Lisp程序,它可以作为两个一半,但我不能让它一起工作。
我画了很多零件,旁边有一个叫做“head”的块,还有一个“PCE\u NAM”的标签。每个零件的值不同。
我想选择一个part&block窗口,然后wblock到一个新文件,该文件的名称来自标记。然后自动循环再做一次。
这是我拼凑起来的花了我一个多星期的时间哈哈。
- (defun c:nest ( / file sel1 LM:GetAttributeValue ss attValue name)
- (setq p1 (getpoint "\nFirst Corner: "))
- (setq p2 (getcorner p1 "\nSecond Corner: "))
- (setq sel1 (ssget "_W" p1 p2 ))
- (vl-load-com)
- (defun LM:GetAttributeValue (blk tag / val enx)
- (while
- (and
- (null val)
- (= "ATTRIB"
- (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
- )
- )
- (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
- (setq val (cdr (assoc 1 enx)))
- )
- )
- )
- (if (and (setq ss (ssget "_W" p1 p2 '((0 . "INSERT") (2 . "Head") (66 . 1))))
- (setq attValue (LM:GetAttributeValue (ssname ss 0) "PCE_NAM"))
- )
- (prompt (strcat "\n[Attribute Value] : " attValue))
- )
- (command "FILEDIA" "0")
- (COMMAND "-WBLOCK" (strcat "C:\\autocad\" attvalue "Y" "" "0,0" sel1 ""))
- (command "oops" )
- (prompt "\nWBlocking complete.")
- (princ)
- );defun
我得到第一个工作位进行选择,它告诉我标签值。
我也可以将所选内容wblock到文件中,但我无法将标记值作为文件名来获取wblock。
如果有任何正确方向的帮助和指针,我们将不胜感激。
P12.dwg
我附上了一个示例文件。
谢谢
俄罗斯 |