乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 83|回复: 7

[编程交流] 在层上插入块

[复制链接]

13

主题

126

帖子

114

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 12:45:15 | 显示全部楼层 |阅读模式
我有一点空闲时间,一直在继续研究李前一段时间为我写的LISP。我今天取得了很大的进步,但在一个地方还不够。我想让我的LISP在一个位置插入三个不同的块,但我希望它们在不同的层上。
 
我有以下代码可以工作,但将所有内容放在当前层上。
 
  1.                       (setq rot (RTD (vla-get-rotation obj)))
  2.                      (setq xScale (vla-get-xscalefactor obj))
  3.                      (setq yScale (vla-get-yscalefactor obj))
  4.                      ;switch to kc layer
  5.                      (command "-insert" (nth count kclst) ipt xScale yScale rot)
  6.                      ;switch to mg layer
  7.                      (command "-insert" (nth count mglst) ipt xScale yScale rot)
  8.                      ;switch to wipeout layer
  9.                      (command "-insert" (nth count wipelst) ipt xScale yScale rot)

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

使用道具 举报

5

主题

22

帖子

17

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 13:02:16 | 显示全部楼层
试试这个:
我假设您已经创建了层。
  1. (setq rot (RTD (vla-get-rotation obj)))
  2.                      (setq xScale (vla-get-xscalefactor obj))
  3.                      (setq yScale (vla-get-yscalefactor obj))
  4.                      ;switch to kc layer
  5.                      (command "-layer" "s" "kc" "")
  6.                      (command "-insert" (nth count kclst) ipt xScale yScale rot)
  7.                      ;switch to mg layer
  8.                      (command "-layer" "s" "mg" "")
  9.                      (command "-insert" (nth count mglst) ipt xScale yScale rot)
  10.                      ;switch to wipeout layer
  11.                      (command "-layer" "s" "wipeout" "")
  12.                      (command "-insert" (nth count wipelst) ipt xScale yScale rot)
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-6 13:02:58 | 显示全部楼层
您也可以这样做:(如果插入的对象位于锁定层上,或该层不存在,则会爆炸。
 
*编辑。。。使用entmod,这样如果层不存在,就会自动创建该层。
  1. (setq rot (rtd (vla-get-rotation obj)))
  2. (setq xscale (vla-get-xscalefactor obj))
  3. (setq yscale (vla-get-yscalefactor obj))
  4.                    ;switch to kc layer
  5. (command "-insert" (nth count kclst) ipt xscale yscale rot)
  6. ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "kc")
  7. (entmod (subst (cons 8 "kc") (assoc 8 (entget (entlast))) (entget (entlast))))
  8.                    ;switch to mg layer
  9. (command "-insert" (nth count mglst) ipt xscale yscale rot)
  10. ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "mg")
  11. (entmod (subst (cons 8 "mg") (assoc 8 (entget (entlast))) (entget (entlast))))
  12.                    ;switch to wipeout layer
  13. (command "-insert" (nth count wipelst) ipt xscale yscale rot)
  14. ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "wipeout")
  15. (entmod (subst (cons 8 "wipeout") (assoc 8 (entget (entlast))) (entget (entlast))))
回复

使用道具 举报

13

主题

126

帖子

114

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

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

 
格伦
回复

使用道具 举报

5

主题

22

帖子

17

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 13:20:54 | 显示全部楼层
对不起,我今天不能打字或校对。。。。看到我修改后的第一篇帖子了吗
回复

使用道具 举报

13

主题

126

帖子

114

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 13:28:27 | 显示全部楼层
啊,没问题,我想可能会有一些特别的事情,通常会做的抹杀或东西。
回复

使用道具 举报

13

主题

126

帖子

114

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 13:42:55 | 显示全部楼层
Doh,
 
有没有什么版主可以把这个帖子放到LISP论坛上?我以为我把它放在那里了,但当我回家看它时,却找不到。
 
谢谢
格伦
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 13:50:19 | 显示全部楼层
 
 
在程序中的下面某处添加此函数:
 
  1. (defun MKE_LYR (NEWLAYER CLR LT / LAY FRZ)
  2. (setq LAY (tblsearch "layer" NEWLAYER))
  3. (if (not LAY)
  4.    (command "_.layer" "_m" NEWLAYER "_c" CLR "" "_lt" LT "" "")
  5.    (progn
  6.      (setq FRZ (cdr (assoc 70 LAY)))
  7.      (if (= FRZ 65)
  8.        (progn
  9.          (command "_.layer" "_t" NEWLAYER "")
  10.          (command "_.layer" "_s" NEWLAYER "")
  11.        )
  12.        (command "_.layer" "_s" NEWLAYER "")
  13.      )
  14.    )
  15. )
  16. (princ)
  17. )

 
然后在插入块之前添加这些线,如图所示:
  1.   (setq rot (RTD (vla-get-rotation obj)))
  2. (setq xScale (vla-get-xscalefactor obj))
  3. (setq yScale (vla-get-yscalefactor obj))
  4. ;switch to kc layer
  5. [color=red](MKE_LYR "KC" "RED" "")[/color]
  6. (command "-insert" (nth count kclst) ipt xScale yScale rot)
  7. ;switch to mg layer
  8. [color=red](MKE_LYR "MG" "GREEN" "")[/color]
  9. (command "-insert" (nth count mglst) ipt xScale yScale rot)
  10. ;switch to wipeout layer
  11. [color=red](MKE_LYR "WIPEOUT" "YELLOW" "")[/color]
  12. (command "-insert" (nth count wipelst) ipt xScale yScale rot)

 
 
这将使层,如果它不在那里或设置它,如果它在那里。
还将设置颜色和线型。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-5 04:36 , Processed in 1.105483 second(s), 79 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表