TheSwamp

CAD Forums => CAD General => Topic started by: M-dub on June 25, 2008, 02:55:45 PM

Title: Quickest Way To Insert Dozens of Blocks
Post by: M-dub on June 25, 2008, 02:55:45 PM
What is the quickest way to insert a whole bunch of blocks into one drawing relatively evenly spaced?  They are all in the same directory.  I was just trying to avoid having to insert each one individually.
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: T.Willey on June 25, 2008, 03:17:14 PM
Lisp of Script I would guess.  Lisp would be My first choice.
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: M-dub on June 25, 2008, 03:21:39 PM
I'm half done.  It's not as easy (straight forward) as I first thought, anyway.

Thanks though.  :)
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: deegeecees on June 25, 2008, 03:27:13 PM
Pseudo code:

Get names of all blocks plus limits
Get max limits of largest block
Set ins point at 0,0
Increment to the right using units of largest block + a couple units
Insert first block in list
Repeat for a number of times, then increment up/dn using units of largest block + a couple units, etc...
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: ronjonp on June 25, 2008, 03:38:13 PM
Here's my stab at it:

Code: [Select]
(defun c:insertblks (/ d doc lst pt pt1 dir)
  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if
    (and (setq
   dir (vl-filename-directory
(getfiled "Select a DWG" (getvar 'dwgprefix) "dwg" 8)
       )
)
(setq lst (vl-directory-files dir "*.dwg"))
(setq pt1 (getpoint "\nSelect point for first block: "))
(setq d
(distance (getpoint pt1 "\nSelect distance to space blocks: ")
  pt1
)
)
    )
     (foreach b lst
       (vla-insertblock
(if (= (getvar 'cvport) 1)
   (vla-get-paperspace doc)
   (vla-get-modelspace doc)
)
(vlax-3d-point (setq pt1 (polar pt1 0.0 d)))
(strcat dir "\\" b)
1
1
1
0.0
       )
     )
  )
  (princ)
)
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: M-dub on June 25, 2008, 03:50:12 PM
Cool, Ron.  That did it  :)

Thanks!
Title: Re: Quickest Way To Insert Dozens of Blocks
Post by: ronjonp on June 25, 2008, 04:02:32 PM
You're welcome :)