.NET WblockCloneObjects in BricsCAD V15 to V18 (dynamic blocks)
Hello,
This 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;
}
}
Thanks you in advance.