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

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

Anonymous
Not applicable
550 Views
1 Reply
Message 1 of 2

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

Anonymous
Not applicable

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

}

 

 

0 Likes
551 Views
1 Reply
Reply (1)
Message 2 of 2

fenton_webb
Autodesk
Autodesk

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




Fenton Webb
AutoCAD Engineering
Autodesk

0 Likes