Jump to content

Inserting Blocks from another DWG into the current drawing


nicolas

Recommended Posts

Hi,

 

I know this is a common topic and I have found number of them on the net but I am still looking forward to a clear-cut lisp procedure to inserting a block from another drawing into the current drawing.

 

Having the source file containing multiple blocks in the search paths has not helped. It seemed there must be a solution as this is an established practice in use in DC and Palette.

 

The reason for the lisp instead of DC/Palette is that I can automatically insert 4 blocks at specified coordinates and this will greatly accelerate my work.

 

Regards,

 

Nicolas

Link to comment
Share on other sites

All four (separate) blocks are contained in one drawing not multiple drawings right?

 

And you know the name of each block. Will the blocks you have to insert change from drawing to drawing?

 

And you know the specific coordinates beforehand that the blocks will be inserted at? Will these coordinates change from drawing to drawing?

 

Will the scale of the blocks be the same or different? Will this change from drawing to drawing?

 

One must account for all the variables.

Link to comment
Share on other sites

try this code to insert the needed drawing and it would be erased after that to have all its blocks into the current open drawing .

 

(defun c:Test (/ filename) (vl-load-com)
;;; Tharwat 22. Feb. 2012 ;;;
 (setq filename [color=blue][b]"C:\\Users\\Drawing1.dwg"[/b][/color])  ;; <<<-- put your complete drawing file name with its directory
 (vl-cmdf "_.-insert" filename '(0. 0. 0.) "" "" "")
 (vl-cmdf "_.erase" (entlast) "")
 (if (tblsearch "BLOCK"
                (setq filename (vl-filename-base filename))
     )
   (vl-cmdf "_.-purge" "Blocks" filename "_N")
 )
 (princ)
)

Link to comment
Share on other sites

Remark,

 

Thanks. The block library contains hundreds of blocks. The lisp program will insert four of them in model space in numerous drawings (I know the names, the destination coordinates, scale 1 in x and y directions, rotation = 0, as is) and 2 additional ones in paper space at specific coordinates but exploded state (because they contain a view port).

 

Tharwat, thanks for the code but I need but some of the blocks and not all the blocks/or a drawing in another drawing. The filename variable contain the path and filename but what about the specific blocks and how to insert them at specific locations??? in model/paper space with scale 1 and the one in paper space in exploded state.

 

Thanks in advanced,

 

Regards,

 

Nicolas.

Link to comment
Share on other sites

After inserting the drawing , its blocks would be all available in hand , so with a few lines of codes you could insert the needed blocks to the destination that you want .

 

e.g in use of entmakex function to insert any block that existed in current drawing .

 

(entmakex (list (cons 0 "INSERT")
               (cons 2 BlockNme) ; Block Name
               (cons 10 pt) ; Insertion Point
               '(41 . 1.0)
               '(42 . 1.0)
               '(43 . 1.0)
         )
)

Link to comment
Share on other sites

  • 10 years later...
On 2/22/2012 at 12:23 PM, Lee Mac said:

Hi Lee im working on your copyblockfromdrawing lisp, however, I need a modification if possible. I am trying to add a block from another drawing everytime a macro button is clicked. The current code you have made only allows for distinct blocks to be added. I am basically setting up a macro button accessible from the autocad toolbar that allows users to add symbols to a drawing, as many times as they wish.

Link to comment
Share on other sites

20 hours ago, Flacon said:

Hi Lee im working on your copyblockfromdrawing lisp, however, I need a modification if possible. I am trying to add a block from another drawing everytime a macro button is clicked. The current code you have made only allows for distinct blocks to be added. I am basically setting up a macro button accessible from the autocad toolbar that allows users to add symbols to a drawing, as many times as they wish.

As someone who uses Lee Mac's StealV1-8.lsp in many macros you should start the macro with a call to steal the block to make sure it's in the drawing then use -insert followed by block name letting the user pick location and scale afterwards.

 

You could also use the -INSERTCONTENT command in a macro to directly insert a block from another drawing.

Edited by tombu
Added link for -INSERTCONTENT
Link to comment
Share on other sites

On 10/31/2022 at 3:33 PM, Flacon said:

Hi Lee im working on your copyblockfromdrawing lisp, however, I need a modification if possible. I am trying to add a block from another drawing everytime a macro button is clicked. The current code you have made only allows for distinct blocks to be added. I am basically setting up a macro button accessible from the autocad toolbar that allows users to add symbols to a drawing, as many times as they wish.

 

Have you considered simply using Tool Palettes?

  • Like 1
Link to comment
Share on other sites

If your copying this block often why not wblock it out and save in a support path can then insert when ever required. Like Lee Tool palettes or for me a custom menu with blocks displayed.

  • Like 1
Link to comment
Share on other sites

I have an MUTCD.dwg that has about 100 standard MUTCD street signs as blocks.

This macro 

^C^C^P(command "adcnavigate" "G:/ENGDESGN/BeaufordT/Blocks/MUTCD.dwg") 

or

^C^Cadcnavigate G:/ENGDESGN/BeaufordT/Blocks/MUTCD.dwg;

open the MUTCD.dwg in Design Center so I can view clear images (I didn't have to create) of all the signs with their names in an alphabetized list of the block names.

Makes inserting or updating those blocks easy in case you wanted another option!

Link to comment
Share on other sites

Tombu you would like this, 100's of signs at your fingertips and its a TTF. So can use in say Word and Excel also. Now the bad news I can not find the company that made them "AUS Fonts" if you find them let me know.

 

image.thumb.png.4d90b02e138fc51794c113a195acdb11.png

image.png.3b284bbfffbd5cda8f30937829aa4219.png

 

 

 

 

  • Like 1
Link to comment
Share on other sites

5 hours ago, BIGAL said:

Tombu you would like this, 100's of signs at your fingertips and its a TTF. So can use in say Word and Excel also. Now the bad news I can not find the company that made them "AUS Fonts" if you find them let me know.

I've attached the sign block drawing I use from Florida Dept. of Transportation. I'd like to see the one you have to see if I'm missing any. I might be able to find those fonts. If you have an image displaying text in an unknown font paste it into https://www.fontsquirrel.com/matcherator?token=ohd8q2l7ylb75dti to identify it.

164223165_mutcd-StandardFonts.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...