Results 1 to 9 of 9

Thread: changing xref layer colors

  1. #1
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default changing xref layer colors

    I am looking for code to change the color of all xref dependant layers to color 251, without autocad turning "on" all xref layers.

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Code:
    (defun c:xr-c(/ xr1 xr2 xr3 xr4 xr5 xr6 tx1 xclr ocmd llist temp1)
    ; Change all the layers of an xref to selected color.
    
    (vl-load-com)
    (setq ocmd (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (if (setq xr1 (entsel "\nSelect xref to change color of all layers: "))
      (progn
        (setq xr2 (entget (car xr1)))
        (setq tx1 (cdr (assoc 0 xr2)))
        (if
          (and
            (= tx1 "INSERT")
            (setq xr3 (cdr (assoc 2 xr2)))
            (setq xr4 (tblsearch "block" xr3))
            (setq xr5 (cdr (assoc 1 xr4)))
          )
          (if (setq xclr (acad_colordlg 251))
            (progn
              (if (assoc 62 xr2)
               (entmod (subst (cons 62 xclr) (assoc 62 xr2) xr2))
               (entmod (append xr2 (list (cons 62 xclr))))
              )
              (setq xr6 (strcat xr3 "|"))
              (setq llist (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
              (vlax-for item llist
                (if (vl-string-search xr6 (vlax-get item 'Name))
                  (progn
                    (setq temp1 (vlax-get item 'TrueColor))
                    (vlax-put temp1 'ColorIndex (rtos xclr 2 0))
                    (vlax-put item 'TrueColor temp1)
                  )
                )
              )
            )
          )
          (prompt "\n No X-Ref selected.")
        )
      )
      (prompt "\n Nothing selected")
    )
    (command "_.regenall")
    (command "_.undo" "_end")
    (setvar "cmdecho" ocmd)
    (princ)
    )

  3. #3
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    This is great, but I need it to automatically select all xrefs (not prompt for a selection), and auto set the colors to 251 (no color dialog box). Thanks

  4. #4
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Script version:
    Code:
    -LAYER
    C
    251
    *|*
    Chris

  5. #5
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Quote Originally Posted by FRAMEDNLV
    Script version:
    Code:
    -LAYER
    C
    251
    *|*
    Chris
    I know how to change the layer colors. The problem occurs when I change the color of xref layers that are turned "off". Autocad turns all the xref layers "on" when the layer color is changed.

  6. #6
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Code:
    (defun c:Test (/ ActDoc)
    
    (vlax-for Lay (vla-get-Layers (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))))
     (if (vl-string-search "|" (vla-get-Name Lay))
      (vla-put-Color Lay 251)
     )
    )
    (vla-Regen ActDoc acActiveViewport)
    (princ)
    )

  7. #7
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Quote Originally Posted by T.Willey
    Code:
    (defun c:Test (/ ActDoc)
    
    (vlax-for Lay (vla-get-Layers (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))))
     (if (vl-string-search "|" (vla-get-Name Lay))
      (vla-put-Color Lay 251)
     )
    )
    (vla-Regen ActDoc acActiveViewport)
    (princ)
    )
    Perfect! Thank you

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    You're welcome.

  9. #9
    Woo! Hoo! my 1st post
    Join Date
    2011-12
    Posts
    1
    Login to Give a bone
    0

    Default Re: changing xref layer colors

    Hi mtubbs,

    I love this, could you write one that lets you select on screen individual xref layers to change? That would be awesome if it was possible...

    found it!
    http://forums.augi.com/showthread.php?t=61726
    Last edited by miffbenita848624; 2012-01-12 at 12:01 AM. Reason: found solution

Similar Threads

  1. changing layer colors
    By dsillence504446 in forum AutoLISP
    Replies: 5
    Last Post: 2014-10-15, 07:47 PM
  2. Changing color of Xref layers based on color and layer name
    By tuerlinckx_peter862162 in forum AutoLISP
    Replies: 7
    Last Post: 2013-02-14, 06:46 PM
  3. LISP to change layer colors to random colors
    By mtubbs in forum AutoLISP
    Replies: 10
    Last Post: 2007-04-27, 05:39 AM
  4. Compare layer colors to pantone colors
    By gandre in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2005-11-18, 01:32 PM
  5. Lisp for changing layer color in XREF's
    By cadd4la in forum AutoLISP
    Replies: 5
    Last Post: 2005-09-28, 01:16 PM

Posting Permissions

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