It's the part of project: I need read some named Blocks from a sample DWG and copy (clone) them (one at a time) to a new drawing.
There are 2 possible way to do it:
1. Database.Insert - it does allow you pass in location point but it takes whole DWG file not blocks inside the whole DWG;
2. Database.WblockCloneObjects - it takes blocks as parameter but it doesn't pass in with location information you want them there
Anyone have similar implementation can share your code/solution with me? Thanks
Hi Luke,
>>1. Database.Insert - it does allow you pass in location point but it takes whole DWG file not blocks inside the whole DWG;
>>This function creates a new block table record in the database executing this function. This new block table record is given the name pointed to by destinationBlockName. Then, each entity in the block table record whose name is sourceBlockName and which resides in the database pointed to by dataBase is copied into the new block table record.
I'd recommend you use Insert for copying blocks from one database to another unless there is a very good reason why its unsuitable.
Once you've instered the BlockTableRecord, you have to add a BlockReference to the drawing to display it. Here's a copy of a DevNote from the ADN website showing how to insert a BTR+BR in the drawing (albeit using a different version of Database.Insert, and omitting code to add AttributeReferences):
How to insert external dwg file as a block in current drawing using VB.NET?
Published date: 2009-06-04
ID: TS87078
Applies to:
AutoCAD® 2010
AutoCAD® 2009
AutoCAD® 2008
AutoCAD® 2007
AutoCAD® 2006
How to insert external dwg file as a block in current drawing using VB.NET?