Hi again,
After taking another look at the ObjectARX docs, I saw I could resolve this using Database.Insert()
Doing this, I am able to insert in my documents all the objects contained in my external docs as block definitions (BlockTableRecord elements).
Anyway, I am still having problems. I am using this piece of code to create the new BlockTableRecord's:
///////////////////////////////////////////////////////////////////////////////////////////////////////////
Dim bt As BlockTable = Nothing
Dim blkOid As ObjectId = Nothing
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
blkOid = bt.Item(blockName)
Catch ex As Exception
Dim etiqDefDoc As Document = Application.DocumentManager.Open(defFilePath, True)
Dim etiqDefDB As Database = etiqDefDoc.Database
blkOid = db.Insert(blockName, etiqDefDB, True)
etiqDefDoc.CloseAndDiscard()
trans.Commit()
Finally
trans.Dispose()
End Try
///////////////////////////////////////////////////////////////////////////////////////////////////////////
But sometimes I am getting an [eNoDocument] error. I tried to use Database.ReadDwgFile() instead of calling DocumentManager.Open(), but I got an AccessViolationException error ("Attempted to read or write protected memory"). I saw some posts at the forum reflecting the same problem, but I still don't have an answer.
I also have been checking the value of DocumentManager.IsApplicationContex, but it is [False] before and after the error happens.
Any kind of help would be appreciated
Thanks in advance