bagulhodoido 发表于 2022-7-5 16:02:14

复制和增加属性

你好。
 
在复制一些文本时,是否需要增加一个字体。比如,我经常需要在图纸上给墙编号。所以,我复制文本EW 01(外墙01),粘贴时,我希望它成为EW 02。
 
谢谢你的帮助。

paulmcz 发表于 2022-7-5 16:07:03

 
我用这个:
 
;;; Replaces selected attribute value with new one and adds sequential number at the end
;;; Author paulmcz Copyright© 2006

(defun c:qs (/ ans st nw oerr e1 e2 natt)
(setq oerr *error*)
(defun *error* (msg)
   (princ "\n ERROR!")
   (setq *error* oerr)
   (command)
   (princ)
)
(if ns
   (princ (strcat "\n Previous text = " ns (itoa stt)))
)
(if ns
   (setq
   ans (getstring
    "\n Keep previous text? : "
)
   )
)
(if (= ans "")
   ()
   (setq ns nil
st nil
   )
)
(if ns
   ()
   (setq ns (getstring t "\n Type in new text: "))
)
(if stt
   ()
   (setq stt 1)
)
(princ "\n Start with number < ")
(princ stt)
(princ " >?: ")
(setq st (getint))
(if (= st nil)
   (setq st stt)
   (setq stt st)
)
(setq nw (strcat ns (itoa st)))
(setq e1 (nentsel "\n Select attribute, do not miss: "))

(while e1
   (setq e2 (entget (setq natt (car e1))))
   (entmod (subst (cons 1 nw) (assoc 1 e2) e2))
   (entupd natt)
   (if        (eq (cdr (assoc 0 e2)) "ATTRIB")
   (setq st (+ 1 st))
   (princ "\n You missed! ")
   )
   (if        st
   (setq nw        (strcat ns (itoa st))
    stt        st
   )
   )
   (setq e1 (nentsel "\n Select next attribute or to exit: "))
)
(princ)
)

(prompt "\n Type > qs < to update attributes: ")

 
它不是为复制和粘贴而制作的,但其工作方式类似。试试看。

bagulhodoido 发表于 2022-7-5 16:12:48

 
 
谢谢你,伙计。
 
顺便说一句,当它提示选择属性时,我应该选择(而不是错过)什么?
 
我以为它是文本字符串,所以它会保持所需的样式,但每当我选择字符串时,它都会提示“你错过了!”

paulmcz 发表于 2022-7-5 16:13:10

选择要更新或更改的属性值

bagulhodoido 发表于 2022-7-5 16:16:49

 
嗯,但我做错了什么?
 
我选择了要更新的文本字符串,它表示您错过了!
 
在我的例子中,它确实更改了EW1的字符串,但我选择的下一个字符串再次变为EW1,所以它就这样了。
 
我希望它像,第一个EW1,下一个字符串,EW2。你知道,就像那样。
 
这就是它的工作原理,对吗?

paulmcz 发表于 2022-7-5 16:22:10

附图标题栏中的绿色文本均为属性。如果您启动例程并单击任何一个绿色文本,它应该会更新为下一个在末尾有递增数字的文本。试试看,让我知道它是否适用于所附的图纸。
10DX05,5HX2LXMELRWA32959。图纸

bagulhodoido 发表于 2022-7-5 16:26:02

 
哦,这就是你所说的属性。
 
嗯,我真的不知道如何管理它们。我将查看有关使用属性创建块的Autocad帮助文件。
 
谢谢你的帮助。

paulmcz 发表于 2022-7-5 16:27:07

如果您只想插入注释增量文本,请尝试我的编号例程。阅读代码的前几行,看看它能做什么。
编号。lsp

bagulhodoido 发表于 2022-7-5 16:32:17

 
这正是我想要的。惊人的Lisp程序。
 
谢谢你的帮助。

paulmcz 发表于 2022-7-5 16:36:29

不客气
页: [1] 2
查看完整版本: 复制和增加属性