1 automation attributes label autocad
我在 AutoCAD 图形中有几个(许多)对象,每个对象在其首选项中都有相同的属性字段。现在我想用数字填充此属性字段(对象一 - 数字 1,对象二 - 数字 2 等等)。手动输入数字非常耗时,因此我想问您是否有自动化的方法来解决这个问题。
预先非常感谢!
下面的程序是一个非常简单的示例,它将提示您输入要编号的属性标记和开始编号的整数,然后不断提示您选择要编号的属性块引用,将数字加一每个有效选择:
(defun c:attnum ( / ent enx num tag )
(if (/= "" (setq tag (strcase (getstring "\nSpecify attribute tag <exit>: "))))
(progn
(setq num (cond ((getint "\nSpecify starting number <1>: ")) (1)))
(while
(not
(progn
(setvar 'errno 0)
(setq ent (car (entsel (strcat "\nSelect block number " (itoa num) " <exit>: "))))
(cond
( (= 7 (getvar 'errno))
(prompt "\nMissed, try again.")
)
( (null ent))
( (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
(prompt "\nThe selected object is not a block.")
)
( (/= 1 (cdr (assoc 66 enx)))
(prompt "\nThe selected block is not attributed.")
)
( (progn
(setq ent (entnext ent)
enx (entget ent)
)
(while
(and
(= "ATTRIB" (cdr (assoc 0 enx)))
(/= tag (strcase (cdr (assoc 2 enx))))
)
(setq ent (entnext ent)
enx (entget ent)
)
)
(/= "ATTRIB" (cdr (assoc 0 enx)))
)
(prompt (strcat "\nThe selected block does not contain the attribute \"" tag "\"."))
)
( (entmod (subst (cons 1 (itoa num)) (assoc 1 enx) enx))
(entupd ent)
(setq num (1+ num))
nil
)
( (prompt "\nUnable to edit attribute value."))
)
)
)
)
)
)
(princ)
)
Run Code Online (Sandbox Code Playgroud)
.lsp(确保Save As Type设置为All Files (*.*))。APPLOAD在 AutoCAD 命令行中键入。Load加载程序。APPLOAD对话框。ATTNUM在 AutoCAD 命令行中键入以运行该程序。类似的说明可以作为我的如何运行 AutoLISP 程序教程的一部分找到。
如果您希望为 AutoCAD 中打开的每个新图形或现有图形自动加载程序,请参阅我的自动加载程序教程。
除了上述项目外,您可能还对以下项目感兴趣:
我的增量编号套件应用程序将提供更广泛的选项集,允许您自定义编号格式,允许前缀和后缀、多个增量部分以及字母数字增量。
您可以使用此应用程序对现有属性块引用进行编号,方法是在对象放置期间在 AutoCAD 命令行中键入“R”或“r”以进入替换模式。
我的增量数组应用程序将允许您在排列属性块引用(或其他对象)时自动递增属性值。