Help with an xref lisp

Discussion in 'AutoCAD' started by The real JD, Jan 28, 2004.

  1. The real JD

    The real JD Guest

    I have a lisp that will convert all xrefs in a drawing to layer color 9.
    Is it a big deal to change it, so i can pick the xref that I want changed
    instead of changing all of them? TIA

    ;;CADALYST 08/03 Tip1888: XREFTO9.LSP XREFS TO COLOR 9 (c) 2003 Jeff
    Mishler
    ;; Routine to set all model space Xref ;layers to color 9
    ;; by Jeff Mishler, 5/3/03


    (defun C:XREFTO9 (/ ssblk cnt blknames lay ename)
    (setq ssblk (ssget "x" '((0 . "INSERT") (410 . "Model"))))
    (setq cnt 0)
    (setq blknames "")
    (repeat (sslength ssblk) ; create list of block names in Model space for
    filter list
    (setq blknames (strcat blknames
    (cdr (assoc 2 (entget (ssname ssblk cnt))))
    "|*,"
    )
    )
    (setq cnt (1+ cnt))
    )
    (setq lay (tblnext "layer" t)) ;get layer entity
    (command "undo" "be")
    (while (/= lay nil)
    (if (wcmatch (cdr (assoc 2 lay)) blknames)
    ;find xref layers, could use assoc 70 instead
    (progn
    (setq ename (tblobjname "layer" (cdr (assoc 2 lay))))
    (setq lay (entget ename))
    (if (> (cdr (assoc 62 lay)) 0) ; is the layer on?
    (setq lay (subst (cons 62 9) (assoc 62 lay) lay)) ; yes it is
    (setq lay (subst (cons 62 -9) (assoc 62 lay) lay))
    ; no, it's off
    )
    (entmod lay)
    )
    )
    (setq lay (tblnext "layer")) ; next layer
    )
    (if ename
    (prompt
    "All xref layers in Model space (except \"0\" and \"defpoints\") now
    color 9!"
    )
    (prompt "No xref layers found in Model Space!")
    )
    (command "undo" "end")
    (princ)
    )
     
    The real JD, Jan 28, 2004
    #1
  2. The real JD

    Jeff Mishler Guest

    Heh, That's mine! ;-)

    Just remove the "x" from the line (setq ssblk (ssget "x" '((0 . "INSERT")
    (410 . "Model"))))
    and that should do it. Might want to change the prompt near the end to
    reflect "the selected xref layers ....."

    Jeff
     
    Jeff Mishler, Jan 28, 2004
    #2
  3. The real JD

    The real JD Guest

    Thanks Jeff!

    :)

     
    The real JD, Jan 30, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.