Code Red > AutoLISP (Vanilla / Visual)
Freeze all layer
Humbertogo:
I try to Freeze all layer with (command "_.-LAYER" "F" "*" it working but i get Error
Error: AutoCAD variable setting rejected: "clayer" "0"; error: An error has
occurred inside the *error* functionAutoCAD variable setting rejected: "clayer"
"0"
do know any one why this err occurred and how to fix it
Thanks
FengK:
Humbertogo,
You can't free the current layer. Here is a quick fix:
(vl-catch-all-apply
(function (lambda ()
(command "-LAYER" "F" "*" "")
)
)
)
- KF
Humbertogo:
I have use your code but i still have the err
ElpanovEvgeniy:
--- Code: ---(defun unfrozen ()
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
) ;_ vla-get-layers
(function
(lambda (x)
(vl-catch-all-apply
(function vla-put-freeze)
(list x :vlax-false)
) ;_ vl-catch-all-apply
) ;_ lambda
) ;_ function
) ;_ vlax-map-collection
(vla-regen
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
1
) ;_ vla-regen
(princ "\nLayers are unfrozen ")
) ;_ defun
(defun frozen ()
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
) ;_ vla-get-layers
(function
(lambda (x)
(vl-catch-all-apply
(function vla-put-freeze)
(list x :vlax-true)
) ;_ vl-catch-all-apply
) ;_ lambda
) ;_ function
) ;_ vlax-map-collection
(vla-regen
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
1
) ;_ vla-regen
(princ "\nLayers are frozen ")
) ;_ defun
(unfrozen)
(frozen)
--- End code ---
Jürg Menzi:
This should do the stuff (you may need to call vl-load-com to initialize ActiveX support):
--- Code: ---;
; == Function MePutAllLayers
; Controls Freeze, LayerOn, Lock, Plottable or ViewportDefault for all Layers.
; Arguments [Type]:
; Sym = Symbol [SYM]:
; - 'vla-put-Freeze
; - 'vla-put-LayerOn
; - 'vla-put-Lock
; - 'vla-put-Plottable
; - 'vla-put-ViewportDefault
; Mde = Mode [BOOLEAN]:
; - :vlax-true
; - :vlax-false
; Return [Type]:
; > Null
; Notes:
; - Some symbols require a vla-regen to make the changes visible.
;
(defun MePutAllLayers (Sym Mde / AcaDoc)
(setq AcaDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for Obj (vla-get-Layers AcaDoc)
(vl-catch-all-error-p
(vl-catch-all-apply Sym (list Obj Mde))
)
)
(princ)
)
--- End code ---
Use:
(MePutAllLayers 'vla-put-Freeze :vlax-true)
Edited: Notes added
Navigation
[0] Message Index
[#] Next page
Go to full version