私は、その一部にいくつかのオートカード機能が必要なアプリケーションを作成しようとしています。だから私はスタンドアロンアプリケーションのためにインターネットで何かを試しましたが、何も起こらず、私はいつもエラーを返します。 (それは、ちょうどプリインストールオープンAutoCADのプラグインと何かを描画していない) 私の最初の試み:スタンドアロンのautocad .netアプリケーションの作成方法
AcadApplication gbl_app = new AcadApplication();
AcadDocument gbl_doc = gbl_app.ActiveDocument;
gbl_app.Application.Visible = true;
そして、これが最初の行に上げるエラーです。
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)).
私の2回目の試行:
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);
そして、これは誤りです:
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)).
だから、本当に私は、スタンドアロンのアプリケーションを作ることができますか?
ありがとう a.h
「AutoCAD.Application.20」は、AutoCAD 2015および2016でのみ機能します。「AutoCAD.Application」を使用して任意のAutoCADバージョン(LTを除く)を対象としてください。 – gileCAD
「AutoCAD.Application」を使用すると何も起こりません。 AutoCADは2015です –
@gileCAD "AutoCAD.Application"を試しましたが、 "AutoCAD.Application.20"と同じエラーが発生します。 –