Announcement

Collapse
No announcement yet.

Converting known layer colors on an XREF to another set of know layer colors...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting known layer colors on an XREF to another set of know layer colors...

    Hey all - SO I apologize in advance. This is my first attempt at a LISP and I keep getting a syntax error. Could anyone take a look at this and see if they can correct me? I'm looking to be able to choose an xref and change all the colors, by layer, to another set of colors. Thanks in advance!!!!
    Code:
    (defun c:laycol(/ ColLst ActDoc Sel Clr Data XrName )
    ; Change all the layers of an xref to preordained colors.
    
    (vl-load-com)
    (setq colLst '(
    (1 . 231)
    (2 . 232)
    (3 . 233)
    (4 . 234)
    (5 . 235)
    (6 . 236)
    (7 . 237)
    (8 . 238)
    (9 . 239)
    (10 . 240)
    (11 . 241)
    (12 . 242)
    (13 . 243)
    (14 . 244)
    (15 . 245)
    (16 . 246)
    (17 . 247)
    (18 . 248)
    (19 . 249)
    )
    )
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    (initget "All")
    (if
    (and
    (setq Sel (entsel "\n Select xref to change colors of all layers: "))
    (setq XrName
    (if (= Sel "All")
    "*|*"
    (if
    (and
    (setq Data (entget (car Sel)))
    (= (cdr (assoc 0 Data)) "INSERT")
    (setq XrName (cdr (assoc 2 Data)))
    (equal (logand (cdr (assoc 70 (tblsearch "block" XrName))) 4) 4)
    )
    (setq XrName (strcat XrName "|*"))
    )
    )
    )
    )
    (progn
    (vlax-for i (vla-get-Layers ActDoc)
    (setq lay (cons l lay)))
    (foreach layer lay
    (if
    (setq col
    (assoc (vla-get-color layer) colLst)
    )
    (vla-put-color layer
    (cdr col)
    )
    )
    )
    (vla-Regen ActDoc acActiveViewport)
    )
    )
    (vla-EndUndoMark ActDoc)
    (princ)
    )
Working...
X