Author Topic: XREF multiple files at one time  (Read 4601 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
XREF multiple files at one time
« on: January 18, 2005, 11:52:51 AM »
Before I burn a lot of time, does anyone (Yo, CAB?) have a lisp routine or something that will XREF overlay a bunch of files at once?

whdjr

  • Guest
XREF multiple files at one time
« Reply #1 on: January 18, 2005, 12:27:42 PM »
Code: [Select]
;;;Created by Will DeLoach
;;;
;;;Description:
;;;Does a multiple attach of selected dwg's.
;;;
;;;Usage:
;;;From the dialog box select a dwg and then click on open.    
;;;Keep doing this procedure until you have selected all the  
;;;files you want to attach, then click cancel to continue with
;;;the attaching of the xref's.
;;;The routine can be modified for insertion point, scale, and
;;;rotation respectively by changing the 3 pause commands.
;;;
;;;
(defun c:mxattach (/ file files)
  (setq file "")
  (while (setq file (getfiled "Select a file to xref" file "dwg" 128))
    (setq files (cons file files))
  )
  (foreach f (reverse files)
    (vl-bb-set 'name (vl-filename-base f))
    (if (vl-cmdf "-xref" "attach" (vl-bb-ref 'name))
      (command pause pause pause)
    )
  )
  (princ)
)


This is one I wrote, but it requires alot of user input and it doesn't currently attach overlay. You can change it however you need to or just holler and I will.

HTH,

AfricaAD

  • Guest
XREF multiple files at one time
« Reply #2 on: January 18, 2005, 01:39:53 PM »
Do a google search for Xtools.

CADaver

  • Guest
XREF multiple files at one time
« Reply #3 on: January 18, 2005, 02:27:30 PM »
Quote from: AfricaAD
Do a google search for Xtools.
I did, now what??

whdjr

  • Guest
XREF multiple files at one time
« Reply #4 on: January 18, 2005, 02:40:36 PM »
How are you planning on implementing this?
Are each of your xrefs the same scale or location?
Do you want to select all the files in a folder?

I can make any or all of these options as well as changing from "attach" to "overlay".
Just say the word and give directions.

ronjonp

  • Needs a day job
  • Posts: 7526
XREF multiple files at one time
« Reply #5 on: January 18, 2005, 02:56:46 PM »
Will,

I modified your code so you could attach files ouside the root dir as well.

Code: [Select]
(defun c:mx (/ file files)
  (setq file "")
  (while (setq file (getfiled "Select a file to xref" file "dwg" 128))
    (setq files (cons file files))
  )
  (foreach f (reverse files)
    (vl-bb-set 'name (strcat (vl-filename-directory f) "\\" (vl-filename-base f)))
    (if (vl-cmdf "-xref" "attach" (vl-bb-ref 'name))
      (command pause pause pause)
    )
  )
  (princ)
)


Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC


CADaver

  • Guest
XREF multiple files at one time
« Reply #7 on: January 18, 2005, 03:29:47 PM »
Thanks AfricaAD, I'll look into it.

Will, I did something similar to what Ron did, but added the insertion point at 0,0,0 and the scales are 1 with a 0 rotation:
Code: [Select]

(defun c:mx (/ file files)
  (setq file "")
  (while (setq file (getfiled "Select a file to xref" file "dwg" 128))
    (setq files (cons file files))
  )
  (foreach f (reverse files)
    (vl-bb-set 'name (strcat (vl-filename-directory f) "\\" (vl-filename-base f)))
    (if (vl-cmdf "-xref" "overlay" (vl-bb-ref 'name))
      (command "*0,0,0" "1" "1" "0")
    )
  )
  (princ)
)


This works pretty well, thanks, I was just hoping to select a range of files with a shift or ctrl, but this works just fine for now.

whdjr

  • Guest
XREF multiple files at one time
« Reply #8 on: January 18, 2005, 03:49:47 PM »
Quote from: CADaver
I was just hoping to select a range of files with a shift or
ctrl

Unfortunately that is a downside to lisp.  I have been bummed out on this for a while now.

I also have a tool that will search a folder and/or all sub-folders for a string in a filename.  It uses wcmatch selection with wildcards and all.  I will post it if you would like to use it.  It does however require that "acetutil" be loaded from the expresstools..

ELOQUINTET

  • Guest
XREF multiple files at one time
« Reply #9 on: January 18, 2005, 03:59:34 PM »
there might be something that might do what you want in the latest installment from cadalyst but i didn't try it might wanna check it out

ELOQUINTET

  • Guest
XREF multiple files at one time
« Reply #10 on: January 18, 2005, 04:01:10 PM »
here try this like i say haven't tried it meself

Code: [Select]
;;;CADALYST 01/05 Tip2009:  mxrefi.lsp       Multiple Xref       (c) 2005 Leonid Nemirovsky

;;=============================================================
;; BTN by Leonid Nemirovsky                       2004
;;=============================================================
(defun c:mxrefi (/ dir pt typ scl ang file lista)
(setq dir (getstring T "X-Ref's Location<Current Folder>: "))
(setq pt (getpoint "\nSelect or Type Insertion Point<0,0>: "))
(if (= pt nil)(setq pt "0,0"))
(initget 1 "Overlay Attach")
(setq typ (getkword "Overlay or Attach <O or A>: "))
(setq scl (getreal "\nScale <1>: "))
(if (= scl nil)(setq scl 1))
(setq ang (getreal "\nRotation Angle<0>: "))
(if (= ang nil)(setq ang 0))
(setq file (getfiled "X-Ref's to attach" dir "dwg" 0))
(command"xref" typ file pt scl scl ang)
(setq lista (list file))
(while
  (setq file (getfiled "X-Ref's to attach" dir "dwg" 0))
  (setq lista (append (list  file) lista))
(command"xref" typ file pt scl scl ang)
)
(princ)

CADaver

  • Guest
XREF multiple files at one time
« Reply #11 on: January 18, 2005, 06:29:03 PM »
I found that one in Cadalyst during lunch, but it's not nearly as good as the one Will posted here already.

The one from XTOOLS, posted by AfricaAD, does exactly what I want, but it has some overhead I need to trim away.

Thanks folks, I appreciate the help.

AfricaAD

  • Guest
XREF multiple files at one time
« Reply #12 on: January 19, 2005, 12:11:34 PM »
I actually used it for the xref text file export. Since it included everything else, I kept it & use it religiously.

I modified mine a little. I would like to however allow multiple selection in CAD not in the dialogue. Just remember, it requires doslib & it comes with doslib2k. Also, there is 1 command that doesn't work (XM) which requires an outside app.

CADaver

  • Guest
XREF multiple files at one time
« Reply #13 on: January 19, 2005, 12:38:06 PM »
Quote from: AfricaAD
Just remember, it requires doslib & it comes with doslib2k.
That's my only problem with the routine, I've been stung in the past by relying on software that becomes unsupported later.


Quote from: AfricaAD
Also, there is 1 command that doesn't work (XM) which requires an outside app.
I noticed that too, I wonder what's up with that.

AfricaAD

  • Guest
XREF multiple files at one time
« Reply #14 on: January 19, 2005, 12:43:07 PM »
From what I noticed, I think doslib is only required for the xref name export to text file & to xref files from a text file (which is a pretty good function).