Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to create an C# Window Application that will lanch the AutoCad and will load the external plugin


What I have tried:

I tried
cad_app.ActiveDocument.SetVariable("Filedia", "0")

cad_app.ActiveDocument.SendCommand(@"Netload C:\ObjectARX 2013\samples\dotNet\HelloWorld\bin\HelloWorld.dll")

But It Require enter or space in command window of Autocad.
Posted
Updated 18-May-17 1:54am

1 solution

C#
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
 
[CommandMethod("OpenDrawing", CommandFlags.Session)]
public static void OpenDrawing()
{
    string strFileName = "C:\\campus.dwg";
    DocumentCollection acDocMgr = Application.DocumentManager;

    if (File.Exists(strFileName))
    {
        acDocMgr.Open(strFileName, false);
    }
    else
    {
        acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " + strFileName +
                                                        " does not exist.");
    }
}
Souce: Create and Open a Drawing (.NET) | Search | Autodesk Knowledge Network
 
Share this answer
 
Comments
Khushalchouhan 20-May-17 7:05am    
Thanks for your response but I don't have any issue in opening the drawing file i have an issue in loading the user created plugin in to AutoCad using window Interface without going into AutoCad

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900