.NET external application - Workflow automation - Search and replace DWG
Hey,
I'm doing a bit of workflow automation. I want to use the BricsCad interop to search and replace text in a dwg file. I want it to be an external application as I'm populating directories and other file types (Excel, word templates)
My application targes .Net 5.0
I've add references to BrxMgd.DLL and TD_Mgd.DLL (local copy = false). Separate class library to the winforms app.
However, as soon as I hit Execute(). I get a 'file not found exception. BrxMgd.DLL can't be found?
Any help or Code snippest would be appreciated.
using AcRx = Bricscad.Runtime;
using AcTrx = Teigha.Runtime;
using AcAp = Bricscad.ApplicationServices;
using AcDb = Teigha.DatabaseServices;
using AcGe = Teigha.Geometry;
using AcEd = Bricscad.EditorInput;
using AcGi = Teigha.GraphicsInterface;
using AcClr = Teigha.Colors;
using AcWnd = Bricscad.Windows;
using AcApP = Bricscad.ApplicationServices.Application;
public override bool Execute()
{
AcAp.Document doc = AcApP.DocumentManager.MdiActiveDocument;
AcEd.Editor ed = doc.Editor;
AcDb.Database destDb = doc.Database;
try
{
// Create a source database to load the DWG into
using (AcDb.Database db = new AcDb.Database(false, true))
{
// Read the DWG into our side database
db.ReadDwgFile(templateFile, AcDb.FileOpenMode.OpenForReadAndAllShare, false, string.Empty);
AcDb.Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
//// DO SEARCH AND REPLACE HERE
AcDb.DBObjectCollection obs = tr.GetAllObjects();
foreach (AcDb.DBObject ob in obs)
{
AcDb.MText mt = ob as AcDb.MText;
if (mt != null)
{
System.Console.Write(mt.Text);
}
//tr.Commit();
}
}
}
}
catch (System.Exception e)
{
Console.Out.WriteLine(e.Message);
Console.Out.WriteLine(this.target + "caused and error, skipping");
}
0