Custom XREF's Manager

Discussion in 'AutoCAD' started by Alan Henderson @ A'cad Solutions, Jan 11, 2005.

  1. Here is a program I use to xref drawings from the AutoCAD Startin: folder

    Save following section as a LISP file -
    ;XR = set layer to 0 and start NEW xref command
    (defun C:XR ()
    (command "_LAYER" "T" "0" "S" "0" "")
    ;--get data and check------------
    (defun xr_close_ok ()
    (setq XREF (get_tile "XREF"))
    (setq XR_VALUES_OK T)
    (done_dialog 1)
    )
    ;--cancel input-------------------
    (defun xr_cancel_ok ()
    (done_dialog 0)
    (setq XR_VALUES_OK T)
    )
    ;--get list of all drawings in AutoCAD startin folder
    (setq LIT (vl-directory-files (getvar "DWGPREFIX") "*.dwg"))
    (setq LIT (vl-sort LIT '<))

    ;--start dialog box------------------
    (setq XR_VALUES_OK nil)
    (while (not XR_VALUES_OK)
    (setq DCL_XR_ID (load_dialog "Xref.dcl"))
    (if (not (new_dialog "Xref" DCL_XR_ID))
    (exit)
    (progn
    (start_list "XREF")
    (mapcar 'add_list LIT)
    (end_list)
    (action_tile "accept" "(xr_close_ok)")
    (action_tile "cancel" "(xr_cancel_ok)")
    ;--start dialog box-----------------
    (setq DCL_XR_EXIT (start_dialog))
    )
    )
    ;--Unload DCL from memory----------------
    (unload_dialog DCL_XR_ID)
    )
    ;--Check of OK Exit------------------------
    (if (= DCL_XR_EXIT 1)
    (progn
    ;--get drawing name(s) selected--------
    (setq LIST_TEXT nil)
    (setq KKS 1 KKF 0 KKK 1 KKL (strlen XREF))
    (while (<= KKK KKL)
    (if (= (substr XREF KKK 1) " ")
    (progn
    (setq LIST_TEXT (append LIST_TEXT (list (substr XREF KKS (- KKK
    KKS)))))
    (setq KKS (1+ KKK))
    )
    )
    (setq KKK (1+ KKK))
    )
    (setq LIST_TEXT (append LIST_TEXT (list (substr XREF KKS))))
    (foreach XXX LIST_TEXT
    (setq TXREF (nth (atoi XXX) LIT))
    (if (tblsearch "BLOCK" (substr TXREF 1 (- (strlen TXREF) 4)))
    (princ (strcat "\n" TXREF " is all ready an XREF in drawing."))
    (progn
    (princ (strcat "\nXREF drawing..." TXREF))
    (command "_XREF" "A" TXREF "0,0" "" "" "")
    )
    )
    )
    (princ "\nFinished Xref'ing drawings.")
    (princ)
    )
    (princ "\nXref drawings Cancelled..")
    )
    (setq xr_close_ok nil xr_cancel_ok nil XREF nil LIT nil XR_VALUES_OK nil
    DCL_XR_ID nil)
    (setq DCL_XR_EXIT nil LIST_TEXT nil KKS nil KKF nil KKK nil KKL nil TXREF
    nil)
    (princ)
    )

    Save following as "Xref.dcl" in same folder as previous lisp file
    Xref : dialog {
    label = "Insert Xref";
    : row {
    : column {
    label = "Select Xref Drawing to Insert";
    : text {
    label = "Hold <CTRL> key to select multiple drawings to Xref";
    }
    : list_box {
    key = "XREF";
    multiple_select = true;
    fixed_height = true;
    fixed_width = false;
    width = 50;
    height = 30;
    allow_accept=true;
    }
    }
    }
    ok_cancel;
    }
     
    Alan Henderson @ A'cad Solutions, Jan 11, 2005
    #1
  2. We are working on a project that included more than 50 main dwg. Everything is drawn in 3D. We seperate all those 50 files cause the main model was to big (long to open...) We still have a good year and a half before the end of this project.
    My question is: Any one as created in the past or work on something to insert (XREF) predefine drawing location.
    I'm looking to a dialog box with radio button (at least). You select wich part of the model you want to load. He also look an mark in this dialog box if certain drawing are loaded...

    Any idea???
    thaks, Simon
     
    masterbike360, Jan 12, 2005
    #2
  3. Alan Henderson @ A'cad Solutions

    j buzbee Guest

    As far as the insertion part of your problem: 0,0,0.

    It might seem odd at first, but believe me it makes everyones life easier;
    even if you have objects hundreds of feet away from the origin.

    I do this with large projects at it works flawlessly. If you buy into the
    origin concept then the xref manager will handle your other concerns. If
    not, I'm sure someone will come along to sell you something soon ;-)

    just my 0.02USD

    jb
     
    j buzbee, Jan 12, 2005
    #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.