Darken Layer Colors...

Discussion in 'AutoCAD' started by Sage Cowsert, Jul 29, 2003.

  1. Sage Cowsert

    Sage Cowsert Guest

    Every once in a while I'd like to have a few layers stand out on my screen
    almost like an in place block & xref edit does but for non blocks.

    Has anyone writen code to do this. Say turn all layers that are color Green
    to color 84?
     
    Sage Cowsert, Jul 29, 2003
    #1
  2. Sage Cowsert

    Jeff Mishler Guest

    Like this?
    ;; Routine to swap layer color. All layers of 'oldcol' will be 'newcol'
    ;; by Jeff Mishler, 7/29/03
    ;; usage - (lay_color 2 84) this will change all layers with yellow(2) to
    84
    ;; Note: colors must be in integer form, no names allowed

    (defun lay_color (oldcol newcol / lay)
    (while (setq lay (tblnext "layer" (not lay)))
    (setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay)))))
    (if (= oldcol (cdr (assoc 62 lay)))
    (progn
    (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay))
    (entmod lay)
    )
    )
    )
    (princ)
    )

    Jeff
     
    Jeff Mishler, Jul 29, 2003
    #2
  3. Sage Cowsert

    Sage Cowsert Guest

    Thanks Jeff. I swear I tried that earlier but it didn't work. Works great
    now. Where's what I ended up with. Btw... this uses Bonus tools.

    (defun c:darken (/ lay colorlist lay asslist newcol)
    (load "lman")
    (bns_sl "PreDarken")
    (setq colorlist
    (list '(1 14) '(2 54) '(3 94) '(4 134) '(5 166) '(6 216) '(7 253) '(8
    251))
    )
    (while (setq lay (tblnext "layer" (not lay)))
    (setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay)))))
    (if (setq asslist (assoc (cdr (assoc 62 lay)) colorlist)) ;oldcol (cdr
    (assoc 62 lay)))
    (progn
    (setq oldcol (car asslist)
    newcol (cadr asslist)
    )
    (setq lay (subst (cons 62 newcol) (assoc 62 lay) lay))
    (entmod lay)
    )
    )
    )
    (princ)
    )

    (defun c:undarken ()
    (bns_rl "Predarken")
    (bns_dl "PreDarken")
    )


    --
    Remove 50+1 in my email address to send me an email
     
    Sage Cowsert, Jul 29, 2003
    #3
  4. Sage Cowsert

    Jeff Mishler Guest

    Or, for the Bonus\Express Tools impaired:

    ;;Routine to swap layer colors.
    ;;by Jeff Mishler, 7/29/03

    (defun lay_color (/ colorlist lay assoclist)
    (setq colorlist
    (list
    '(1 14) '(2 54) '(3 94) '(4 134) '(5 166) '(6 216) '(7 253) '(8 251)
    )
    )
    (if lightflag (setq colorlist (mapcar 'reverse colorlist)))
    (while (setq lay (tblnext "layer" (not lay)))
    (setq lay (entget (tblobjname "layer" (cdr (assoc 2 lay)))))
    (if (setq assoclist (assoc (cdr (assoc 62 lay)) colorlist))
    (progn
    (setq lay (subst (cons 62 (cadr assoclist)) (assoc 62 lay) lay))
    (entmod lay)
    )
    )
    )
    (princ)
    )

    (defun c:darken ()
    (lay_color)
    (princ)
    )

    (defun c:lighten (/ lightflag)
    (setq lightflag t)
    (lay_color)
    (princ)
    )

     
    Jeff Mishler, Jul 30, 2003
    #4
  5. Sage Cowsert

    Sage Cowsert Guest

    Interesting. The only concern I have is that you may be merging one color
    with an existing one. When its lightened it'll change it.

    Say for example. Color starts out as color 14.

    Darken doesn't do anything with it. Lighten changes it to color 1.
     
    Sage Cowsert, Jul 30, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.