Results 1 to 5 of 5

Thread: Help with this color change LISP routine

  1. #1
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Help with this color change LISP routine

    AutoLISP Gurus,

    I managed to write this routine to change the color of a given group of layers. The problem is that when I try to use it on drawings that don't contain all layers listed, it doesn't work. I attempted to write an IF function that would check for the layer first, if it exists, then execute the command, if not, do nothing or print "no such layer" and move on, but it isn't working.

    Any thougts are appreciated.
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    2006-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: Help with this color change LISP routine

    Try this
    Code:
    (defun LYCLR (LAYER COLOR / OBJNAME LAYLST)
      (if (tblsearch "LAYER" LAYER)
        (progn
         (setq LAYLST (assoc 62 (tblsearch "LAYER" LAYER)))
          (setq OBJNAME (tblobjname "LAYER" LAYER))
          (entmod (subst (cons 62 COLOR) LAYLST (entget OBJNAME)))
        )
        (print "no such layer")
      ) ;_ end of if
    ) ;_ end of defun

  3. #3
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Re: Help with this color change LISP routine

    Hrothgar,

    Thanks so much, that worked!

    So if I understand what was happening, when using IF by itself it expects only one expression where I was giving it three, and by nesting the PROGN function inside, LISP interpretted all expressions as one?

    Thanks Again,

  4. #4
    Member
    Join Date
    2006-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: Help with this color change LISP routine

    Yes that's right.

    Also, someone else can probably say for sure, but I think overall it would run faster if you stored layer names and colors in a dotted pair list ie. (("layer1 . 2) ("layer2" . 4)), and then processed the list in one routine instead of multiple calls to Lyclr. But I'm only talking fractions of a second most likely, so it may not be worth the trouble at this point.
    Last edited by Hrothgar; 2008-11-25 at 11:42 PM.

  5. #5
    Active Member
    Join Date
    2004-10
    Location
    Wheat Ridge, Colorado
    Posts
    97
    Login to Give a bone
    0

    Default Re: Help with this color change LISP routine

    Many thanks. I will try using dotted pairs as I develop the routine.

    Peace,

Similar Threads

  1. Change color of changed text routine
    By jayhay35365091 in forum AutoLISP
    Replies: 4
    Last Post: 2014-08-04, 07:44 PM
  2. LISP for change yellow color into Color 8
    By rhodinj1427782 in forum AutoLISP
    Replies: 6
    Last Post: 2014-01-16, 05:26 AM
  3. Layer Color Change LISP Routine
    By guardianfiredesign774457 in forum AutoLISP
    Replies: 19
    Last Post: 2013-08-28, 05:08 AM
  4. Replies: 10
    Last Post: 2007-05-06, 08:18 AM
  5. Color Change Routine - Layers & Objects
    By JohnnyFortune in forum AutoLISP
    Replies: 2
    Last Post: 2006-12-07, 12:24 AM

Posting Permissions

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