Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Export all layer...
Message
Information générale
Forum:
CAD
Catégorie:
Autocad Lisp
Divers
Thread ID:
00383141
Message ID:
00386380
Vues:
19
Roi,
Your code works like a charm.
This is really cool of you to help us like this.
Again thank you.


>>I like to export all layer names from my drawing to a text file so I can write a scrip to replace the layer name with layer#.
>>
>>I never wrote code in Lisp.
>>Any one knows how can I do this in Lisp?
>
>Here ya go. I added a bunch of comments so you can see how it works. :-)
>
>
;;;writes every layer name out to a user selected .txt file
>
>(defun c:layer_write (/ cur_dir fil_name fil_tag chk)
>
>	;; Grab ACAD's current folder
>	(setq cur_dir (getvar "dwgprefix"))
>
>	;; Get a file name from the user
>	(setq fil_name (getfiled "Select file to write to" cur_dir "txt" 1))
>
>	;; Open the file for writing
>	(setq fil_tag (open fil_name "w"))
>
>	;; Write the first line. Just get the first layer in the table
>	(write-line
>		(setq chk (cdr (assoc 2 (tblnext "LAYER" T))))
>		fil_tag
>	) ;_ end of write-line
>
>	;; Now loop through the layer table grabbing a layer name.
>	;; Note: each call to tblnext will get the next layer.
>	(while chk
>		(setq chk (cdr (assoc 2 (tblnext "LAYER" nil))))
>
>		;; If we got a layer, write.
>		;; If tblnext returned nil we've got all the layers,
>                ;; so chk (now nil) will stop the loop.
>		(if	chk
>			(write-line chk fil_tag)
>		) ;_ end of if
>
>	) ;_ end of while
>
>	;; close the file
>	(close fil_tag)
>) ;_ end of defun
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform