TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on November 25, 2015, 06:17:13 AM

Title: Check layer if "off / frozen" with dbx
Post by: Peter2 on November 25, 2015, 06:17:13 AM
After a long pause I have to fight against DBX again  :whistling:

I want to check all layers, which are used by objects in an objectlist, if they are "off" or "frozen". In Lisp I check if
- DXF-GC 70 contains "1" (frozen)
- DXF GC 62 is negative (off)

Code: [Select]
(foreach bild ObjLst
        (setq bildlayer (cdr (assoc 8 (entget bild))))
        ; DXF-Code: 70 enthält 1 -> gefroren; 62 (Farbe) ist negativ -> ausgeschaltet
        (setq bildlayer_dxf (tblsearch "layer" bildlayer))
        (if (or
                (= (logand 1 (cdr (assoc 70 bildlayer_dxf))) 1); wenn der GC 70 den Bitcode 1 = gefroren
                (< (cdr (assoc 62 bildlayer_dxf)) 0)           ; negativ -> ausgeschaltet
            )
            (setq layerflag 1)
        )
    )

Please help me to make it with DBX.

Thanks and regards
Title: Re: Check layer if "off / frozen" with dbx
Post by: Kerry on November 25, 2015, 06:22:36 AM
Peter;

Quote
I have to fight against DBX again
You may need to explain this so it's understandable in the context of the code you posted.
Title: Re: Check layer if "off / frozen" with dbx
Post by: roy_043 on November 25, 2015, 06:31:33 AM
(tblsearch) searches tables in the current document and can therefore not be use in an (O)DBX context.
Title: Re: Check layer if "off / frozen" with dbx
Post by: Kerry on November 25, 2015, 06:34:29 AM
Thanks Roy ... I'm blind as well as silly.
Title: Re: Check layer if "off / frozen" with dbx
Post by: kpblc on November 25, 2015, 07:41:11 AM
(setq item (vla-item (vla-get-layers doc) "LayerName"))
(equal (vla-get-freeze item) :vlax-true) ; returns t if layer is frozen
(equal (vla-get-layeron item) :vlax-true) ; returns t if layer is on
Title: Re: Check layer if "off / frozen" with dbx
Post by: Peter2 on November 25, 2015, 10:17:45 AM
You may need to explain this so it's understandable in the context of the code you posted.
Sorry, Kerry. When I'm under pressure and I have the feeling that a "common dbx two-liner" will do the job but I don't have any clue - then my postings are not as precise as they should be  :embarrassed:

(setq item (vla-item (vla-get-layers doc) "LayerName"))
(equal (vla-get-freeze item) :vlax-true) ; returns t if layer is frozen
(equal (vla-get-layeron item) :vlax-true) ; returns t if layer is on
Thanks - exactly the two-liner I hoped for.  :yay!: