Author Topic: Inserting Blocks within other drawings  (Read 1252 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Inserting Blocks within other drawings
« on: March 17, 2015, 09:49:01 AM »
I am trying to figure out by using a script setup (command line); If I have a drawing that has several blocks in it, I want to write a script that can find that drawing and look for the name of the requested block and insert it into the current drawing. I know you can do it thru the tool palette but again, (automating it, is what I am hoping for).
thanks for all your help!
Civil3D 2020

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Inserting Blocks within other drawings
« Reply #1 on: March 17, 2015, 09:49:55 AM »
design center is your friend <CTRL+2>
Be your Best


Michael Farrell
http://primeservicesglobal.com/

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Inserting Blocks within other drawings
« Reply #2 on: March 17, 2015, 10:04:15 AM »
I know that the design center is the way to go; but can I access that command from a command line?
Civil3D 2020

ChrisCarlson

  • Guest
Re: Inserting Blocks within other drawings
« Reply #3 on: March 17, 2015, 10:12:22 AM »
You can do it through the insert dialog IF the directory where the block is stored is in your support path. Also going this route each block needs it's own .dwg file.

You could use this routine to extract each block to it's own file.

Based off Ron's routine

Code - Auto/Visual Lisp: [Select]
  1. ;;source http://www.theswamp.org/index.php?topic=47103.0
  2. (defun c:exportblocks (/ blk blks x dir)
  3.     (progn (setvar 'filedia 0)
  4.            (setq dir (strcat (getvar 'dwgprefix) "_ExportedBlocks\\"))
  5.            (vl-mkdir dir)
  6.            (vlax-for blk blks
  7.              (if (and (not (wcmatch (setq x (vla-get-name blk)) "*|*,*`**"))
  8.                       (= (vla-get-isxref blk) :vlax-false)
  9.                  )
  10.                  (progn
  11.                  (annotativeblock x)
  12.                (command "._-wblock" (strcat dir x) x)
  13.                    )
  14.              )
  15.            )
  16.            (setvar 'filedia 1)
  17.     )
  18.   )
  19.   (princ)
  20. )
  21.  
  22. (defun annotativeblock ( blk )
  23.     (and (setq blk (tblobjname "block" blk))
  24.         (progn
  25.             (regapp "AcadAnnotative")
  26.             (entmod
  27.                 (append (entget (cdr (assoc 330 (entget blk))))
  28.                    '(
  29.                         (   -3
  30.                             (   "AcadAnnotative"
  31.                                 (1000 . "AnnotativeData")
  32.                                 (1002 . "{")
  33.                                 (1070 . 0)
  34.                                 (1070 . 0)
  35.                                 (1002 . "}")
  36.                             )
  37.                         )
  38.                     )
  39.                 )
  40.             )
  41.         )
  42.     )
  43. )
  44.  

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Inserting Blocks within other drawings
« Reply #4 on: March 17, 2015, 12:06:58 PM »
Civil3D 2020