嗨,Shailujp,
这相当于编写incatt2来处理插入的选择集,而不是单独拾取和处理它们。为了解决一系列可能的属性标记名称的问题,它将对照标记列表(可以编辑)检查所有属性。如果标记名在列表中,它将向其属性值添加前缀。
- (defun c:prefatts ( / pref sscnt ss1 tags )
- (vl-load-com)
- (setq tags (mapcar
- 'strcase
- '([color=blue]"ITEM_NUMBER" "BALIN" "X"[/color])[b][color=red] ;<==== Put attribute TAG names here inside the list[/color][/b]
- )
- )
- (cond
- ((= (setq pref (getstring T "\nEnter Prefix to add to the selected attributes: ")) "")
- (princ "\nNothing to do... exiting...")
- )
- ((progn
- (if (null (cadr (ssgetfirst)))
- (princ "\nSelect Blocks to Modify: ")
- )
- (setq ss1 (ssget '((0 . "INSERT") (66 . 1))))
- )
- (repeat (setq sscnt (sslength ss1))
- (foreach x (vlax-invoke (vlax-ename->vla-object (ssname ss1 (setq sscnt (1- sscnt)))) 'getattributes)
- (if (member (strcase (vla-get-tagstring x)) tags)
- (vla-put-textstring x (strcat pref (vla-get-textstring x)))
- )
- )
- )
- )
- (T
- (princ "\nUnsuitable selection... Exiting...")
- )
- )
- (princ)
- )
当我试图修改它以增加字母时,它给了我stringp 66错误。有人能帮我吗?
我需要这个来将字母从A增加到Z,当这个过程结束时,下一个数字应该是AA,AB,AC等等。这听起来可能吗?
修改代码:
- (defun c:INCATT ( / tag pre ss1 ) (vl-load-com)
- (setq tag "ITEM_NUMBER" pre "")
- (if (setq *num* (cond ( (getint (strcat "\nSpecify Starting Number" (if *num* (strcat " <" (itoa *num*) "> : ") ": ")))) ( *num* )))
- (while (setq ss1 (ssget "_+.:E:S:L" '((0 . "INSERT") (66 . 1))))
- (if
- (vl-some
- (function
- (lambda ( x )
- (if (eq tag (vla-get-tagstring x))
- (not (vla-put-textstring x (strcat pre (itoa *num*))))
- )
- )
- )
- (vlax-invoke (vlax-ename->vla-object (ssname ss1 0)) 'getattributes)
- )
- (setq *num* (1+ *num*))
- (princ (strcat tag " Attribute not found."))
- )
- )
- )
- (princ)
- )
提前感谢!! |