Launching AutoCAD with a specific profile using .NET - Through the Interface (typepad.com)
All the similar blogs Launching AutoCAD refer to a certain AutoCAD-Version.
Is it possible to choose and launch different AutoCAD-Versions at runtime and get their acApp?
Binding the project with a certain AutoCAD type library (lets say SDK 2021) ->
"acApp =(AcadApplication)Marshal.GetActiveObject(progID)" is NULL for all versions other than 2021!
void lauchAutoCADdoSomething(int nVer) {
AcadApplication acApp = null;
string progID;
if (nVer == 2007) {
progID = "AutoCAD.Application.17.1";
}
.....
.....
if (nVer == 2020) {
progID = "AutoCAD.Application.23.1";
}
if (nVer == 2021) {
progID = "AutoCAD.Application.24";
}
acApp =(AcadApplication)Marshal.GetActiveObject(progID);
if (acApp != null)
{
acApp.Visible = true;
AcadDocuments acDocs = acApp.Documents;
......
.....
acApp.ActiveDocument.SendCommand("_MYCOMMAND ");
.....
.....
}
return;
}
Well, since your app (you did not explicitly say, but I assume it is a stand-alone EXE app that you use for automating a running AutoCAD session, because you use GetActiveObject(progID) to create an AcadApplication instance in your app) is set to reference AutoCAD 2021 type library interop, it would not work with ANY earlier version of AutoCAD other than AutoCAD 2021, which you have already known, as you described. That is, trying to come up with different ProgID (i.e. "AutoCAD.Application.xxx") makes no sense, because your app has already been compiled with early binding to AutoCAD 2021.
If you want your app with multiple versions of AutoCAD, you need to use late binding and make sure you app only deals with AutoCAD's features that apply to all target AutoCAD versions
Norman Yuan
This is what i've already described. I just want to avoid "Late Binding" and "Reflection"..... if somehow possible.
Can't find what you're looking for? Ask the community or share your knowledge.