xref auto-reload?????

Discussion in 'AutoCAD' started by Caddog, Apr 14, 2004.

  1. Caddog

    Caddog Guest

    Has anyone worked on a lisp that can be run to reload any xrefs that have
    been updated? I don't want to reload all xrefs because some of them have
    been unloaded for a reason?

    any help would be nice.

    Thanks
     
    Caddog, Apr 14, 2004
    #1
  2. Caddog

    ffejgreb Guest

    I culled this from a routine I created to kinda do what you need. It will
    check the status of a specific xref and then load or reload depending on its
    status. You will need to modify a couple of lines (I tried to make it
    apparent) to suit your file/xref names.

    HTH,

    Jeff


    ;;;Functions common to all routines

    ;;The first two defuns (CSP and CURRENTSPACE) are courtesy of Luis Esquivel
    ;;Everything else is with thanks to the Autodesk customization newsgroup and
    all those
    ;;that help anyone willing to learn that asks for it.

    (defun CSP ()
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    )

    (defun CURRENTSPACE ()
    (setq CSPACE
    (cond
    ((eq (vla-get-activespace (CSP)) 1) "model")
    (t
    (if (= (vla-get-mspace (CSP)) :vlax-true) "model" "paper")
    )
    )
    )
    )

    (defun LOADYES ()
    (CURRENTSPACE)
    (initget "Yes No")
    (setq ly (getkword (strcat "\n \""rn"\" is not attached. Would you like
    to attach it? <Yes/No> ")))
    )


    ;;Error trap

    (defun trap1 (errmsg)
    (command "undo" "b")
    (setq *error* temperr)
    (prompt "\nResetting System Variables ")
    (princ)
    )


    ;;;The individual xref's


    (defun TOPO ()
    (setq layold (getvar "clayer")) ;;save current layer
    (command "ucs" "w") ;;set UCS to world
    (if
    (not
    (tblsearch "layer" "xref")) ;;search for correct layer to attach the
    xref on
    (command "-layer" "n" "Xref" "c" "7" "Xref" "s" "Xref" "") ;;create and
    set current if needed
    (command "-layer" "s" "Xref" "") ;;otherwise set it current
    )
    (command "-xref" "overlay" "PATH AND FILE NAME GO HERE" "0,0" "1" "1" "0")
    ;;bring the xref in
    (command "ucs" "p") ;;reset the UCS
    (setvar "clayer" layold) ;;reset layer
    (princ)
    )


    ;;;The commands


    (defun C:RTOPO (/ temperr *error* rn ry ly layold)
    (setq temperr *error*)
    (setq *error* trap1)
    (command "undo" "m")
    (setq rn "XREF NAME GOES HERE") ;;Reference Name - used in LOADYES if
    xref isn't part of the drawing
    (setq ry ;;Reference Yes - is the xref already part of the drawing?
    (if
    (not
    (tblsearch "block" "XREF NAME GOES HERE") ;;search for the xref by
    name
    )
    "No" "Yes" ;;No if it isn't, Yes if it is
    )
    )
    (if
    (= ry "Yes") ;;if it is...
    (command "-xref" "r" "XREF NAME GOES HERE") ;;reload it
    (LOADYES) ;;run this if it isn't
    )
    (if ;;but...
    (and
    (= ry "No") ;;if it isn't...
    (= ly "Yes") ;;and it should be...
    (= cspace "model") ;;and you are in model space...
    )
    (TOPO) ;;bring it in
    )
    (if ;;otherwise...
    (and
    (= ly "Yes") ;;if it isn't and should be...
    (= CSPACE "paper") ;;but you are also in paper space...
    )
    (alert "Currently in Paper Space. Tile to Model Space and re-run the
    routine.") ;;tell user and end routine
    )
    (setq *error* temperr)
    (princ)
    )
     
    ffejgreb, Apr 14, 2004
    #2
  3. Caddog

    OLD-CADaver Guest

    some of them have been unloaded for a reason? <<

    hmmm... If they have been updated, how would the routine know you want them to remain unloaded?
     
    OLD-CADaver, Apr 14, 2004
    #3
  4. Caddog

    Caddog Guest

    Great question. The routine would have to look at the status of the xref.
    If the xref is "unloaded" then ignore it. If the xref is loaded then
    proceed.....

    I think??????
    them to remain unloaded?
     
    Caddog, Apr 14, 2004
    #4
  5. A simple method is:

    (defun C:XREFRELOAD ()
    (command "_.-xref" "r" "*")
    )

    (defun C:XREFUNLOAD ()
    (command "_.-xref" "u" "*")
    )

    But there can be problems. Most of the time this works well.
     
    Bruce Sheldon, Apr 15, 2004
    #5
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.