+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17
  1. #11
    Full Member Smirnoff's Avatar
    Using
    AutoCAD 2011
    Join Date
    Feb 2011
    Location
    Riga, Latvia
    Posts
    57

    Default

    Registered forum members do not see this ad.

    ASMI, is that you?
    Yes, it's mi. Thank you Lee Mac.

  2. #12
    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
    15,708

    Default

    Great to see you around here again! Its been a long time
    Lee Mac Programming

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

    Just another Swamper

  3. #13
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    Quote Originally Posted by Smirnoff View Post
    Here is very good solution. Entmod entity and create layer at once.
    Thanks! I try keep things simple like my mind <g> It is good to see you back! -David
    R12 (Dos) - A2K

  4. #14
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Aug 2010
    Posts
    6

    Default

    Quote Originally Posted by David Bethel View Post
    Or something fairly simple should work as well:

    Code:
    (defun c:enc (/ ss en ed clr)
      (and (setq ss (ssget))
           (while (setq en (ssname ss 0))
                  (setq ed (entget en))
                  (if (setq clr (cdr (assoc 62 ed)))
                      (entmod (subst (cons 8 (strcat "C" (itoa clr)))
                                     (assoc 8 ed) ed)))
                 (ssdel en ss)))
      (prin1))

    Bylayer entities are not affected. New layer name is "C" and the color number. -David
    hi david, this is working like a charm, what could i do for the "by layer" entities is there another lisp that can swap the "by layer" with the actual color?. Also could this also be done adding linetype? generating layers based on color and linetype. layers could be named like "C8 hidden, C8 continuous, C11 dashdot, C11 hidden..."

    thanks guys

  5. #15
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    For layer color and linetype - ( this could give a layer "C256-BYLAYER" )

    Code:
    (defun c:encl (/ ss en ed nl)
      (and (setq ss (ssget))
           (while (setq en (ssname ss 0))
                  (setq ed (entget en))
                  (setq nl (if (assoc 62 ed)
                               (strcat "C" (itoa (cdr (assoc 62 ed))))
                               "C256"))
                  (setq nl (if (assoc 6 ed)
                               (strcat nl "-" (cdr (assoc 6 ed)))
                               (strcat nl "-BYLAYER")))
                  (entmod (subst (cons 8 nl) (assoc 8 ed) ed))
                  (ssdel en ss)))
      (prin1))
    For a bylayer values I would go to the layer table and find out what color and / or linetype is currently assigned to that layer.

    The default being "C7-CONTINUOUS"


    There are probably a lot more elegant ways of doing this but who said I was elegant <g> -David
    R12 (Dos) - A2K

  6. #16
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925

    Default

    With layer color and linetypes

    Code:
    ;;;CHANGED SELECTED ENTITIES TO CORRESPONDING COLOR
    ;;;AND LINETYPE LAYER
    
    (defun c:encld (/ ss en ed nl la ld nc nt ll)
      (and (setq ss (ssget))
           (while (setq en (ssname ss 0))
                  (setq ed (entget en)
                        la (cdr (assoc 8 ed))
                        ld (tblsearch "LAYER" la)
                        nc (itoa
                            (abs
                             (cdr (assoc 62 (if (assoc 62 ed) ed ld)))))
                        nt (cdr (assoc 6 (if (assoc 6 ed) ed ld)))
                        nl (strcat "C" nc "-" nt))
                  (if (not (assoc nl ll))      ;;;SETUP LAYER DATA LIST
                      (setq ll (cons (list nl "_C"  nc) ll)
                            ll (cons (list nl "_LT" nt) ll)))
                  (entmod (subst (cons 8 nl) (assoc 8 ed) ed))
                  (ssdel en ss)))
    
    ;;;SETUP NEW LAYER COLORS AND LINETYPES
      (command "_.LAYER")
      (foreach v ll
        (command (nth 1 v) (nth 2 v) (nth 0 v)))
      (command "")
    
      (prin1))

    Have Fun -David
    R12 (Dos) - A2K

  7. #17
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Aug 2010
    Posts
    6

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by David Bethel View Post
    With layer color and linetypes

    Code:
    ;;;CHANGED SELECTED ENTITIES TO CORRESPONDING COLOR
    ;;;AND LINETYPE LAYER
    
    (defun c:encld (/ ss en ed nl la ld nc nt ll)
      (and (setq ss (ssget))
           (while (setq en (ssname ss 0))
                  (setq ed (entget en)
                        la (cdr (assoc 8 ed))
                        ld (tblsearch "LAYER" la)
                        nc (itoa
                            (abs
                             (cdr (assoc 62 (if (assoc 62 ed) ed ld)))))
                        nt (cdr (assoc 6 (if (assoc 6 ed) ed ld)))
                        nl (strcat "C" nc "-" nt))
                  (if (not (assoc nl ll))      ;;;SETUP LAYER DATA LIST
                      (setq ll (cons (list nl "_C"  nc) ll)
                            ll (cons (list nl "_LT" nt) ll)))
                  (entmod (subst (cons 8 nl) (assoc 8 ed) ed))
                  (ssdel en ss)))
    
    ;;;SETUP NEW LAYER COLORS AND LINETYPES
      (command "_.LAYER")
      (foreach v ll
        (command (nth 1 v) (nth 2 v) (nth 0 v)))
      (command "")
    
      (prin1))

    Have Fun -David
    awesome david, many thanks!

Similar Threads

  1. Routine to generate layouts based on rectangles in a larger drawing
    By ABuckingham in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 9th Dec 2012, 08:37 am
  2. creating layers by color
    By gib65 in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 7th Jul 2011, 12:50 am
  3. Change Layers Based On Text Height
    By peterk92 in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 1st Oct 2010, 11:08 am
  4. layers color and printing
    By hamedo_kool in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 13th Mar 2009, 03:25 pm
  5. disable 'reconcile layers' dialogue based on autocad version
    By P Zero in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 23rd Jul 2008, 09:20 am

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