Results 1 to 7 of 7

Thread: Change xref colors to match the output file

  1. #1
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Change xref colors to match the output file

    Hi everyone,

    I am looking for a lisp that will change the colors, linetypes, etc of the original file to match the colors, linetypes, etc of the file that it is xref into.

    Thank

  2. #2
    Member
    Join Date
    2011-11
    Posts
    5
    Login to Give a bone
    0

    Default Re: Change xref colors to match the output file

    Try this. It matches color, linetype, lineweight and plottable status.
    Code:
    (defun c:setxlayer ( /
                        xlayer  ; ename of layer to be evaluate
                        xl      ; xlayer dxf lis
                        xname   ; Xref layer name
                        cname   ; current dwg layer name matching xname
                        clayer  ; cname's ename
                        cl      ; current dwg layer's dxf list
                        )            
      (while
        (setq xlayer (tblnext "layer" (not xlayer)))
        (if
          (= 16 (logand 16 (cdr (assoc 70 (setq xl (entget (tblobjname "layer" (cdr (assoc 2 xlayer)))))))))
          (progn
            (setq xname (cdr (assoc 2 xl))
                  cname (substr xname (+ 2 (vl-string-position 124 xname))))
            (if
              (setq clayer (tblsearch "layer" cname))
              (progn
                (setq cl (entget (tblobjname "layer" (cdr (assoc 2 clayer))))) 
                (entmod
                  (mapcar
                    (function
                      (lambda (a)
                        (cond
                          ((= (car a) 62)
                           (cons 62 (if
                                      (minusp (cdr a))
                                      (- (abs (cdr (assoc 62 cl))))
                                      (abs (cdr (assoc 62 cl)))
                                      )
                           ))
                          ((member (car a) '(6 290 370)) (assoc (car a) cl))
                          (T a)
                        )
                      )
                    )
                  xl
                  )
                )
              )
            )
          )
        )
      )
      (princ)
    )

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

    Default Re: Change xref colors to match the output file

    Quote Originally Posted by Stefan BMR View Post
    Try this. It matches color, linetype, lineweight and plottable status.
    Code:
    (defun c:setxlayer ( /
                        xlayer  ; ename of layer to be evaluate
                        xl      ; xlayer dxf lis
                        xname   ; Xref layer name
                        cname   ; current dwg layer name matching xname
                        clayer  ; cname's ename
                        cl      ; current dwg layer's dxf list
                        )            
      (while
        (setq xlayer (tblnext "layer" (not xlayer)))
        (if
          (= 16 (logand 16 (cdr (assoc 70 (setq xl (entget (tblobjname "layer" (cdr (assoc 2 xlayer)))))))))
          (progn
            (setq xname (cdr (assoc 2 xl))
                  cname (substr xname (+ 2 (vl-string-position 124 xname))))
            (if
              (setq clayer (tblsearch "layer" cname))
              (progn
                (setq cl (entget (tblobjname "layer" (cdr (assoc 2 clayer))))) 
                (entmod
                  (mapcar
                    (function
                      (lambda (a)
                        (cond
                          ((= (car a) 62)
                           (cons 62 (if
                                      (minusp (cdr a))
                                      (- (abs (cdr (assoc 62 cl))))
                                      (abs (cdr (assoc 62 cl)))
                                      )
                           ))
                          ((member (car a) '(6 290 370)) (assoc (car a) cl))
                          (T a)
                        )
                      )
                    )
                  xl
                  )
                )
              )
            )
          )
        )
      )
      (princ)
    )
    What about Layer Transparency?



    Also, it may be worth prompting using if these changes will be temporary, in the event that VISRETAIN == 0.

    Cheers
    Last edited by BlackBox; 2014-10-29 at 09:11 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

  4. #4
    Member
    Join Date
    2011-11
    Posts
    5
    Login to Give a bone
    0

    Default Re: Change xref colors to match the output file

    Quote Originally Posted by BlackBox View Post
    What about Layer Transparency?

    Also, it may be worth prompting using if these changes will be temporary, in the event that VISRETAIN == 0.
    Cheers
    Layer transparency? I saw it coming... Hoped OP doesn't need it.
    Code:
    (defun c:setxlayer ( /
                        xlayer  ; ename of layer to be evaluate
                        xl      ; xlayer dxf lis
                        xname   ; Xref layer name
                        cname   ; current dwg layer name matching xname
                        clayer  ; cname's ename
                        cl      ; current dwg layer's dxf list
                        layer_transparency
                        )            
      (while
        (setq xlayer (tblnext "layer" (not xlayer)))
        (if
          (= 16 (logand 16 (cdr (assoc 70 (setq xl (entget (tblobjname "layer" (cdr (assoc 2 xlayer)))))))))
          (progn
            (setq xname (cdr (assoc 2 xl))
                  cname (substr xname (+ 2 (vl-string-position 124 xname))))
            (if
              (setq clayer (tblsearch "layer" cname))
              (progn
                (setq cl (entget (tblobjname "layer" (cdr (assoc 2 clayer))) '("AcCmTransparency")))
                (if
                  (setq layer_transparency (assoc -3 cl))
                  (entmod (append xl (list layer_transparency)))
                  )
                (entmod
                  (mapcar
                    (function
                      (lambda (a)
                        (cond
                          ((= (car a) 62)
                           (cons 62 (if
                                      (minusp (cdr a))
                                      (- (abs (cdr (assoc 62 cl))))
                                      (abs (cdr (assoc 62 cl)))
                                      )
                           ))
                          ((member (car a) '(6 290 370)) (assoc (car a) cl))
                          (T a)
                        )
                      )
                    )
                  xl
                  )
                )
              )
            )
          )
        )
      )
      (princ)
    )

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

    Default Re: Change xref colors to match the output file

    Quote Originally Posted by Stefan BMR View Post
    Layer transparency? I saw it coming... Hoped OP doesn't need it.
    Code:
    (defun c:setxlayer ( /
                        xlayer  ; ename of layer to be evaluate
                        xl      ; xlayer dxf lis
                        xname   ; Xref layer name
                        cname   ; current dwg layer name matching xname
                        clayer  ; cname's ename
                        cl      ; current dwg layer's dxf list
                        layer_transparency
                        )            
      (while
        (setq xlayer (tblnext "layer" (not xlayer)))
        (if
          (= 16 (logand 16 (cdr (assoc 70 (setq xl (entget (tblobjname "layer" (cdr (assoc 2 xlayer)))))))))
          (progn
            (setq xname (cdr (assoc 2 xl))
                  cname (substr xname (+ 2 (vl-string-position 124 xname))))
            (if
              (setq clayer (tblsearch "layer" cname))
              (progn
                (setq cl (entget (tblobjname "layer" (cdr (assoc 2 clayer))) '("AcCmTransparency")))
                (if
                  (setq layer_transparency (assoc -3 cl))
                  (entmod (append xl (list layer_transparency)))
                  )
                (entmod
                  (mapcar
                    (function
                      (lambda (a)
                        (cond
                          ((= (car a) 62)
                           (cons 62 (if
                                      (minusp (cdr a))
                                      (- (abs (cdr (assoc 62 cl))))
                                      (abs (cdr (assoc 62 cl)))
                                      )
                           ))
                          ((member (car a) '(6 290 370)) (assoc (car a) cl))
                          (T a)
                        )
                      )
                    )
                  xl
                  )
                )
              )
            )
          )
        )
      )
      (princ)
    )
    Wonder what would happen if there were multiple XREFs with same layers, but different settings?

    I sure hope they don't need UNDO functionality either.
    "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
    Member
    Join Date
    2011-11
    Posts
    5
    Login to Give a bone
    0

    Default Re: Change xref colors to match the output file

    Quote Originally Posted by BlackBox View Post
    Wonder what would happen if there were multiple XREFs with same layers, but different settings?
    It seems to me you didn't test it...

    I sure hope they don't need UNDO functionality either.
    My mistake. I'll update, if necessary.

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

    Default Re: Change xref colors to match the output file

    Quote Originally Posted by Stefan BMR View Post
    It seems to me you didn't test it...
    Incorrect; to clarify, see the bottom of this post.



    Quote Originally Posted by Stefan BMR View Post
    My mistake. I'll update, if necessary.
    You've done well so far, add only what you're willing to.

    Cheers
    "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

Similar Threads

  1. 2012: Area plan colors don't match legend colors
    By drubinoff in forum Revit Architecture - General
    Replies: 0
    Last Post: 2013-08-24, 05:36 PM
  2. Change entities colors to match pen style
    By PMPFern in forum AutoCAD General
    Replies: 2
    Last Post: 2009-07-09, 01:34 PM
  3. Replies: 5
    Last Post: 2009-04-08, 06:24 AM
  4. LISP to change layer colors to random colors
    By mtubbs in forum AutoLISP
    Replies: 10
    Last Post: 2007-04-27, 05:39 AM
  5. Replies: 1
    Last Post: 2005-08-13, 04:37 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
  •