【基本操作】图层操作--选实体解冻部分图层
(setq*ACAD*(vlax-get-acad-object)
*DOC* (vla-get-ActiveDocument *ACAD*)
*LAYS*(vla-get-Layers *DOC*)
)
;选择集与对象名表互转
(defun ss-enlst (ss / enlst)
(cond
((= (type ss) 'PICKSET)
(vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex SS)))
)
((= (type ss) 'LIST)
(setq enlst (ssadd))
(last (mapcar '(lambda (x) (ssadd x enlst)) ss))
)
)
)
;;71.9 [功能] 返回冻结图层列表
(defun MJ:ListLayers-Frozen (/ each out)
(vlax-for each *LAYS*
(if (= (vlax-get-property each "Freeze") :vlax-true)
(setq out (cons (vla-get-name each) out))
)
)
out
)
;;71.3 [功能] 图层列表 冻结
(defun MJ:LayerFreeze (LayList)
(vlax-for each *LAYS*
(if (member (strcase (vla-get-name each)) LayList)
(if (vlax-write-enabled-p each)
(vla-put-Freeze each :vlax-True)
)
)
(vlax-release-object each)
)
)
;;71.4 [功能] 图层列表 解冻
(defun MJ:LayerThaw (LayList)
(vlax-for each *LAYS*
(if (member (strcase (vla-get-name each)) LayList)
(if (vlax-write-enabled-p each)
(vla-put-Freeze each :vlax-False)
)
)
(vlax-release-object each)
)
)
(defun C:jd(/ LayerFreeze_lst layer_lst ss x)
(princ "\n图层操作--解冻选定\n")
(setvar "cmdecho" 0)
(command ".undo" "be");;;建立undo组开始
(setq LayerFreeze_lst(MJ:ListLayers-Frozen))
(command "-layer" "TH" "*" "")
(if (setq ss (ssget))
(progn
(setq ss(ss-enlst ss))
(setq layer_lst
(mapcar '(lambda(x)(cdr (assoc 8 (entget x)))) ss)
)
(foreach x layer_lst
(setq LayerFreeze_lst(vl-remove x LayerFreeze_lst))
)
)
)
(MJ:LayerFreeze LayerFreeze_lst)
(command ".undo" "e");;;建立undo组完成
(setvar "cmdecho" 1)
)
对块和参照内图层不能用,希望能改进,使用场景将极大扩展。 cghdy 发表于 2020-5-12 10:32
对块和参照内图层不能用,希望能改进,使用场景将极大扩展。
自己改下,把ssget模式换成nentsel模式 1028695446 发表于 2020-5-12 17:39
自己改下,把ssget模式换成nentsel模式
nentsel牺牲有点大,只能点选了 (DEFUN HY-GET-DXF (CODE ENAME) (CDR (ASSOC CODE (ENTGET ENAME))))
(defun C:jd()
(princ "\n图层操作--解冻选定\n")
(setvar "cmdecho" 0)
(command ".undo" "be");;;建立undo组开始
(setq LayerFreeze_lst(MJ:ListLayers-Frozen))
(command "-layer" "TH" "*" "")
(setq layer_lst nil)
(while (setq nenam (car(nentsel )))
(setq layer_lst (list (HY-GET-DXF 8 nenam) layer_lst))
(foreach x layer_lst
(setq LayerFreeze_lst(vl-remove x LayerFreeze_lst))
)
)
(MJ:LayerFreeze LayerFreeze_lst)
(command ".undo" "e");;;建立undo组完成
(setvar "cmdecho" 1)
)
;;;修改可以针对块及参照使用。
;;;顺带提一下nentsel使用起来一无法像ssget一样框选,二反馈不直观,无法判断是否点中图元。望高手改进。 cghdy 发表于 2020-5-12 22:04
(DEFUN HY-GET-DXF (CODE ENAME) (CDR (ASSOC CODE (ENTGET ENAME))))
(defun C:jd()
(princ "\n图层操 ...
原函数MJ:LayerFreeze针对外部参照无效,举例(MJ:LayerFreeze '("参照所在独立图层"))返回值0,但是没有冻结该图层。 冻结的图层看不到,锁定的图层才能看到! 如果图上都看不到冻结的图层,请问 如何选择需要解冻的图层啊
页:
[1]