Glen Smith 发表于 2022-7-6 12:45:15

在层上插入块

我有一点空闲时间,一直在继续研究李前一段时间为我写的LISP。我今天取得了很大的进步,但在一个地方还不够。我想让我的LISP在一个位置插入三个不同的块,但我希望它们在不同的层上。
 
我有以下代码可以工作,但将所有内容放在当前层上。
 
                      (setq rot (RTD (vla-get-rotation obj)))
                     (setq xScale (vla-get-xscalefactor obj))
                     (setq yScale (vla-get-yscalefactor obj))

                     ;switch to kc layer
                     (command "-insert" (nth count kclst) ipt xScale yScale rot)
                     ;switch to mg layer
                     (command "-insert" (nth count mglst) ipt xScale yScale rot)
                     ;switch to wipeout layer
                     (command "-insert" (nth count wipelst) ipt xScale yScale rot)

 
有没有简单的方法?图层应该已经存在于图形中,因此只需将其设置为当前图层即可。
 
谢谢
格伦

cedwards 发表于 2022-7-6 13:02:16

试试这个:
我假设您已经创建了层。

(setq rot (RTD (vla-get-rotation obj)))
                     (setq xScale (vla-get-xscalefactor obj))
                     (setq yScale (vla-get-yscalefactor obj))

                     ;switch to kc layer
                     (command "-layer" "s" "kc" "")
                     (command "-insert" (nth count kclst) ipt xScale yScale rot)
                     ;switch to mg layer
                     (command "-layer" "s" "mg" "")
                     (command "-insert" (nth count mglst) ipt xScale yScale rot)
                     ;switch to wipeout layer
                     (command "-layer" "s" "wipeout" "")
                     (command "-insert" (nth count wipelst) ipt xScale yScale rot)

ronjonp 发表于 2022-7-6 13:02:58

您也可以这样做:(如果插入的对象位于锁定层上,或该层不存在,则会爆炸。
 
*编辑。。。使用entmod,这样如果层不存在,就会自动创建该层。

(setq rot (rtd (vla-get-rotation obj)))
(setq xscale (vla-get-xscalefactor obj))
(setq yscale (vla-get-yscalefactor obj))

                   ;switch to kc layer
(command "-insert" (nth count kclst) ipt xscale yscale rot)
;;(vla-put-layer (vlax-ename->vla-object (entlast)) "kc")
(entmod (subst (cons 8 "kc") (assoc 8 (entget (entlast))) (entget (entlast))))
                   ;switch to mg layer
(command "-insert" (nth count mglst) ipt xscale yscale rot)
;;(vla-put-layer (vlax-ename->vla-object (entlast)) "mg")
(entmod (subst (cons 8 "mg") (assoc 8 (entget (entlast))) (entget (entlast))))
                   ;switch to wipeout layer
(command "-insert" (nth count wipelst) ipt xscale yscale rot)
;;(vla-put-layer (vlax-ename->vla-object (entlast)) "wipeout")
(entmod (subst (cons 8 "wipeout") (assoc 8 (entget (entlast))) (entget (entlast))))

Glen Smith 发表于 2022-7-6 13:13:13

谢谢你们的快速回复,很自然,我在发布后在AfraLISP网站上找到了以下链接——尽管在发布之前我花了整整20分钟的时间在那里寻找。
 
http://www.afralisp.net/lispa/lisp31.htm
 
Cedwards,Ellight在这个声明中做了什么?查看命令行窗口意味着它应该是关于协调的,但我不确定是什么。
(command "-layer" "wipeout" "ELIGHT" "")
 
格伦

cedwards 发表于 2022-7-6 13:20:54

对不起,我今天不能打字或校对。。。。看到我修改后的第一篇帖子了吗

Glen Smith 发表于 2022-7-6 13:28:27

啊,没问题,我想可能会有一些特别的事情,通常会做的抹杀或东西。

Glen Smith 发表于 2022-7-6 13:42:55

Doh,
 
有没有什么版主可以把这个帖子放到LISP论坛上?我以为我把它放在那里了,但当我回家看它时,却找不到。
 
谢谢
格伦

The Buzzard 发表于 2022-7-6 13:50:19

 
 
在程序中的下面某处添加此函数:
 
(defun MKE_LYR (NEWLAYER CLR LT / LAY FRZ)
(setq LAY (tblsearch "layer" NEWLAYER))
(if (not LAY)
   (command "_.layer" "_m" NEWLAYER "_c" CLR "" "_lt" LT "" "")
   (progn
   (setq FRZ (cdr (assoc 70 LAY)))
   (if (= FRZ 65)
       (progn
         (command "_.layer" "_t" NEWLAYER "")
         (command "_.layer" "_s" NEWLAYER "")
       )
       (command "_.layer" "_s" NEWLAYER "")
   )
   )
)
(princ)
)
 
然后在插入块之前添加这些线,如图所示:
(setq rot (RTD (vla-get-rotation obj)))
(setq xScale (vla-get-xscalefactor obj))
(setq yScale (vla-get-yscalefactor obj))

;switch to kc layer
(MKE_LYR "KC" "RED" "")
(command "-insert" (nth count kclst) ipt xScale yScale rot)
;switch to mg layer
(MKE_LYR "MG" "GREEN" "")
(command "-insert" (nth count mglst) ipt xScale yScale rot)
;switch to wipeout layer
(MKE_LYR "WIPEOUT" "YELLOW" "")
(command "-insert" (nth count wipelst) ipt xScale yScale rot)
 
 
这将使层,如果它不在那里或设置它,如果它在那里。
还将设置颜色和线型。
页: [1]
查看完整版本: 在层上插入块