距離をUSERR1 to USERR5システム変数に格納してから、外部プロセスからDocument.GetVariable
COM APIで読み取ることができます。
EndCommand
イベントにハンドラをインストールして、コマンドの終了を検出できます。ここで
はいくつかのコードです:
using Autodesk.AutoCAD.Interop;
[..]
void button1_Click(object sender, EventArgs e)
{
const uint MK_E_UNAVAILABLE = 0x800401e3;
AcadApplication acad;
try
{
// Try to get a running instance of AutoCAD 2016
acad = (AcadApplication) Marshal.GetActiveObject("AutoCAD.Application.20.1");
}
catch (COMException ex) when ((uint) ex.ErrorCode == MK_E_UNAVAILABLE)
{
// AutoCAD is not running, we start it
acad = (AcadApplication) Activator.CreateInstance(Type.GetTypeFromProgID("AutoCAD.Application.20.1"));
}
activeDocument = acad.ActiveDocument;
activeDocument.EndCommand += ActiveDocument_EndCommand;
activeDocument.SendCommand("YOURCOMMAND ");
}
void ActiveDocument_EndCommand(string CommandName)
{
if (CommandName != "YOURCOMMAND") return;
try
{
double value = activeDocument.GetVariable("USERR1");
// Process the value
MessageBox.Show(value.ToString());
}
finally
{
// Remove the handler
activeDocument.EndCommand -= ActiveDocument_EndCommand;
}
}
どのようにあなたの窓からAutoCADであなたのプラグインをロードしているアプリケーションを形成しますか?そして、あなたはどのようにコマンドを起動していますか? – Maxence
あなたは次のものを追加するだけです:(コマンド "+(char)34 +" NETLOAD "+(char)34 +" "+ (char)34 +(あなたのDllパス)+(char)34 +") "; atボタンのクリックイベントです。ちょうどSendCommandを使用してlauchコマンドを使用して –
私はthis.soで新しく私はEndCommandイベントにハンドラをインストールする方法を尋ねている。あなたが私に例を提供することができれば素晴らしいだろう –