Layer Methods


Synopsis

(std-layer-make <name> <defprops>) ; Create/set a layer w/ optional properties

(std-layer-set <name>) ; Set an existing layer current

(std-layer-on <name-or-list>) ; Turn it on

(std-layer-off <name-or-list>) ; Turn it off

(std-layer-thaw <name-or-list>)

(std-layer-freeze <name-or-list>)

(std-layer-lock <name-or-list>)

(std-layer-unlock <name-or-list>)

(std-layer-thaw-vp <name-or-list>)

(std-layer-freeze-vp <name-or-list>)

(std-layer-put-color <name-or-list> <int>) ; Set the color

(std-layer-put-ltype <name-or-list> <ltype>) ; Set the linetype

Description

These layer methods are similar to the VLA layer methods and properties.

Internally it may use (command "_LAYER" .... "") but most likely faster methods as with tblobjname/entmod/entmake or VLA-PUT-LAYER-xxx.

STD-LAYER-MAKE is used to create a layer if it exists or not. It also ensures that the layer is visible and current. If the layer already exists the provided color or ltype properties are not changed, otherwise it is created with the given properties.

<proplist> is a list of pairs of property names [string] and values to be set, as for (command "_LAYER" "_Make" name ... "").

Valid property names are the strings "Color" and "Ltype", case-insensitive and always english. The prepended underscore is not supported.

The other layer properties ("LWeight", "Plot", "OFF", "Freeze", ...) are not supported yet.

(Note: This might change. Symbols might be better than strings, esp. in foreign languages, but cannot be used with external func: VLA, ADS,ARX)

Valid property values are the same as for the special setters STD-LAYER-PUT-COLOR and STD-LAYER-PUT- LTYPE, a number between 0 and 256 and a linetype name.

STD-LAYER-SET sets the layer current if it exists. On success the ENAME of the layer object is returned, if it does not exist NIL is returned. Note that if you want to restore the state at the end of your command use the "CLAYER" slot for the error handler.

The two setters STD-LAYER-PUT-COLOR and STD-LAYER-PUT-LTYPE take two arguments, the first as in the other methods, the second is the new value to be set, which must be of the correct type. The color must be an integer in the range +-0 .. 256, where

0 stands for BYBLOCK,

256 for BYLAYER and

1..255 for the currently valid colors.

In the future larger numbers may be accepted as well.

Negative numbers force turing the layer off, positive numbers ignore the state of on/off, i.e. if a layer is off (has a negative color property) and the color is changed to a positive number, the state will stay off, the new color property will be the negative argument value.

To turn a layer off you must use explicitly STD-LAYER-OFF. Otherwise code will become unreadable.

The ltype argument for STD-LAYER-PUT-LTYPE might already be loaded, or if not it will be loaded from the actual <acad>.LIN linetyope definition file (which is most likely ACAD.LIN). if the name is not found, the layer remains unchanged and NIL is returned.

All the other layer methods just do what you will expect, according their names.

They do work one single or multiple layers. To hide the actual methods how these commands are performed we accept only a single string or a list of single strings, but no string with multiple layer names delimited by comma and no wildcards. This would be acceptable by the method (command "'_LAYER" prop name ""), but the faster methods via tblobjname/entmod or VLA will not work then. They expect single strings. To make this clear and to help using the fast methods we force this argument type though it may be limiting.

Examples

(std-layer-make "test" ("color" 3))

;;; set a layer current with saving the old state

(std-var-init '(("CLAYER"))) ; saves the current layer

(std-layer-set "test") ; sets "test" current

...

(std-var-restore) ; restores the old current layer

;;; or shorter:

;; saves the current layer and sets "test" current

(std-var-init '(("CLAYER" . "test")))	
...

(std-var-restore) ; restores the old current layer

;;; turns a layer temp. on

;; VAR-PUSH is used inside a helper function,

;; in C: commands use VAR-INIT instead

(std-var-push '((:LAYER . "test"))) ; saves the layer state

(std-layer-on "test") ; turns "test" on

...

(std-var-pop) ; restores the old layer state of "test"

;;; turn on all layers which are currently not visible.

;;; either like this, the old way

(command "'_LAYER" "_ON" "*" "_Thaw" "*" "")

;;; or like this, doing it explicitly:

(mapcar 'std-layer-thaw 
        (std-tbl-layer "*" STD:LAY-FROZEN 
                           STD:TBL-ALL 
                           STD:LAY-ON-OR-OFF))
(mapcar 'std-layer-on 
        (std-tbl-layer "*" STD:LAY-THAWED 
                           STD:TBL-ALL 
                           STD:LAY-OFF))

Arguments

defprops: A list of property pairs: (string value ...)

name-or-list: A string, a valid layer name, or a list of those. A comma delimited string or any wildcard is NOT allowed.

name: a string (a valid layer name). A comma delimited string or a wildcard is NOT allowed.

int: A valid color number, from 0 to 256.

ltype: A string, a valid linetype name, which should exist or be defined in the actual <acad>.LIN linetype definition file.

Return Values

On success the ENAME of the layer is returned, on failure NIL.

Side Effects

See above. All these functions perform only side-effects.

Module

(std-require 'STDTBL)

Defined in STDTBL