【GBQT】关闭其它图层
前段时间整理了一下自己用的图层管理相关的命令,参见:http://bbs.mjtd.com/thread-186617-1-1.html但都是用command写的,偶尔会提示关键词错误的奇怪情况,所以打算用vla的方式重新写一些命令
第一个便是:关闭其它图层,目前支持预选对象。
本帖最后由 尘缘一生 于 2022-12-5 12:45 编辑
[*];[图层关闭(反)]----------
[*](defun sl:tcgbf (/ ent lay n ss vlay)
[*](princ "\n 请选择需要显示的图层")
[*](if (setq ss (ssget))
[*] (progn
[*] (vlax-for vlay *LAYS* (vla-put-layeron vlay :vlax-false))
[*] (repeat (setq n (sslength ss))
[*] (setq
[*] ent (ssname ss (setq n (1- n)))
[*] lay (dxf1 ent 8)
[*] vlay (vla-item *LAYS* lay)
[*] )
[*] (vla-put-layeron vlay :vlax-true)
[*] )
[*] (princ "\n 已关闭除选择图层外的其余图层")
[*] )
[*])
[*])
[*];;常量定义--------0000级加载
[*](setq *Acad* (vlax-get-acad-object)
[*]*AcDocument* (vla-get-activedocument *Acad*); 获取当前图档指针
[*]*Model-Space* (vla-get-modelspace *AcDocument*)
[*]*Paper-Space* (vla-get-PaperSpace *AcDocument*)
[*]*BLKS* (vla-get-Blocks *AcDocument*)
[*]*LAYS* (vla-get-Layers *AcDocument*)
[*]*ACLYS*(vla-get-activeLayer *AcDocument*)
[*]*LTS*(vla-get-Linetypes *AcDocument*)
[*]pi2 (* pi 0.5)
[*]pi4 (* pi 0.25)
[*]3pi4 (* 0.75 pi)
[*]2pi (+ pi pi)
[*]3pi2 (+ 3pi4 3pi4);; (* 1.5 pi)
[*]5pi4 (+ pi pi4);;(* 1.25 pi)
[*]7pi4 (+ 3pi2 pi4) ;;(* 1.75 pi)
[*])
感谢大佬分享~~~ layiso约等于关闭其他图层的吧? 尘缘一生 发表于 2022-12-4 20:46
[*];[图层关闭(反)]----------
[*](defun sl:tcgbf (/ ent lay n ss vlay)
[*](princ "\n 请选择需要 ...
我写的还是太麻烦了哈哈,学习了!还是您的简单。全关再开哈哈 lxl217114 发表于 2022-12-4 21:08
layiso约等于关闭其他图层的吧?
没查过资料,但光看效果差不多 感谢分享。 尘缘一生 发表于 2022-12-4 20:46
[*];[图层关闭(反)]----------
[*](defun sl:tcgbf (/ ent lay n ss vlay)
[*](princ "\n 请选择需要 ...
大佬 ,能否加个关闭当前所选图形的图层。再加个显示所有图层?
469229020@QQ.CO 发表于 2022-12-5 11:25
大佬 ,能否加个关闭当前所选图形的图层。再加个显示所有图层?
[*];[图层关闭]------------
[*](defun sl:tcgb (/ ent lay n ss vlay)
[*](setvar "ErrNo" 0)
[*](princ (slmsg "\n 请选择需要关闭的图层" "\n 請選擇需要關閉的圖層" "\n Please select the layer you want to turn off"))
[*](while (/= (getvar "ErrNo") 52)
[*] (if (setq ss (ssget ":S"))
[*] (progn
[*] (repeat (setq n (sslength ss))
[*] (setq ent (ssname ss (setq n (1- n))) lay (dxf1 ent 8) vlay (vla-item *LAYS* lay))
[*] (vla-put-layeron vlay :vlax-false)
[*] )
[*] (princ (slmsg "\n 已关闭选择图层" "\n 已關閉選擇圖層" "\n Layer selection turned off"))
[*] )
[*] )
[*])
[*])
[*];[图层全部显示]-----------
[*](defun sl:tcqbxs (/ vlay)
[*](vlax-for vlay *LAYS* (vla-put-layeron vlay :vlax-true))
[*](vla-regen *AcDocument* AcAllViewPorts) ;;图形较大有时需要重生成才显示 可把这句加上
[*](princ (slmsg "\n 已打开全部图层" "\n 已打開全部圖層" "\n All layers are turned on"))
[*](princ)
[*])
[*];三个全部 全显+解锁+解冻-------------
[*](defun sl:tcqbxjj (/ actlay vlay)
[*](setq Actlay (vla-get-name *ACLYS*))
[*](vlax-for vlay *LAYS* (if (/= (strcase (vla-get-name vlay)) (strcase (getvar "clayer")))
[*] (vla-put-freeze vlay :vlax-false)
[*] )
[*] (vla-put-layeron vlay :vlax-true)
[*] (vla-put-lock vlay :vlax-false)
[*])
[*](vla-regen *AcDocument* AcAllViewPorts)
[*](princ (slmsg "\n 所有图层已显示+解锁+解冻" "\n 所有圖層已顯示+解鎖+解凍" "\n All layers are displayed+unlocked+thawed"))
[*](princ)
[*])
尘缘一生 发表于 2022-12-5 12:48
[*];[图层关闭]------------
[*](defun sl:tcgb (/ ent lay n ss vlay)
[*](setvar "ErrNo" 0)
TCGB ; 错误: no function definition: SLMSG
; 错误: 参数类型错误: VLA-OBJECT nil
这个是咋回事呢?
页:
[1]
2