Hello, I want to load the external references in the drawing, how to implement this program?
I returned to the drawing path and the way I want to load it using the insertion point.
The code error is probably somewhere not understand where.
Please help )
[CommandMethod("TDMSXREF", CommandFlags.Session)]
publicvoid TDMSXREF()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
string path = "0";
string moduleName = "CMD_SYSLIB";
string functionName = "CheckOutSelObj";
TDMSApplication tdmsAppDlg = newTDMSApplication();
//path = tdmsAppDlg.ExecuteScript(moduleName, functionName);
ObjectId xrefObj = db.AttachXref(@"C\MyD.dwg", "test");
BlockReference br = newBlockReference(newPoint3d(0, 0, 0), xrefObj);
BlockTable btTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(btTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
modelSpace.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);
ed.WriteMessage(path);
}
tr.Commit();
}