这是另一种Visual Lisp方法。
- ( (lambda ( / )
-
-
-
-
- ;; By: Se7en
-
-
-
-
- ;; Copyright (c)2010-2011 John Kaul
- ;; All rights reserved.
-
- ;; Redistribution and use in source and binary forms, with or without
-
- ;; are met:
-
-
- ;; notice, this list of conditions and the following disclaimer.
-
- ;; notice, this list of conditions and the following disclaimer in
-
-
-
-
- ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-
-
-
-
- ;; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- ;; OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ;; AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-
-
-
- (vlax-map-collection
- (vla-get-layers (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
-
- (if (vlax-get-property layer
- (vlax-put-property layer 'Lock :vlax-true))))) )
这里有一些更酷的东西只使用自动Lisp。我使用大量变量创建了它,这样你可以更好地遵循这个过程。
- ( (lambda ( layername / layer lsylst props off freeze lock )
-
-
-
- ;; By: Se7en
-
-
-
- ;; 70 - Standard flags (bit-coded values):
- ;; 1 = Layer is frozen; otherwise layer is thawed
-
- ;; 4 = Layer is locked
-
- ;; 62 - Color number (if negative, layer is off)
-
-
- ;; (1+4=5). something like...
-
-
- ;; (setq laylst (entget (tblobjname "LAYER" "<YOUR LAYER NAME HERE>")))
-
-
- ;; (cons 70 (boole 6 (cdr (assoc 70 laylst)) 5))
- ;; (assoc 70 laylst)
-
-
-
-
- ;; Copyright (c)2010-2011 John Kaul
- ;; All rights reserved.
-
- ;; Redistribution and use in source and binary forms, with or without
-
- ;; are met:
-
-
- ;; notice, this list of conditions and the following disclaimer.
-
- ;; notice, this list of conditions and the following disclaimer in
-
-
-
-
- ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-
-
-
-
- ;; BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- ;; OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ;; AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-
-
-
- (setq layer (tblobjname "LAYER" layername))
- (setq laylst (entget layer)
- props (cdr (assoc 70 laylst))
- off (cdr (assoc 62 laylst))
- freeze 1
- lock 4
- )
- (setq props (boole 6 props freeze))
- (setq off (1+ (~ off)))
- (setq props (boole 6 props lock))
- (setq laylst (subst (cons 70 props) (assoc 70 laylst) laylst)
- laylst (subst (cons 62 off) (assoc 62 laylst) laylst))
- (entmod laylst)
- )
- "0" ;; just for example. make this a named procedure to use in your library.
- )
|