Author Topic: Quickest Way To Insert Dozens of Blocks  (Read 1926 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Quickest Way To Insert Dozens of Blocks
« 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Quickest Way To Insert Dozens of Blocks
« Reply #1 on: June 25, 2008, 03:17:14 PM »
Lisp of Script I would guess.  Lisp would be My first choice.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

M-dub

  • Guest
Re: Quickest Way To Insert Dozens of Blocks
« Reply #2 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.  :)

deegeecees

  • Guest
Re: Quickest Way To Insert Dozens of Blocks
« Reply #3 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...

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Quickest Way To Insert Dozens of Blocks
« Reply #4 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)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

M-dub

  • Guest
Re: Quickest Way To Insert Dozens of Blocks
« Reply #5 on: June 25, 2008, 03:50:12 PM »
Cool, Ron.  That did it  :)

Thanks!

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Quickest Way To Insert Dozens of Blocks
« Reply #6 on: June 25, 2008, 04:02:32 PM »
You're welcome :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC