그런 다음 외부 프로세스에서 Document.GetVariable
COM API를 읽을의 USERR1 to USERR5 시스템 변수에 거리를 저장할 수 있습니다.
EndCommand
이벤트에 처리기를 설치하여 명령 완료 시점을 감지 할 수 있습니다. 당신이 당신의 창 형태의 응용 프로그램에서 AutoCAD에서 플러그인을로드하는 방법
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;
}
}
: 여기
몇 가지 코드? 어떻게 명령을 내리고 있니? – Maxence다음과 같이 추가하면됩니다 : (명령 "+ (char) 34 +"NETLOAD "+ (char) 34 +" "+ (char) 34 + (Dll 경로) + (char) 34 +") "; 버튼을 클릭 이벤트. 그냥 명령을 사용하여 lauch SendCommand –
나는 this.So에 새로운 오전 EndCommand 이벤트 처리기를 설치하는 방법을 묻는 오전. 예를 들어 제공 할 수 있다면 위대한 것입니다. –