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

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

216 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 (190 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.