Posts: 5
Registered: ‎06-19-2013
Message 1 of 2 (205 Views)

How to ddd external references in the drawing? (C#)

205 Views, 1 Replies
06-19-2013 12:35 AM

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);


      tr.AddNewlyCreatedDBObject(br, true);







ADN Support Specialist
Posts: 352
Registered: ‎07-24-2007
Message 2 of 2 (179 Views)

Re: How to ddd external references in the drawing? (C#)

06-19-2013 08:45 AM in reply to: Sfinks7s

don't call AttachXRef while inside a transaction, see if that solves your problem.

Fenton Webb

Developer Technical Services

Autodesk Developer Network

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.