本帖最后由 嘒彼小星 于 2023-7-29 10:07 编辑
在院长的代码基础上,子程序后,if前。加代码,
(setq layer_tc (tblsearch "layer" "你好123"))
(if (= layer_tc nil)(command "-LAYER" "n" "你好123" ""))
(command "LAYER" "S" "你好123" "")
然后循环里面的圆的命令改为
(command "PLINE" "non" p1 "w" "5" "5" "A" "A" "180" "non" p2 "CL")
上面这两个5 根据你需要的线的粗细来更改为别的数值。
完整的就像下面这样:
- (defun c:iy ()
- (defun mimx (s1 / p1 p9)
- (vla-getboundingbox (vlax-ename->vla-object s1) 'p1 'p9)
- (list (vlax-safearray->list p1) (vlax-safearray->list p9))
- )
- (setq layer_tc (tblsearch "layer" "你好123"))
- (if (= layer_tc nil)(command "-LAYER" "n" "你好123" ""))
- (command "LAYER" "S" "你好123" "")
- (if (and (setq s1 (car (entsel "\n选择图块: ")))
- (= (cdr (assoc 0 (entget s1))) "INSERT")
- (setq bk (cdr (assoc 2 (entget s1))))
- (setq ss (ssget "x" (list (cons 2 bk))))
- )
- (progn
- (setq i -1)
- (while (setq s1 (ssname ss (setq i (1+ i))))
- (setq ptn (mimx s1)
- p1 (car ptn)
- p2 (cadr ptn)
- )
- (command "PLINE" "non" p1 "w" "5" "5" "A" "A" "180" "non" p2 "CL")
- )
- )
- )
- (princ)
- )
|