Hello,Mr.Liang,can i ask you some other questions?
i want search some modelitems and i find them ,then i want to zoom to the modelitem,but i find .NET api has no related api ,the com api has ,so i use ComApiBridge to use the com api but it throw a exception called
"Application::MainDocument is Null,COM API not available",what's wrong?
i find the Autodesk.Navisworks.Api.Application.MainDocument is always null,how to solve this problem
the code is below,the project is in attachment
Search s = new Search();
s.SearchConditions.Add(SearchCondition.HasCategoryByName("LcRevitId"));
s.SearchConditions.Add(SearchCondition.HasPropertyByName("LcRevitId", "LcOaNat64AttributeValue").EqualValue(VariantData.FromDisplayString(txtModelID.Text.Trim())));
s.Selection.SelectAll();
s.Locations = SearchLocations.DescendantsAndSelf;
ModelItemCollection mic = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false);
if (mic == null || mic.Count == 0)
{
MessageBox.Show("没有对应ID的元素");
}
else
{
ModelItem item = mic.First();
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Add(item);
InwOpState10 oState = ComApiBridge.State;
//InwOaPath3 path = ComApiBridge.ToInwOaPath(item) as InwOaPath3;
//oState.ZoomInCurViewOnBoundingBox(path.GetBoundingBox(), 1);
oState.ZoomInCurViewOnCurSel();
}