Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create a Layer List and thier current state to a file...

10 views
Skip to first unread message

Van Phan

unread,
Jan 19, 1999, 3:00:00 AM1/19/99
to
Hello All,

I came accross this routine from Cadence Web site. When I do a test run;
it seems that all the Layers are set to *ON* and "THAWED AND UNLOCKED"
in the print out even when some of the layers are OFF and in different
state in the Drawing. The Color and Linetype Seems to print out
correctly. Could someone please help me find out what the problem is.

Thanks in advance for all your assistant.

Sincerely,
Van
pha...@yahoo.com

;; AutoCad AutoLisp routine to print directory name,
;; file name, and conditions of layers of current drawing.
;; A text file "layers.txt" is generated
;; Copyright June 1997 Jesse Casanova

(defun c:lcond(/ filein tname lname lcolor lstate lcol frz lcond)

;; Establish file for layer names
(setq filein (open "c:\\temp\\layers.txt" "w"))
(write-line (strcat "Drawing Name = " (getvar "dwgname")) filein)
(write-line "STATUS OF LAYERS" filein)
(write-line "LAYER NAME: ON/OFF, THAWED/FROZEN, COLOR NUMBER, LINETYPE"
filein)
(write-line " " filein)
(close filein)

;; Layer names
(setq tname (tblnext "layer" T)
lname (cdr (assoc 2 tname)) ;; layer name
lcolor (cdr (assoc 62 tname)) ;; color (- means off)
lstate (cdr (assoc 70 tname)) ;; on (65 means frozen)
ltyp (cdr (assoc 6 tname)) ;; line type
colo (itoa (abs lcolor)) ;; color number
)
(if (> lcolor 0)
(setq lcol "ON")
(setq lcol "OFF")
)
(if (= lstate 64) (setq frz "THAWED AND UNLOCKED")) ;; Various
(if (= lstate 65) (setq frz "FROZEN AND UNLOCKED")) ;; Combinations
(if (= lstate 68) (setq frz "THAWED AND LOCKED")) ;; of FREEZE/THAW

(if (= lstate 69) (setq frz "FROZEN AND LOCKED")) ;; and
LOCK/UNLOCK
(if (= lstate 0) (setq frz "THAWED AND UNLOCKED"))
(setq lcond (strcase (strcat "layer " lname ": " lcol ", " frz ", " colo
", " ltyp)))
(setq filein (open "c:\\temp\\layers.txt" "a"))
(write-line lcond filein)
(close filein)
(while
(setq tname (tblnext "layer"))
(setq lname (cdr (assoc 2 tname))
lcolor (cdr (assoc 62 tname))
lstate (cdr (assoc 70 tname))
ltyp (cdr (assoc 6 tname))
colo (itoa (abs lcolor))
)
(if (> lcolor 0)
(setq lcol "ON")
(setq lcol "OFF")
)
(if (= lstate 64) (setq frz "THAWED AND UNLOCKED"))
(if (= lstate 65) (setq frz "FROZEN AND UNLOCKED"))
(if (= lstate 68) (setq frz "THAWED AND LOCKED"))
(if (= lstate 69) (setq frz "FROZEN AND LOCKED"))
(if (= lstate 0) (setq frz "THAWED AND UNLOCKED"))
(setq lcond (strcase (strcat "layer " lname ": " lcol ", " frz ", "
colo ", " ltyp)))
(setq filein (open "c:\\temp\\layers.txt" "a"))
(write-line lcond filein)
(close filein)
) ;; end while
(princ)
)

>>>> Print out sample

Plan.dwg.DWG
STATUS OF LAYERS
LAYER NAME: ON/OFF, THAWED/FROZEN, COLOR NUMBER, LINETYPE

LAYER 0: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER PATTERN_CLASS: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 25: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 20: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 1: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 23: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 16: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 58: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER 14: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER EXT-BLDG: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER AN-ROAD: ON, THAWED AND UNLOCKED, 4, CONTINUOUS
LAYER AN-WALL: ON, THAWED AND UNLOCKED, 6, CONTINUOUS
LAYER TEXT: ON, THAWED AND UNLOCKED, 4, CONTINUOUS
LAYER PARKING3: ON, THAWED AND UNLOCKED, 7, CONTINUOUS
LAYER FILL: ON, THAWED AND UNLOCKED, 11, CONTINUOUS
LAYER RFSHEET: ON, THAWED AND UNLOCKED, 3, CONTINUOUS
LAYER FILL-DARK: ON, THAWED AND UNLOCKED, 3, CONTINUOUS

<<<<< End of sample


Paul Turvill

unread,
Jan 19, 1999, 3:00:00 AM1/19/99
to
The routine makes incorrect use of group code 70. It is a bit-encoded
quantity; in order to get the correct status information, the program
should evaluate each bit, rather than make assumptions about the total
value of lstate.
__
Van Phan wrote in message <36A4CC76...@yahoo.com>...

Jon Fleming

unread,
Jan 19, 1999, 3:00:00 AM1/19/99
to
looks as if the author did not understand the 70 group or how to extract
values for bit-coded integers with the (logand ...) function. Try the
following (untested):

;; AutoCad AutoLisp routine to print directory name,
;; file name, and conditions of layers of current drawing.
;; A text file "layers.txt" is generated
;; Copyright June 1997 Jesse Casanova

;; Modified 1/19/99 by Jon Fleming

(defun c:lcond (/ filein tname lname lcolor lstate lcol frz Rewind)

;; Establish file for layer names
(setq filein (open "c:\\temp\\layers.txt" "w"))
(write-line
(strcat "Drawing Name = " (getvar "dwgname"))
filein
)
(write-line "STATUS OF LAYERS" filein)
(write-line
"LAYER NAME: ON/OFF, THAWED/FROZEN, COLOR NUMBER, LINETYPE"
filein
)
(write-line " " filein)

(setq Rewind T)
(while
(setq tname (tblnext "layer" Rewind))


(setq lname (cdr (assoc 2 tname))
lcolor (cdr (assoc 62 tname))
lstate (cdr (assoc 70 tname))
ltyp (cdr (assoc 6 tname))
colo (itoa (abs lcolor))

Rewind NIL


)
(if (> lcolor 0)

(setq lcol "On")
(setq lcol "Off")
)
(if (= 1 (logand lstate 1))
(setq frz "Frozen and ")
(setq frz "Thawed and ")
)
(if (= 2 (logand lstate 2))
(setq frz (strcat frz "Frozen in new VP and "))
(setq frz (strcat frz "Thawed in new VP and "))
)
(if (= 4 (logand lstate 4))
(setq frz (strcat frz "Locked"))
(setq frz (strcat frz "Unlocked"))
)
(write-line


(strcat "layer " lname ": " lcol ", " frz ", " colo ", " ltyp)

filein
)
)
(close filein)
(princ)
)

jrf

In article <36A4CC76...@yahoo.com>, Van Phan wrote:
> Hello All,

Van

unread,
Jan 20, 1999, 3:00:00 AM1/20/99
to
Mr. Jon,

It worked perfectly. Now I do not have to write down all the layer names
and their status anymore. I am sure someone out there could use this as
well.

I only beginning to play around with Auto Lisp but hopefuly I'll get better
so that I can contribute no matter how small to this NG like you did.

Sincerely,
Van

Jon Fleming <jo...@fleming-group.com> wrote in article
<VA.0000070...@main.fleming-group.com>...

0 new messages