嗨,我需要帮助。我想从现有的两个LISP中找到新的LISP。
第一个交付选择集(根据属性值),第二个应使用该选择集(更改选定对象的层)。
我认为这很琐碎,但我不知道怎么做。我在谷歌上花了一些时间,但什么也没学到。
我不喜欢在执行过程中选择任何东西。
稍后我将在代码中自己更改层名称(这是我对许多相同属性(具有不同的特定属性值)的全局层更改想法的第一步)。
1.
- (defun c:attselect ( / ss2 ss tag val n na)
- (setq ss2 (ssadd))
- (sssetfirst nil nil)
- (princ "\nSelect blocks containing attributes.")
- (if (setq ss (ssget '((0 . "INSERT") (66 . 1))))
- (progn
- (setq tag "COLOR"
- val "OR (1)"
- );setq
- (if (equal tag "")
- (setq tag "*")
- );if
- (if (equal val "")
- (setq val "*")
- );if
- (setq n 0)
- (repeat (sslength ss)
- (setq na (ssname ss n))
- (if (sample_att_match na tag val)
- (setq ss2 (ssadd na ss2))
- );if
- (setq n (+ n 1));setq
- );repeat
- (if (equal (getvar "cmdnames") "")
- (sssetfirst ss2 ss2)
- (command ss2)
- );if
- );progn then
- );if
- (princ)
- );defun c:attselect
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun sample_att_match ( na tag val / e1 a b flag)
- (while (and (setq na (entnext na))
- (setq e1 (entget na))
- (not (equal (cdr (assoc 0 e1)) "SEQEND"))
- (not flag)
- );and
- (if (equal (cdr (assoc 0 e1)) "ATTRIB")
- (progn
- (setq a (cdr (assoc 2 e1)) ;2 is tag
- b (cdr (assoc 1 e1)) ;1 is value
- );setq
- (if (and a
- (wcmatch a tag)
- b
- (wcmatch b val)
- );and
- (setq flag T);then jump out of the loop
- );if
- );progn then attrib
- );if
- );while
- flag
- );defun sample_att_match
- (princ "\nType ATTSELECT to run")
- (princ)
我对我在某处找到的原始代码(标记“COLOR”,val“OR(1)”)进行了更改。
2.
- ; Changes selected objects to Layer PL1
- (defun c:setpl1 ()
- (tolayer
- (ssget "_:L") ;;selection
- "PL1" ;;Layer
- )
- (princ)
- )
- (defun tolayer ( ss lay / i e )
- ;;; ss - pickset
- ;;; lay -layer name
- (repeat (setq i (sslength ss))
- (entmod
- (subst
- (cons 8 lay)
- (assoc 8 (entget (setq e (ssname ss (setq i (1- i))))))
- (entget e)
- )
- )
- )
- )
此代码可在此论坛上找到:http://www.cadtutor.net/forum/showthread.php?67438-LISP-to-move-selected-objects-to-a-specified-layer
VVA出版。
Thanx他,第一个代码的创建者(未知)。
Thanx未来的“合路器” |