+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default Export layers list (only a selection)

    Registered forum members do not see this ad.

    I have this routine (unknown to the author). Thank you for your help with the following change: Export the list of layers but only on a selection.


    Code:
    (defun c:LL2T ( / oecho clrlst dwgnm fn fh lyr lyrlst)
    (defun chkbit (bit_val num)
    (not (zerop (logand bit_val num)))
    )
    (setq
    oecho (getvar "cmdecho")
    clrlst (list
    (cons 1 "RED")
    (cons 2 "YELLOW")
    (cons 3 "GREEN")
    (cons 4 "CYAN")
    (cons 5 "BLUE")
    (cons 6 "MAGENTA")
    (cons 7 "WHITE")
    )
    dwgnm (getvar "dwgname")
    )
    (setvar "cmdecho" 0)
    (setq fn (getfiled " File name: " (strcat dwgnm ".LS") "LS" (+ 1 2))
    )
    (while (setq lyr (tblnext "layer" (not lyr)))
    (setq lyrlst (cons (cdr (assoc 2 lyr)) lyrlst))
    )
    (setq lyrlst (acad_strlsort lyrlst))
    (princ "\nWriting layer data to file...")
    (setq fh (open fn "w"))
    (princ (strcat dwgnm ".DWG\n") fh)
    (foreach x lyrlst
    (setq
    lyr (tblsearch "layer" x)
    lyrname (cdr (assoc 2 lyr))
    lyrclr (cdr (assoc 62 lyr))
    lyrlt (cdr (assoc 6 lyr))
    frzn? (chkbit 1 (cdr (assoc 70 lyr)))
    lokd? (chkbit 4 (cdr (assoc 70 lyr)))
    )
    (if (minusp lyrclr)
    (setq
    on? "OFF"
    lyrclr (abs lyrclr)
    )
    (setq on? "ON")
    )
    (if (assoc lyrclr clrlst)
    (setq lyrclr (cdr (assoc lyrclr clrlst)))
    )
    (if frzn?
    (setq frzn? "FROZEN")
    (setq frzn? "THAWED")
    )
    (if lokd?
    (setq lokd? "LOCKED")
    (setq lokd? "UNLOCKED")
    )
    (princ lyrname fh)
    ;;(princ "," fh)
    ;;(princ lyrclr fh)
    ;;(princ "," fh)
    ;;(princ lyrlt fh)
    ;;(princ "," fh)
    ;;(princ on? fh)
    ;;(princ "," fh)
    ;;(princ frzn? fh)
    ;;(princ "," fh)
    ;;(princ lokd? fh)
    (princ "\n" fh)
    )
    (princ "done.")
    (close fh)
    (setvar "cmdecho" oecho)
    (princ)
    )

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Here is a similar program with a few more options - also, note that you can select layers from the Layer Manager and copy them directly.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    Lee, fantastic tool, as expected. Thank you for your statement. Already I kept. However, for this, I just want to extract the names of the layers contained in a selection, not the entire design.

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Maybe something like this?
    Code:
    (defun c:layernames ( / f l s x )
        (if (and (setq s (ssget))
                 (setq f (getfiled "Create File" "" "txt" 1))
            )
            (if (setq f (open f "w"))
                (progn
                    (repeat (setq i (sslength s))
                        (or (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l)
                            (and (write-line x f)
                                 (setq l (cons x l))
                            )
                        )
                    )
                    (close f)
                )
                (princ "\nUnable to open file for writing.")
            )
        )
        (princ)
    )
    [Untested]
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    Lee, that's exactly. Better, just even making out the list sorted alphabetically. Thank you!

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Quote Originally Posted by teknomatika View Post
    Lee, that's exactly. Better, just even making out the list sorted alphabetically. Thank you!
    You're welcome! - For an alphabetically sorted output, try the following:
    Code:
    (defun c:layernames ( / f l s x )
        (if (and (setq s (ssget))
                 (setq f (getfiled "Create File" "" "txt" 1))
            )
            (if (setq f (open f "w"))
                (progn
                    (repeat (setq i (sslength s))
                        (or (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l)
                            (setq l (cons x l))
                        )
                    )
                    (foreach x (acad_strlsort l) (write-line x f))
                    (close f)
                )
                (princ "\nUnable to open file for writing.")
            )
        )
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    247

    Default

    Lee, you're the best. But also generous. Thank you!

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,368

    Default

    Registered forum members do not see this ad.

    ........
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Export cui as indented text list
    By samifox in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 1
    Last Post: 25th Apr 2015, 03:03 am
  2. List box selection changes radio_row selection?
    By LosGirk in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 9th Jan 2015, 07:19 am
  3. how can i exclude the xref layers from the layers list?
    By samifox in forum AutoCAD General
    Replies: 8
    Last Post: 7th Mar 2014, 02:49 pm
  4. List to Selection set
    By satishrajdev in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 1st Nov 2013, 02:37 pm
  5. Export your layer list to Excel
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 17th Aug 2011, 12:50 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts