Xref Xopen & Reload

Discussion in 'AutoCAD' started by spencer1971, Nov 4, 2004.

  1. spencer1971

    spencer1971 Guest

    I am tyring to develope a lisp routine trhat acts as xopen but automatically loads the last xref editing is finished.

    I have cropped the following routines from various posts on this forum and have now got two buttons.

    Button 1 acts as xopen but retains filename et.

    (defun C:x-o (/ )
    (vl-load-com)
    (setq ENAM (car (entsel "\nSelect block to open: "))
    ELST (entget ENAM)
    EOBJ (vlax-ename->vla-object ENAM)
    )
    (if (vl-catch-all-error-p
    (vl-catch-all-apply 'vla-get-path (list EOBJ))
    )
    (if (not (setq BLKNAME (findfile (strcat (cdr (assoc 2 ELST)) ".dwg"))))
    (setq BLKNAME (wblk ENAM))
    )
    (setq BLKNAME (vla-get-path EOBJ))
    )
    (PRINC BLKNAME)
    (getstring "\nPress Enter to continue: ")
    (command "vbastmt"
    (strcat "AcadApplication.Documents.Open \"" BLKNAME "\"")
    )
    (princ)
    )

    Button 2 will allow for a fast auto reload by picking the last edited xref.

    (defun c:x-l ()
    (setq cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq temp (entsel "\nXref to Reload: "))
    (setq ent (car temp))
    (setq dat (entget ent))
    (setq xrr (cdr (assoc 2 dat)))
    (command "xref" "reload" xrr)
    (PRINC "\nXref Reloaded") (PRINC)
    )

    What i am trying to do is set button 2 to reload the xref picked from button 1 thus saving a second pick when drawing is reentered,
    I have tried but I am not getting to the bottom of it,

    Any suggestions would be greatly appriciated.

    Spencer
     
    spencer1971, Nov 4, 2004
    #1
  2. spencer1971

    T.Willey Guest

    One way to do it, is see if the variable from you code to open an xref drawings is not nil, then if it's a name just reload that name, if not then have it select one. IMO, you should make most if not all of your variables local, just leave one that is global (the xref name) and give it a very unique name.

    Tim
     
    T.Willey, Nov 4, 2004
    #2
  3. spencer1971

    spencer1971 Guest

    Andy thanks for your reply,

    I tried that but had a problem with the filename.

    The variable BLKNAME ends up as a full path "c:\drawings\jobname\ground" etc but this is no use when re-loading xref.
    The reference name is the name without the path (or could be somethin different if renamed manually in the xred dll box.)

    Thats what im trying to retrieve.

    Spencer
     
    spencer1971, Nov 4, 2004
    #3
  4. spencer1971

    spencer1971 Guest

    Sorry Tim, I was typing an e-mail to someone called Andy,,

    It is getting late..
     
    spencer1971, Nov 4, 2004
    #4
  5. spencer1971

    Jeff Mishler Guest

    Spencer,
    Since you are already using ActiveX properties & methods, why not use the
    ReLoad method on the Xref Vla-object?

    (vla-reload EOBJ)
     
    Jeff Mishler, Nov 4, 2004
    #5
  6. spencer1971

    spencer1971 Guest

    Jeff,

    I am only using ActiveX because I cut it from a post on this forum, Im ok at Lsp but Ive never really done any other programming,
    I'll take this as a chance to learn and look into (vla-reload EOBJ) as suggested,

    Thanks for the advice

    Spence
     
    spencer1971, Nov 4, 2004
    #6
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.