Ok, I think we finally have made some progress, at least from reproducing the issue.
Please see the attached project and screen shots. The project is hard coded to load the model from the C:\ drive.
When you click the process button, 2 things will happen.
1) The document (from the DocumentControl) will be searched for the Element ID property, just as you have done in your examples. You will see, in both the screen shots and the running project, the "Category - Property" list contains all the aforementioned categories and properties.
2) The document (from the DocumentControl) will walk through all the ModelItems within the Model. You will see, in both the screen shots and the running project, the "Category - Property" list does NOT contain several categories, per my original post issue.
In our main project, when we click a model item to select it, the ModelItem returned as part of the selection does not contain the properties either, so we really need to be able to have the properties loaded with the document control and not only returned as part of a search.
Please let me know what we can do to alleviate this problem.
Thanks,
Jon
P.S.
The project I tried to upload exceeded the 5MB limit, so I have pasted the code for the code-behing below. The window was built based on the http://adndevblog.typepad.com/aec/2013/03/use-navisworks-api-with-wpf-create-a-net-control-applicati... example, so you should be able to easily re-create the project.
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace NavisTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
DocumentControl _docControl = new DocumentControl();
HashSet<string> _properties = new HashSet<string>();
HashSet<string> _searchProperties = new HashSet<string>();
public MainWindow()
{
ApplicationControl.Initialize();
InitializeComponent();
viewControl.DocumentControl = _docControl;
string file = @"C:\BRIC-NWD1.nwd";
_docControl.Document.TryOpenFile(file);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
// search the model, all properties are there
TestSearch(_docControl.Document);
// walk the model, missing properties
ProcessModel(_docControl.Document);
}
private void Window_Closed(object sender, EventArgs e)
{
// terminate the control application
// ApplicationControl.Terminate();
}
private void ProcessModel(Document doc)
{
if (doc.Models.Count > 0)
{
Model theModel = doc.Models[0];
foreach (ModelItem item in theModel.RootItem.Children)
{
ProcessModelItems(item);
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("Results from Walking the Model:");
foreach (string catProp in _properties.OrderBy(s => s))
{
sb.AppendLine(catProp);
}
MessageBox.Show(sb.ToString());
}
}
private void ProcessModelItems(ModelItem item)
{
if (item.Children.Count() > 0)
{
foreach (ModelItem child in item.Children)
{
ProcessModelItems(child);
}
}
if (item.HasGeometry)
{
ProcessCategories(item);
}
}
private void ProcessCategories(ModelItem item)
{
foreach (PropertyCategory propCat in item.GetUserFilteredPropertyCategories())
{
foreach (DataProperty propData in propCat.Properties)
{
_properties.Add(string.Format("{0} - {1}", propCat.DisplayName, propData.DisplayName));
}
}
}
private void TestSearch(Document doc)
{
var search = new Search();
search.Selection.SelectAll();
search.SearchConditions.Add(SearchCondition.HasPropertyByName("LcRevitId", "LcOaNat64AttributeValue").EqualValue(VariantData.FromDisplayString("331809")));
var items = search.FindAll(doc, false);
doc.CurrentSelection.CopyFrom(items);
var selected = doc.CurrentSelection.SelectedItems[0];
foreach (var propCat in selected.PropertyCategories)
{
foreach (DataProperty propData in propCat.Properties)
{
_searchProperties.Add(string.Format("{0} - {1}", propCat.DisplayName, propData.DisplayName));
}
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("Results from Search:");
foreach (string catProp in _searchProperties.OrderBy(s => s))
{
sb.AppendLine(catProp);
}
MessageBox.Show(sb.ToString());
}
}
}