Irishpotato Posted February 22, 2023 Posted February 22, 2023 I am trying to subtract a pre determined layer list from my current drawing layers and have the results export to a txt file. I was able to write part of the lisp myself and I found a lisp online for writing to a text file however I think that is my issue. Below is what i have so far. Thank you in advance for your help. (DEFUN C:testing () (setvar "cmdecho" 1) (vl-load-com) (vlax-for lyr (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))(setq then (cons (vla-get-name lyr) table))) ;retrieve layers in current file (setq now '(BERM BORDER CABLE LINE)) ;preassigned layers to look for (defun ListsDifference ( now then )(if l1(if (vl-some '(lambda ( l ) (member (car now) l)) then)(ListsDifference (cdr now) ls)(cons (car l1) (ListsDifference (cdr now) then))))) ;subtract layers in active file from preassigned list (setq ;attempting to create txt file from of the list differences lyrent (tblnext LListDifference t) dprefx (getvar "dwgprefix") dname1 (getvar "dwgname") dname2 (substr dname1 1 (- (strlen dname1) 4)) ;remove old extension filename (strcat dname2 ".txt") ;add new extension padding " " header1 (substr (strcat "LAYER" padding) 1 30) header (strcat header1) prmpt (strcat dprefx filename) file (open prmpt "a") ) (write-line filename file) (write-line "" file) (write-line header file) (write-line "" file) (while lyrent (setq lyrname (substr (strcat (strcase (cdr (assoc 2 lyrent))) padding) 1 30) lyrdata (strcat lyrname) ) (write-line lyrdata file) (setq lyrent (tblnext LListDifference)) ) (close file) (prompt (strcat "\nCreated " prmpt)) (princ) ) Quote
Emmanuel Delay Posted February 24, 2023 Posted February 24, 2023 Can you repeat what end result you want? You want the current layer list; except skip the layers "BERM", "BORDER", "CABLE", "LINE" Then export that list, right? So just the layer names? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.