XREF Information

Discussion in 'AutoCAD' started by Bruce Sheldon, Aug 17, 2004.

  1. Does anyone have any LISP routine(s) that will report the status of all the
    XREF's in the current drawing? Especially I would like to query whether an
    xref was found or not, and also if the file is loaded or unloaded. I see
    there are some DXF codes for determining overlay vs attach, etc. Perhaps
    the 32 flag will tell me what I need to know, but any input on this subject
    would be much appreciated. Thanks.

    Bruce
     
    Bruce Sheldon, Aug 17, 2004
    #1
  2. Bruce Sheldon

    T.Willey Guest

    This is what I use. Hope it helps.
    Tim

    (defun c:xr-check(/ tbl1 bname btype btype2 bpath bpath2 blist blist2 cnt1 cnt2 cnt3 op1 op2 cmd1 bdwg olderr)
    ;
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (setq olderr *error* *error* xr-err)
    (setq cmd1 (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq cnt1 T)
    (while (setq tbl1 (tblnext "block" cnt1))
    (if (setq bpath (cdr (assoc 1 tbl1)))
    (progn
    (setq bname (cdr (assoc 2 tbl1)))
    (if (= (logand 32 (cdr (assoc 70 tbl1))) 0)
    (if (findfile bpath)
    (progn
    (setq btype "Unloaded")
    (setq blist (append blist (list bname)))
    (setq cnt2 "Yes")
    )
    (progn
    (setq btype (strcat "Not-Found (Can't find drawing file \"" bname "\")"))
    (setq blist2 (append blist2 (list bname)))
    (setq cnt3 "Yes")
    )
    )
    (setq btype "Loaded")
    )
    (if (= (logand 8 (cdr (assoc 70 tbl1))) 0)
    (setq btype2 "Attach")
    (setq btype2 "Overlay")
    )
    (princ (strcat "\n" bname " - " btype2 " - " btype))
    )
    )
    (if cnt1 (setq cnt1 nil))
    )
    (if (not btype)
    (princ "\n No Xref in drawing. ")
    (textpage)
    )
    (if (= cnt2 "Yes")
    (progn
    (initget "Y N")
    (setq op1 (getkword "\nWould you like to reload all \"Unloaded\" xrefs [<Y>,N]? "))
    (if op1
    (setq op1 (strcase op1))
    (setq op1 "Y")
    )
    (if (= op1 "Y")
    (foreach item blist
    (command "_.xref" "_r" item)
    )
    )
    )
    )
    (if (= cnt3 "Yes")
    (progn
    (initget "Y N")
    (setq op2 (getkword "\nWould you like to fix \"Not-Found\" xref paths (one at a time) [<Y>,N]? "))
    (if op2
    (setq op2 (strcase op2))
    (setq op2 "Y")
    )
    (if (= op2 "Y")
    (progn
    (graphscr)
    (if (not bpath2)
    (setq bpath2 "H:\\")
    )
    (foreach item blist2
    (if (setq bdwg (getfiled (strcat "Select file \""item"\"") bpath2 "dwg" 16))
    (progn
    (setq bpath2 (vl-filename-directory bdwg))
    (command "_.xref" "_p" item bdwg)
    )
    )
    )
    )
    )
    )
    )
    (command "_.undo" "_end")
    (setvar "cmdecho" cmd1)
    (princ)
    )

    ;=======================================================

    (defun xr-err (msg /)

    (graphscr)
    (setq *error* olderr)
    (command "_.undo" "_end")
    (setvar "cmdecho" cmd1)
    (princ "\n Function cancelled.")
    )
     
    T.Willey, Aug 17, 2004
    #2
  3. Thanks, T, saved me about of day of coding!!!

    cnt2 cnt3 op1 op2 cmd1 bdwg olderr)
     
    Bruce Sheldon, Aug 17, 2004
    #3
  4. Bruce Sheldon

    T.Willey Guest

    Glad it works for someone besides me.

    Tim
     
    T.Willey, Aug 17, 2004
    #4
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.