Help with opening an Xref by picking on it

Discussion in 'AutoCAD' started by David Munoz, Mar 5, 2004.

  1. David Munoz

    David Munoz Guest

    Hello,
    I would like to be able to open xrefs, in the same session of ACAD, by
    selecting it on screen. I can do VERY basic lisp stuff but am not sure how
    to pull path info from an xref once selected.

    I don't want to use the REFEDIT command and would rather have something that
    just opens up a drawing instead.

    Any information would be greatly appreciated.

    Thanks,
    David Munoz
     
    David Munoz, Mar 5, 2004
    #1
  2. David Munoz

    Jeff Mishler Guest

    Here's something to get you started. Just remember, a lisp routine that
    is started in one drawing will not finish until that drawing is made
    active again.

    Good Luck,
    Jeff

    (defun c:xedit (/ bpath ent newdwg ss)
    (vl-load-com)
    (if (> (getvar "SDI") 0);multi-document mode check
    (princ "\nMust be in MDI to use this program, exiting....")
    (progn
    (if (not (setq ss (ssget ":S" '((0 . "INSERT")))));get one entity
    (princ "\nNot a valid selection, exiting...")
    (progn
    (setq ent (vlax-ename->vla-object (ssname ss 0)));set vla-obj
    (if (vlax-property-available-p ent 'path);make sure path is there
    (progn
    (setq bpath (vla-get-path ent));saved path
    (if (findfile bpath);find it
    (progn
    (setq newdwg (vla-open
    (vla-get-documents
    (vlax-get-acad-object))
    bpath));open it
    (vla-activate newdwg);set it current
    )
    )
    )
    )
    )
    )
    )
    )
    (princ)
    )
     
    Jeff Mishler, Mar 5, 2004
    #2
  3. David Munoz

    R.K. McSwain Guest

    Here's a start:
    (cdr (assoc 1 (tblsearch "block" (cdr (assoc 2 (entget (car (entsel))))))))
     
    R.K. McSwain, Mar 5, 2004
    #3
  4. David Munoz

    Rudy Tovar Guest

    Here's one I wrote a few years ago for R14.

    Modify as you wish - contains 'XO' and 'BK' - Xref open and Back to Prev.
    needs a few modification.

    (defun c:xo (/ ent ent-info ent-blok ent-name ent-file file-pre file-dwg
    dwg-pref 1xfile 2xfile)


    (command "qsave")


    (setq ent (entsel))


    (if ent (setq ent-info (entget (car ent))
    ent-blok (cdr (assoc 2 ent-info))
    ent-name (tblsearch "block" ent-blok)
    ent-file (cdr (assoc 1 ent-name))
    file-pre (getvar "xloadpath")
    file-dwg (getvar "dwgname")
    dwg-pref (getvar "dwgprefix")
    )
    )

    (if ent
    (progn
    (setq 1xfile (findfile ent-file))
    (setq 2xfile (findfile (strcat dwg-pref ent-file)))
    )
    )
    (if 1xfile
    (progn
    (setq file (open "c:\backfile.tmp" "w"))
    (write-line (strcat dwg-pref file-dwg) file)
    (close file)
    (command ".open" 1xfile)
    (setq 2xfile nil)
    )
    )

    (if 2xfile
    (progn
    (setq file (open "c:\backfile.tmp" "w"))
    (write-line (strcat dwg-pref file-dwg) file)
    (close file)
    (command ".open" 2xfile)
    )
    )
    (if (and (= 1xfile nil)(= 2xfile nil))(Alert "Entity select is Not an Xref
    File"))
    (princ)
    )


    (defun c:bk (/ file file-name)




    (command "qsave")
    (setq file (open "c:\backfile.tmp" "r"))
    (setq file-name(read-line file))
    (close file)

    (command ".open" file-name)

    (princ)
    )
     
    Rudy Tovar, Mar 5, 2004
    #4
  5. David Munoz

    David Munoz Guest

    WOW, Thanks to all of you who replied. I haven't tried them out yet but it
    looks like I can figure them out and modify them as needed.

    I appreciate the help.

    David Munoz
     
    David Munoz, Mar 5, 2004
    #5
  6. David Munoz

    REZIN8 Guest

    Hi Jeff...
    just went back and looked at this file you wrote some time back.... nice! thanks for the archive. Quick question...

    Is there some way to have the xref reload in the original file after editing and closing out of the xref?

    thanks in advance.
    Lou.
     
    REZIN8, Feb 10, 2005
    #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.