首页 > 解决方案 > Editor.GetEntity 不等待用户输入(点击)

问题描述

我有两个 dwg 文件:PID.dwg & 3D.dwg

用例是在 PID.dwg 上运行一个函数,然后在 3D.dwg 上运行——尤其是按这个顺序。

下面 SendCommand 中使用的命令来自一个单独的 DLL 文件,我在执行此函数之前使用 NETLOAD 加载该文件。

Dim app As AcadApplication = CType(Application.AcadApplication, AcadApplication)
' Ctype( Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, 
'        Autodesk.AutoCAD.Interop.AcadApplication )

If isPidAnd3dOpened() Then
    ' Activate PID document
    app.ActiveDocument = acDocPid
    'acDocPid.Activate()
    acDocPid.SendCommand("DOSOMETHINGONPID" & vbCrLf)

    ' Activate 3D document
    app.ActiveDocument = acDoc3d
    'acDoc3d.Activate()
    acDoc3d.SendCommand("DOSOMETHINGON3D" & vbCrLf)
End If

"DOSOMETINGON3D"用户使用的要求和输入的功能Editor.GetEntity

但是,当acDoc3d.SendCommand("DOSOMETHINGON3D" & vbCrLf)执行时,它不会暂停等待用户输入。

我错过了什么?

标签: vb.netautocadautocad-plugin

解决方案


可能您必须等到命令DOSOMETHINGONPID完成。

在 ARX 中会是这样的:

CString activeCMDName = _T("DOSOMETHINGONPID");
bool EOL = false;
while (!EOL)
{
    CString cmds = Variable::Get(_T("CMDNAMES") );      
    if (cmds.Find( activeCMDName ) > 0 )    {
        Command::Wait();
    }
    else    {
        EOL = true;
    }
}

在哪里

CString Variable::Get( CString name )
{
    CString OutVal;
    resbuf rb ;
    acedGetVar(name, &rb);
    OutVal.SetString(rb.resval.rstring);
    acutDelString(rb.resval.rstring);   
    return OutVal ;
}

void Command::Wait()
{
    ResBuf rb;
    rb.Add(RTSTR , _T("\\"));
    int ret = acedCmd(rb.GetFirst());
}

对不起,我没有这个代码.net。希望你能处理好这个。


推荐阅读