2013-08-05 36 views
0

我寫了這個代碼:的Autocad右鍵單擊事件處理程序

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++; 
} 

代碼工作正常,但到coplete圖紙我必須鍵入ESC,我想請右鍵單擊或空格鍵點擊閉上loop.Can我能做到嗎?

回答

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,並通過改變你的循環EVAL你會出來當用戶選擇是,你可以設置了一空格鍵新聞。

希望這有助於:)

+0

PromptPointOptions即時使用和pointOptions是變量。 –

+0

我會等待:) –

+0

@AntonioPapa更新。 –