layer table documentation

Pavel_Hosek
edited October 2023 in LISP
Is there any available documentation for how the data is stored in the layer table? I have found some code that accesses "layer" table but not only it contains quite less data than expected, it is also difficult to figure out how the (70.XX) key-value pair works. An example that I found in the table is ((0 . LAYER) (2 . LAYERNAME) (70 . 0) (62 . 6) (6 . CONTINUOUS)), but it doesn't seem to change at all when I change the layer from printable to nonprintable, and the flag (70.XX) changes value when the layer is locked/unlocked as well as frozen/unfrozen, so it is not a simple true/false value.
So, at the end
A ) is there any documentation for this table, or
B ) is there any other way to use LISP to list all the layers that are non-printable, frozen, and switched off?

Comments

  • chris_yates
    edited October 2023
    I don't think this is very well documented, even by Autodesk. It is a bitwise flag. I understand this "flag" is an integer representation of a binary number, acting combined as a grouping of logical true/false operators. I found a couple of places that described the first few flags for the layer table:
    • 1 is Frozen, 2 is Frozen on new paper space view ports and 4 is locked.
    • the rest of the values will be 8, 16, 32 and 64 (binary 1000000).
    • These can be added to give a unique combination of states.
    The OSMODE system variable uses the same bitwise method. For example, combining endpoint, intersection, and extension results in a value of 4129.
  • Using VL may reveal what you want this is a dump of a couple of layers, the grated pit is set to no plot.

    (setq LayerTable (vla-get-layers (vla-get-activedocument (vlax-get-Acad-Object))))

    (vlax-for lay LayerTable
    (if (= (vlax-get lay 'name) "DEFAULT")
    (vlax-dump-object lay)
    )
    )


    ; Property values :
    ;
    ; Application (RO) = #
    ; Color = 7
    ; Database (RO) = #
    ; Description = ""
    ; Document (RO) = #
    ; Freeze = 0
    ; Handle (RO) = "E3BF"
    ; HasExtensionDictionary (RO) = 0
    ; LayerOn = -1
    ; Linetype = "Continuous"
    ; Lineweight = 9
    ; Lock = 0
    ; Material = "Global"
    ; Name = "DEFAULT"
    ; ObjectID (RO) = 1064881392
    ; ObjectID32 (RO) = 1064881392
    ; ObjectName (RO) = "AcDbLayerTableRecord"
    ; OwnerID (RO) = 1062013728
    ; OwnerID32 (RO) = 1062013728
    ; PlotStyleName = "Color_7"
    ; Plottable = -1
    ; TrueColor = #
    ; Used (RO) = -1
    ; ViewportDefault = 0
    nil
    (vlax-for lay LayerTable
    (if (= (vlax-get lay 'name) "DR_GRATED_PIT")
    (vlax-dump-object lay)
    )
    )

    ; IAcadLayer 6604e4c0 : TeighaX Interface of a logical grouping of data, similar to overlays.
    ;
    ; Property values :
    ;
    ; Application (RO) = #
    ; Color = 2
    ; Database (RO) = #
    ; Description = ""
    ; Document (RO) = #
    ; Freeze = 0
    ; Handle (RO) = "C7C1"
    ; HasExtensionDictionary (RO) = 0
    ; LayerOn = -1
    ; Linetype = "Continuous"
    ; Lineweight = -3
    ; Lock = 0
    ; Material = "Global"
    ; Name = "DR_GRATED_PIT"
    ; ObjectID (RO) = 1064834032
    ; ObjectID32 (RO) = 1064834032
    ; ObjectName (RO) = "AcDbLayerTableRecord"
    ; OwnerID (RO) = 1062013728
    ; OwnerID32 (RO) = 1062013728
    ; PlotStyleName = "Color_2"
    ; Plottable = 0
    ; TrueColor = #
    ; Used (RO) = -1
    ; ViewportDefault = 0
    nil
  • For Plot you check the value for 290 dxf code.

    With the 70 dxf code you can use boole to check for a setting

    See here for documentation Layer (DXF)

    Here is an example function to illustrate
    (defun LayerState (layername / layer laystat state)
     (setq Layer (tblobjname "LAYER" layername))
    	(cond
    		(Layer
    			(setq layer (entget layer))
    			(setq laystat (vle-cdrassoc 70 Layer))
    			(setq state
    				(list
    					(cons "Frozen" (if (= 1 (boole 1 1 laystat)) 1 0)) ; 1 = Frozen 0 = Thawed
    					(cons "NewVPFrozen" (if (= 2 (boole 1 2 laystat)) 1 0)) ; 1 = New VP Frozen 0 = New VP Thawed
    					(cons "Locked" (if (= 4 (boole 1 4 laystat)) 1 0)) ; 1 = Locked 0 = Unlocked
    					(cons "Xref" (if (= 16 (boole 1 16 laystat)) 1 0)) ; 1 = Xref 0 = Not a Xref
    					(cons "XrefRes" (if (= 32 (boole 1 32 laystat)) 1 0)) ; 1 = Xref resolved 0 = Xref not resolved
    					(cons "Referenced" (if (= 64 (boole 1 64 laystat)) 1 0)) ; 1 = Yes 0 = No
    					(cons "Plot" (vle-cdrassoc 290 Layer)) ; 1 = Yes 0 = No
    				)
    			)
    		)
    	)
    	state
    )

    Regards,
    Jason Bourhill
    BricsCAD V23 Ultimate
    CAD Concepts