0

我写了这段代码:

int count = 1;

while (true)
{

    pointOptions.Message = "\nEnter the end point of the line: ";
    pointOptions.UseBasePoint = true;
    pointOptions.BasePoint = drawnLine.EndPoint;
    pointResult = editor.GetPoint(pointOptions);

    if (pointResult.Status == PromptStatus.Cancel)
    {
        break;
    }

    if (count == 1)
    {
        drawnLine.AddVertexAt(count, pointResult.Value.Convert2d(new Plane()), 0, 0, 0);
        blockTableRecord.AppendEntity(drawnLine);
        transaction.AddNewlyCreatedDBObject(drawnLine, true);
    }
    else
    {
        stretch(drawnLine, pointResult.Value, Point3d.Origin);
    }

    editor.Regen();

    count++;
}

代码工作正常,但要完成绘图我必须输入 ESC,我想右键单击或空格键单击以关闭我的循环。我可以这样做吗?

4

1 回答 1

1

它在下面的PromptPointOptions代码示例中:

// Set promptOptions
var pointOptions = new PromptPointOptions("\nSelect Next Point: ");
pointOptions.SetMessageAndKeywords("\nSelect Next Point: or Exit [Y]","Yes");
pointOptions.AppendKeywordsToMessage = true;
pointOptions.AllowArbitraryInput = true;
pointOptions.UseBasePoint = true;
pointOptions.BasePoint = drawnLine.EndPoint;

// While user wants to draw the polyline
while (pointResult.Status != PromptStatus.Keyword)
{
// Get point
pointResult = Editor.GetPoint(pointOptions);

// stop creating polyline
if (pointResult.Status == PromptStatus.Cancel)
    break;

if (count == 1) {

    // Get base point and add to the modelspace
    drawnLine.AddVertexAt(count, pointResult.Value.Convert2d(new Plane()), 0, 0, 0);
    blockTableRecord.AppendEntity(drawnLine);
    transaction.AddNewlyCreatedDBObject(drawnLine, true);
} else

    // Grow the polyline
    stretch(drawnLine, pointResult.Value, Point3d.Origin);

// Regen
editor.Regen();

count++;
}

您正在寻找的是PromptPointOptions.SetMessageAndKeywords并且通过更改循环评估,当用户选择“是”时您会出来,您可以将其设置为按空格键。

希望这可以帮助 :)

于 2013-08-05T23:47:34.920 回答