Author Topic: Batch insert reference(Xref)  (Read 4390 times)

0 Members and 1 Guest are viewing this topic.

andy_lee

  • Newt
  • Posts: 147
Batch insert reference(Xref)
« on: July 21, 2014, 06:52:58 AM »
Hi ,friends
Select a folder and insert all DWG file to drawing from the folder.
 I think need a Dcl file to enter the Rows and columns, Line spacing and the column spacing.

Thans for help!
andy.
Best regards.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Batch insert reference(Xref)
« Reply #1 on: July 21, 2014, 08:14:05 AM »
If I recall, you can select multiple DWGs when using the XREF command.  No need for a custom app.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Batch insert reference(Xref)
« Reply #2 on: July 21, 2014, 08:41:38 AM »
xref or insert?  OpenDCL provides a grid control that can assist in placing the referenced drawings

jb
James Buzbee
Windows 8

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #3 on: July 21, 2014, 11:53:17 PM »
Re:M@yhem
xref command can't select multiple DWGs.

andy.
Best regards.

kruuger

  • Swamp Rat
  • Posts: 635
Re: Batch insert reference(Xref)
« Reply #4 on: July 22, 2014, 03:14:27 AM »
Re:M@yhem
xref command can't select multiple DWGs.
yes we can.
k.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Batch insert reference(Xref)
« Reply #5 on: July 22, 2014, 05:19:04 PM »

I honestly can't remember where I got this but it works for me...

Code: [Select]
(defun c:BatchXref ()
(setvar "tilemode" 1)
(princ "\n\nPick any drawing in the set.")
(setq pickfile (getfiled "Pick any drawing in the set" "g:/" "dwg" 2)) ;;; type in your preferred path...
;
;extract just the path
(setq filelen (strlen pickfile))
(setq letter "")
(while (/= letter "\\")
  (setq letter (substr pickfile filelen 1))
  (setq filelen (- filelen 1))
)
(setq filelen (+ filelen 1))
(setq path (substr pickfile 1 filelen))
;
;list all floor plan drawings in that directory
(vl-load-com)
(setq filelist (vl-directory-files path "Arch*.dwg" 1)) ;;; type in the naming of your files etc...
;
;xref all floor plans into current drawing
(setq counter 0)
(setvar "filedia" 0)
(repeat (length filelist)
  (setq currentfile (strcat path (nth counter filelist)))
  (command "-xref" "a" currentfile "0,0,0" "1" "" "0")
  (setq counter (+ counter 1))
)
(setvar "filedia" 1)
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #6 on: July 23, 2014, 03:54:39 AM »

I honestly can't remember where I got this but it works for me...

Code: [Select]
(defun c:BatchXref ()
(setvar "tilemode" 1)
(princ "\n\nPick any drawing in the set.")
(setq pickfile (getfiled "Pick any drawing in the set" "g:/" "dwg" 2)) ;;; type in your preferred path...
;
;extract just the path
(setq filelen (strlen pickfile))
(setq letter "")
(while (/= letter "\\")
  (setq letter (substr pickfile filelen 1))
  (setq filelen (- filelen 1))
)
(setq filelen (+ filelen 1))
(setq path (substr pickfile 1 filelen))
;
;list all floor plan drawings in that directory
(vl-load-com)
(setq filelist (vl-directory-files path "Arch*.dwg" 1)) ;;; type in the naming of your files etc...
;
;xref all floor plans into current drawing
(setq counter 0)
(setvar "filedia" 0)
(repeat (length filelist)
  (setq currentfile (strcat path (nth counter filelist)))
  (command "-xref" "a" currentfile "0,0,0" "1" "" "0")
  (setq counter (+ counter 1))
)
(setvar "filedia" 1)
)

Thank you ,V-Man , I test it ,Nothing is inserted.
andy.
Best regards.

kruuger

  • Swamp Rat
  • Posts: 635
Re: Batch insert reference(Xref)
« Reply #7 on: July 23, 2014, 05:08:30 AM »
ah just remembered that i wrote this:
http://forum.cad.pl/lisp-wczytanie-ciag-dalszy-t75832.html
http://forum.cad.pl/download/file.php?id=751&mode=view
few years ago when i have more time to play with lisp :)
k.

hanhphuc

  • Newt
  • Posts: 64
Re: Batch insert reference(Xref)
« Reply #8 on: July 23, 2014, 05:12:54 AM »
Thank you ,V-Man , I test it ,Nothing is inserted.
Be careful: variables not localized yet :)

hi emk2012, Try to replace, this line
Code: [Select]
(setq filelist (vl-directory-files path "Arch*.dwg" 1)) ;;; type in the naming of your files etc...
to this..
Code: [Select]
(setq filelist (vl-directory-files path "*.dwg"))
warning: This will insert all drawings in that specific directory!
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #9 on: July 23, 2014, 08:04:19 AM »
ah just remembered that i wrote this:
http://forum.cad.pl/lisp-wczytanie-ciag-dalszy-t75832.html
http://forum.cad.pl/download/file.php?id=751&mode=view
few years ago when i have more time to play with lisp :)
k.

kruuger, Nice! great routine.
About different drawing of the frame. This may be a little bit better.


andy.
Best regards.

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #10 on: July 23, 2014, 08:07:35 AM »
Thank you ,V-Man , I test it ,Nothing is inserted.
Be careful: variables not localized yet :)

hi emk2012, Try to replace, this line
Code: [Select]
(setq filelist (vl-directory-files path "Arch*.dwg" 1)) ;;; type in the naming of your files etc...
to this..
Code: [Select]
(setq filelist (vl-directory-files path "*.dwg"))
warning: This will insert all drawings in that specific directory!

hanhphuc, Thank you for the modified. Now ,It's Ok!
andy.
Best regards.

kruuger

  • Swamp Rat
  • Posts: 635
Re: Batch insert reference(Xref)
« Reply #11 on: July 23, 2014, 08:35:59 AM »
ah just remembered that i wrote this:
http://forum.cad.pl/lisp-wczytanie-ciag-dalszy-t75832.html
http://forum.cad.pl/download/file.php?id=751&mode=view
few years ago when i have more time to play with lisp :)
k.

kruuger, Nice! great routine.
About different drawing of the frame. This may be a little bit better.


yes. there was idea to make an addition option to generate bounding box of xref and make constant dist between them but because of time...never happens :(
k.

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #12 on: July 23, 2014, 10:10:02 AM »
ah just remembered that i wrote this:
http://forum.cad.pl/lisp-wczytanie-ciag-dalszy-t75832.html
http://forum.cad.pl/download/file.php?id=751&mode=view
few years ago when i have more time to play with lisp :)
k.

kruuger, Nice! great routine.
About different drawing of the frame. This may be a little bit better.


yes. there was idea to make an addition option to generate bounding box of xref and make constant dist between them but because of time...never happens :(
k.

I can understand you, Thanks.
andy.
Best regards.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Batch insert reference(Xref)
« Reply #13 on: July 23, 2014, 10:11:47 AM »
Re:M@yhem
xref command can't select multiple DWGs.
It has been able to do so for a few years now.  What version are you using??
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

andy_lee

  • Newt
  • Posts: 147
Re: Batch insert reference(Xref)
« Reply #14 on: July 23, 2014, 10:15:50 AM »
Re:M@yhem
xref command can't select multiple DWGs.
It has been able to do so for a few years now.  What version are you using??

ACad 2010
andy.
Best regards.