Hi,
Bellow is typical part of code to import block from other DWG.
It is working perfect also with dynamic blocks using BricsCAD V13, V14 and AutoCAD.
I was very surprised that it doesn't work with BricsCAD V15 to V18.
What is the reason? How to solve it?
ObjectId ImportBlock(Database targetDb, string sourceFileName, string blockName)
{
using (var sourceDb = new Database(false, true))
{
sourceDb.ReadDwgFile(sourceFileName, FileOpenMode.OpenForReadAndAllShare, false, null);
var id = ObjectId.Null;
using (var tr = sourceDb.TransactionManager.StartTransaction())
{
var bt = (BlockTable)tr.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
if (!bt.Has(blockName))
return ObjectId.Null;
id = bt[blockName];
tr.Commit();
}
var ids = new ObjectIdCollection();
ids.Add(id);
var mapping = new IdMapping();
sourceDb.WblockCloneObjects(ids, targetDb.BlockTableId, mapping, DuplicateRecordCloning.Replace, false);
return mapping[id].Value;
}
}
The same situation is when I tried following code:
http://through-the-interface.typepad.com/through_the_interface/2006/08/import_blocks_f.htmlIn attachment you can find sample source DWG with dynamic block.
Thanks you in advance.