Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Layer Color Change LISP Routine

  1. #1
    Login to Give a bone
    0

    Default Layer Color Change LISP Routine

    Hi all,

    Just joined the site today and it looks very helpful. Hoping to
    learn a lot and broaden my basic lisp routine skills. Was wondering if anyone
    could help me with this lisp routine.

    When I get a drawing from a
    architect its usually filled with all kinds of colors. I manually usually run a
    burst lisp routine to break the blocks apart and get them to there true layer
    state. Then I will select all objects in the drawing and turn then over to color
    250 so they will plot very faded and light and my customers can focus on my fire
    sprinkler drawings more. Is that a way to have a list routine do this for me?
    Possibly with out having to explode the blocks and make the drawing huge? Even
    if the routine couldn't burst then change all objects over to color 250 that
    would be fine also.

    Looking forward to hear from a professional

    Rodney

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Try this code and select the block that you want to change their element's colors to color number 250

    Code:
    (defun c:Test (/ ss i sn name lst)
      (vl-load-com)
      ;;;        ------ Tharwat 15. June. 2012 -----      ;;;
      ;;; codes to change elements in the selected blocks ;;;
      ;;;                  to color 250                   ;;;
      (if (not acdoc)
        (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
      )
      (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (if (not (member (setq name (cdr (assoc 2 (entget sn)))) lst))
            (progn
              (setq lst (cons name lst))
              (vlax-for each (vla-item (vla-get-blocks acdoc) name)
                (vla-put-color each 250)
              )
            )
          )
        )
        (princ)
      )
      (if ss
        (vla-regen acdoc AcAllviewports)
      )
      (princ)
    )

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Provided you open the received drawing (without already inserting it into another of your drawings, etc.), you can run this once, and BOOM:

    Code:
    (defun c:BOOM ()
      (command "._setbylayer" (ssget "_x") "" "yes" "yes" "._-layer" "color" 250 "*" "")
      (princ))
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Quote Originally Posted by RenderMan View Post
    Code:
    (defun c:BOOM ()
      (command "._setbylayer" (ssget "_x") "" "yes" "yes" "._-layer" "color" 250 "*" "")
      (princ))
    SETBYLAER

    crawling... crawling..... I'm just too slow.....

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Quote Originally Posted by pbejse View Post
    SETBYLAER

    crawling... crawling..... I'm just too slow.....
    SETBYLAYER's the bomb (pun intended)...
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Quote Originally Posted by RenderMan View Post
    SETBYLAYER's the bomb (pun intended)...
    Yup, Saw your post on another window even before i clicked Post Quick Reply , I would've named it BAM!!!! if ever i'll get to the point that i can outdraw you RenderMan


  7. #7
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Man you guys ROCK!!!!!!!! Just saved me a ton of time! Can I donate to this site?

    Quote Originally Posted by RenderMan View Post
    Provided you open the received drawing (without already inserting it into another of your drawings, etc.), you can run this once, and BOOM:

    Code:
    (defun c:BOOM ()
      (command "._setbylayer" (ssget "_x") "" "yes" "yes" "._-layer" "color" 250 "*" "")
      (princ))

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Quote Originally Posted by guardianfiredesign774457 View Post
    Man you guys ROCK!!!!!!!! Just saved me a ton of time! Can I donate to this site?
    That is kind of you to say; There's no need for donations, we're happy to help... Just learn what you can, and help someone else when the opportunity presents itself.

    Quote Originally Posted by pbejse View Post
    I would've named it BAM!!!!
    Name it what you like, I was going for a punny (this commercial cracks us up at home):

    Quote Originally Posted by pbejse View Post
    if ever i'll get to the point that i can outdraw you RenderMan

    Ha, ha, it's not about 'firing' first, it's about getting the job done.

    (Inappropriate content)
    Last edited by peter; 2012-06-15 at 07:36 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Ok so it seems these codes you guys provided will turn even my title block and my blocks that i want red and other colors to be turned to 250 Is there a way to select only the iteams you want changed to be turned to 250? Like have the routine ask you to select all objects, grab them all then BOOM?

    Quote Originally Posted by RenderMan View Post
    That is kind of you to say; There's no need for donations, we're happy to help... Just learn what you can, and help someone else when the opportunity presents itself.



    Name it what you like, I was going for a punny (this commercial cracks us up at home):



    Ha, ha, it's not about 'firing' first, it's about getting the job done.

    (Inappropriate content)

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Layer Color Change LISP Routine

    Quote Originally Posted by RenderMan View Post

    (Inappropriate content)
    ... Seriously?

    Quote Originally Posted by guardianfiredesign774457 View Post
    Ok so it seems these codes you guys provided will turn even my title block and my blocks that i want red and other colors to be turned to 250 Is there a way to select only the iteams you want changed to be turned to 250? Like have the routine ask you to select all objects, grab them all then BOOM?
    Just guessing:

    Code:
    (defun c:BOOM ( / *error* ss oss layerName layers)
      (vl-load-com)
    
      (if (setq ss (ssget "_:L" '((0 . "INSERT"))))
        (progn
          (vlax-for x  (setq oss (vla-get-activeselectionset
                                   (vla-get-activedocument
                                     (vlax-get-acad-object))))
            (if
              (not (vl-position (setq layerName (vla-get-layer x)) layers))
               (setq layers (cons layerName layers))))
          (vla-delete oss)
          (command
            "._setbylayer"
            ss
            ""
            "yes"
            "yes"
            "._-layer"
            "color"
            250
            (vl-string-right-trim
              ","
              (apply 'strcat (mapcar '(lambda (x) (strcat x ",")) layers)))
            ""))
        (prompt "\n** Nothing selected ** "))
      (princ))
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2015-02-16, 07:53 PM
  2. Replies: 8
    Last Post: 2015-01-06, 01:15 PM
  3. Help with this color change LISP routine
    By jeff.richards in forum AutoLISP
    Replies: 4
    Last Post: 2008-11-26, 02:54 PM
  4. Lisp to change layer color in viewport
    By moonlight_9630 in forum AutoLISP
    Replies: 2
    Last Post: 2008-07-08, 07:31 PM
  5. Replies: 10
    Last Post: 2007-04-27, 06:17 PM

Tags for this Thread

Posting Permissions

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