打开一文档并选择实体问题
本帖最后由 arxnew 于 2010-12-30 17:22 编辑打开文档后,做选择实体操作不执行,除非关闭此文档才继续执行,这是为什么?
publicvoid SelEnts()
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
//openDialog.Filter="*.dwg|*.dwf|*.dwt|";
//openDialog.DefaultExt=".dwg";
if (openDialog.ShowDialog()!= System.Windows.Forms.DialogResult.OK) return;
string file=openDialog.FileName;
bool isopen = false;
foreach (Document doc in Application.DocumentManager)
{
if (doc.Name == file)
{
Application.DocumentManager.MdiActiveDocument = doc;
isopen = true;
break;
}
}
if (!isopen)
{
Document doc=Application.DocumentManager.Open(file, true);
//Application.DocumentManager.MdiActiveDocument = doc;
}
m_editor = Application.DocumentManager.MdiActiveDocument.Editor;
m_db = HostApplicationServices.WorkingDatabase;
PromptSelectionOptions promptSelection = new PromptSelectionOptions();
promptSelection.MessageForAdding = "选择实体!";
PromptSelectionResult promptSelResult = m_editor.GetSelection(promptSelection);
if (promptSelResult.Status != PromptStatus.OK) return;
SelectionSet selectionSet=promptSelResult.Value;
}
在命令中调用的话,设置命令函数的CommandMethod属性
CommandFlags.Session
已解决,只是在打开文档后无须重新设置为当前文档。另外db,editor须重新指定。
页:
[1]