Lisp to insert Xrefs from different folders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've been working on a lisp to help us set up new drawings. It works in the way that as a company we use the same DWG names for all of the same xrefs even between different projects. i.e. 2D First Floor General Arrangement = 2D-XA-01.dwg / 2D Second Floor RCP = 2D-XA-02-RCP.dwg etc etc
See my attempt below which may make things a little clearer:
(defun c:01ABC ( / ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-01.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-01-RCP.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-01-FURNITURE.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\3D XREFS\\3D-XA-01.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XS-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\3D XREFS\\3D-XS-02.dwg" "0,0,0" "" "" "") (princ) (command "zoom" "e") (princ)) (defun c:01XYZ ( / ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-01.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-01-RCP.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-01-FURNITURE.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\3D XREFS\\3D-XA-01.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XS-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\3D XREFS\\3D-XS-02.dwg" "0,0,0" "" "" "") (princ) (command "zoom" "e") (princ)) (defun c:02ABC ( / ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-02-RCP.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XA-02-FURNITURE.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\3D XREFS\\3D-XA-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\2D XREFS\\2D-XS-03.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0341 - ABC\\123\\XREF\\3D XREFS\\3D-XS-03.dwg" "0,0,0" "" "" "") (princ) (command "zoom" "e") (princ)) (defun c:02XYZ ( / ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-02-RCP.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XA-02-FURNITURE.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\3D XREFS\\3D-XA-02.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\2D XREFS\\2D-XS-03.dwg" "0,0,0" "" "" "") (princ) (command "_-xref" "overlay" "C:\\Users\\home\\Desktop\\LISP TEST\\0342 - XYZ\\123\\XREF\\3D XREFS\\3D-XS-03.dwg" "0,0,0" "" "" "") (princ) (command "zoom" "e") (princ))
I understand i'm far from spectacular at writing these but at the moment it works great. For example, if i want to insert level 2 XREFS for project XYZ i simply type 02XYZ
The project numbers i.e. 0341/0342 is always changing as new jobs come in and their ABC/XYZ values change also so my lisp would require me to adapt/update it every time a new project is started.
My question is whether there is a way to load the XREFS from the folder after selecting what project i want or having some sort of wild card so when prompted for the job number it will automatically read for folders containing that job number and follow the path through there and load xrefs from
\\123\\XREF\\3D XREFS\\etc.dwg
onwards
I understand this probably isn't a 5 minute piece of assistance and your help is greatly appreciated.
Thank you in advance for any help
Sam