Opening any version of Autocad from windows form application

前端 未结 2 1313
南方客
南方客 2021-01-29 10:46

I am currently creating a windows form application that needs to open autocad .I have done it for Autocad 2014.Is there any way we can do this task workable not just for single

相关标签:
2条回答
  • 2021-01-29 11:00

    For your first question, here are some suggestions:

    1. AutoCAD via COM API, where you can launch and control the application. Here is a nice tutorial, note the version string can be changed on runtime, but to support multiple versions, you'll need Late-binding (dynamic on C#).
    2. AutoCAD Console (aka AutoCAD via command line), available since version 2013, is the best way to automate AutoCAD from another application.
    3. Forge Design Automation API is the AutoCAD "on the cloud", best if you don't have AutoCAD installed on yours or on the customer's machine.

    If you go with #1, the best way is via late-binding, so you don't have any reference on your app (don't use AcMgd, AcDbMgd or AcCoreMgd, use only the Autodesk.AutoCAD.Interop libraries). For #2 you'll need all three references (as the console is available since version 2013). For #3 you just need to call a webservice, so no Autodesk reference at all (cleanest).

    For your second question, you'll need to compile your application twice, at least: for AutoCAD 2012 and older, and again for AutoCAD 2013 and newer. The first with AcMgd and AcDbMgd, and the second just add AcCoreMgd.

    0 讨论(0)
  • 2021-01-29 11:06

    One way to potentially achieve this is to find out which program is associated with Autocad files. This can be found by calling FindExecutable passing in a filename with an autocad file extension.

    Once you have the executable to use you could launch it using Process.Start

    Import as follows:

    [DllImport("shell32.dll", EntryPoint = "FindExecutable")]
    private static extern long FindExecutable(string lpFile, string lpDirectory, StringBuilder lpResult);
    
    0 讨论(0)
提交回复
热议问题