马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
请教发帖时让lisp源代码的的缩进保存..
;;替换框选的所有块,其余的块不变。
- (defun C:blkrp ( / ss BlkName blkname2 ents i)
- (setvar "osmode" 0)
- (princ "\n请选择作为源块的图块:")
- ;(setq ss (ssget (list (cons 0 "INSERT"))))
- (setq sssname "INSERT")
- (setq ss (sselect sssname))
- (setq BlkName (cdr (assoc 2 (entget (car ss)))))
- (princ "\n请选择将替换的图块:")
- (setq ss1 (ssget (list (cons 0 "INSERT"))))
- (setq blkname2 (cdr (assoc 2 (entget (ssname ss1 0)))))
- (if ss1
- (progn
- (setq i 0)
- (repeat (sslength ss1)
- (setq ents (entget (ssname ss1 i)))
- (setq ents (subst (cons 2 BlkName) (assoc 2 ents) ents))
- (entmod ents)
- (setq i (1+ i))
- );end repeat
- );end progn
- );end if
- (princ)
- ) ;end defun
- (defun Sselect (sssname)
- (setq m 1)
- (while m
- (setq ss1 (entsel))
- (cond
- ((not ss1)
- (prompt "\n错误:你什么都没有选择!")
- )
- ;加此段可强制选择sssname的物体.选择别的物体没用.
- ((/= sssname (cdr (assoc 0 (entget (car ss1)))))
- (prompt "\n错误:你选择的物体不匹配")
- )
- (t (prompt "\n...OK_...") (setq m nil))
- );cond
- );while m
- ss1
- );end defun
[php](defun C:blkrp (/ ss BlkName blkname2 ents i)
(setvar "osmode" 0)
(princ "\n请选择作为源块的图块:")
(setq sssname "INSERT"
ss (sselect sssname)
BlkName (cdr (assoc 2 (entget (car ss))))
)
(princ "\n请选择将替换的图块:")
(setq ss1 (ssget (list (cons 0 "INSERT")))
blkname2 (cdr (assoc 2 (entget (ssname ss1 0))))
)
(if ss1
(progn
(setq i 0)
(repeat (sslength ss1)
(setq ents (entget (ssname ss1 i))
ents (subst (cons 2 BlkName) (assoc 2 ents) ents)
)
(entmod ents)
(setq i (1+ i))
)
)
)
(princ)
)
(defun Sselect (sssname)
(setq m 1)
(while m
(setq ss1 (entsel))
(cond
((not ss1)
(prompt "\n错误:你什么都没有选择!")
)
;;加此段可强制选择sssname的物体.选择别的物体没用.
((/= sssname (cdr (assoc 0 (entget (car ss1)))))
(prompt "\n错误:你选择的物体不匹配")
)
(t (prompt "\n...OK_...") (setq m nil))
)
)
ss1
)[/php]
这样的lsp很难看
如何能这样,就好多了.
如图 |