Ich versuche, eine Anwendung zu machen, dass ein Teil davon einige AutoCAD-Funktionen benötigt. Also habe ich alles im Internet für Standalone-Anwendungen ausprobiert, aber nichts passiert und ich gebe immer einen Fehler zurück. (Es ist nicht Plugin, nur offen vorinstalliert Autocad und zieht etwas) Meinen ersten Versuch:Wie man eine autonome autocad.net-Anwendung erstellt
AcadApplication gbl_app = new AcadApplication();
AcadDocument gbl_doc = gbl_app.ActiveDocument;
gbl_app.Application.Visible = true;
Und das ist Fehler, die in erster Linie erhöhen.
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in SBDesign.exe
Additional information:
Retrieving the COM class factory for component with CLSID {0D327DA6-B4DF-4842-B833-2CFF84F0948F}
failed due to the following error: 80040154
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Mein zweiter Versuch:
AcadApplication acAppComObj = null;
const string strProgId = "AutoCAD.Application.20";
// Get a running instance of AutoCAD
try
{
acAppComObj = (AcadApplication)Marshal.GetActiveObject(strProgId);
}
catch // An error occurs if no instance is running
{
try
{
// Create a new instance of AutoCAD
acAppComObj = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(strProgId), true);
}
catch(Exception er)
{
// If an instance of AutoCAD is not created then message and exit
System.Windows.Forms.MessageBox.Show("Instance of 'AutoCAD.Application'" +
" could not be created.");
return;
}
}
// Display the application and return the name and version
acAppComObj.Visible = true;
System.Windows.Forms.MessageBox.Show("Now running " + acAppComObj.Name +
" version " + acAppComObj.Version);
Und das ist der Fehler:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'.
This operation failed because the QueryInterface call on the COM component for
the interface with IID '{10E73D12-A037-47E5-8464-9B0716BE3990}'
failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Also wirklich, wie kann ich eine Standalone-Anwendung zu machen?
Danke A. h
"AutoCAD.Application.20" funktioniert nur mit AutoCAD 2015 und 2016. Verwenden Sie "AutoCAD.Application", um eine AutoCAD-Version (außer LT) als Ziel zu verwenden. – gileCAD
Wenn ich "AutoCAD.Application" verwende, passiert nichts. Mein AutoCAD ist 2015 –
@gileCAD Ich habe "AutoCAD.Application" versucht, aber ich bekomme den gleichen Fehler, der für "AutoCAD.Application.20" passiert. –