明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1013|回复: 6

[提问] 关于图元改层的,请求大佬帮助

[复制链接]
发表于 2019-12-14 09:50:56 | 显示全部楼层 |阅读模式
(defun c:tt()
(setq ss (ssget "i"))
(if (= ss nil)
(command "-LAYER" "M" "0" "")
(command "-LAYER" "M" "0" "" "LAYCUR" )
)  
(princ)
)








请教下,各位大佬,帮忙改成
空选时,切到0层
选择图元时,只把图元改到0层,当前层不变

发表于 2019-12-14 10:09:10 | 显示全部楼层
(defun c:tt (/ name ss)
        (if (setq ss (ssget))
                (while (setq name (ssname ss 0))
                        (vla-put-Layer (vlax-ename->vla-object name) "0")
                        (ssdel name ss)
                )
                (setvar "CLAYER" "0")
        )
)
发表于 2019-12-14 10:18:21 | 显示全部楼层
试试  是这效果不
(defun YH_chlayer (YH_layer / YH_S)
(if (null (tblsearch "LAYER" YH_layer))
    (entmake (list
        '(0 . "LAYER")
        '(100 . "AcDbSymbolTableRecord")
        '(100 . "AcDbLayerTableRecord")
        (cons 2 YH_layer)         
        '(70 . 0)                 
        '(62 . 7)                 
        '(6 . "bylayer")         
)
      )
    )
(setq YH_S (cadr (ssgetfirst)))
(if YH_S
    (command "CHPROP" YH_S "" "la" YH_layer "c" "bylayer" "")
    (setvar "clayer" YH_layer)
    )
(princ)
)
(defun c:TT0 ()
(YH_chlayer "0")
)
 楼主| 发表于 2019-12-14 10:25:38 | 显示全部楼层
(defun c:zjtc()
  (princ "\n增加1-9号图层")
  (setvar "cmdecho" 0)                  ; 关闭命令提示
  (Setq osmode_bak (getvar "osmode"))   ;_记录捕捉
  (Setvar "osmode" 0)                   ;_关闭捕捉
  (command "layer" "new" "_1" "c" "7" "_1" "")
  (command "layer" "new" "_2" "c" "5" "_2" "")
  (command "layer" "new" "_3" "c" "6" "_3" "")
  (command "layer" "new" "_4" "c" "4" "_4" "")
  (command "layer" "new" "_5" "c" "3" "_5" "")
  (command "layer" "new" "_6" "c" "2" "_6" "")
(command "layer" "new" "_7" "c" "30" "_7" "")
(command "layer" "new" "_8" "c" "8" "_8" "")
(command "layer" "new" "_9" "c" "1" "_9" "")
  (setvar "cmdecho" 1)                  ; 打开命令提示
  (Setvar "osmode" osmode_bak)          ;_还原捕捉
(PRINC))

;;;图层切换
(defun c:1 ()
(setvar "clayer" "_1")(princ))


(defun c:2 ()
(setvar "clayer" "_2")(princ))


(defun c:3 ()
(setvar "clayer" "_3")(princ))


(defun c:4 ()
(setvar "clayer" "_4")(princ))


(defun c:5 ()
(setvar "clayer" "_5")(princ))


(defun c:6 ()
(setvar "clayer" "_6")(princ))


(defun c:7 ()
(setvar "clayer" "_7")(princ))


(defun c:8 ()
(setvar "clayer" "_8")(princ))


(defun c:9 ()
(setvar "clayer" "_9")(princ))

;;;图元改层
(defun c:11 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_1" "")
(setvar "cmdecho" 1)
(princ))

(defun c:22 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_2" "")
(setvar "cmdecho" 1)
(princ))

(defun c:33 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_3" "")
(setvar "cmdecho" 1)
(princ))

(defun c:44 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_4" "")
(setvar "cmdecho" 1)
(princ))

(defun c:55 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_5" "")
(setvar "cmdecho" 1)
(princ))

(defun c:66 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_6" "")
(setvar "cmdecho" 1)
(princ))

(defun c:77 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_7" "")
(setvar "cmdecho" 1)
(princ))

(defun c:88 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_8" "")
(setvar "cmdecho" 1)
(princ))

(defun c:99 ()
(setvar "cmdecho" 0)
(setq sset (ssget))
(command"change"sset"" "p" "LA" "_9" "")
(setvar "cmdecho" 1)
(princ))



自己整理的,凑合着用也不错,

 楼主| 发表于 2019-12-14 10:26:30 | 显示全部楼层
xj6019 发表于 2019-12-14 10:18
试试  是这效果不
(defun YH_chlayer (YH_layer / YH_S)
(if (null (tblsearch "LAYER" YH_layer))

感谢回答...............
 楼主| 发表于 2019-12-14 10:57:37 来自手机 | 显示全部楼层
taoyi0727 发表于 2019-12-14 10:09
(defun c:tt (/ name ss)
        (if (setq ss (ssget))
                (while (setq name (ssname ss 0))

感谢回答。。。。。。。。。。
发表于 2022-12-10 15:21:37 | 显示全部楼层
不错,画图用的频率比较多的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-16 04:16 , Processed in 0.144336 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表