|
![]() |
Namespace: Autodesk.Navisworks.Api
Assembly: Autodesk.Navisworks.Api (in Autodesk.Navisworks.Api.dll)
Syntax
Visual Basic |
---|
Public Class NamedConstant _ Inherits NativeHandle |
C# |
---|
public class NamedConstant : NativeHandle |
Visual C++ |
---|
public ref class NamedConstant : public NativeHandle |
Remarks
NamedConstant's are, for most instances, an identifier for a value combining the internal constant's name and a localized display name equivalent.
For example to identify the PropertyCategory called 'Item' we could use the identifier NamedConstant("LcOaNode", "Item"), where "Item" is the localized display name and "LcOaNode" is the internal name.
For most instances, such as the example above, there are other methods one can use to search for the given property, such as SearchCondition.HasPropertyByName for the above example. NamedConstants should only be used when both the internal name and the display name are both known and specifically where the display name is unaffected by localization.
Examples

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows.Forms; using System.Text; using Autodesk.Navisworks.Api.Controls; //This sample should be tried with the GateHouse sample drawing, public static void NamedConstantSearch() { //Create a new search object Search s = new Search(); //Add our search condition s.SearchConditions.Add( new SearchCondition( new NamedConstant("LcOaNode", "Item"), new NamedConstant("LcOaNodeHidden", "Hidden"), SearchConditionOptions.StartGroup, SearchConditionComparison.Equal, VariantData.FromBoolean(false) ) ); //Note, this particular search would be better acheived using other methods than NamedConstant //and is purely to demonstrate NamedConstant usage. //for example a better form of the same query would be: //s.SearchConditions.Add( // SearchCondition.HasPropertyByName(PropertyCategoryNames.Item, DataPropertyNames.ItemHidden) // .EqualValue(VariantData.FromBoolean(false))); // // //Set the selection which we wish to search s.Selection.SelectAll(); s.Locations = SearchLocations.DescendantsAndSelf; //halt searching below ModelItems which match this s.PruneBelowMatch = true; //get the resulting collection by applying this search ModelItemCollection searchResults = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false); StringBuilder output = new StringBuilder(); output.AppendLine("Found the following:"); //show the results foreach (ModelItem mi in searchResults) { output.AppendLine(mi.ToString()); } MessageBox.Show(output.ToString()); }
Inheritance Hierarchy
Autodesk.Navisworks.Api..::..NativeHandle
Autodesk.Navisworks.Api..::..NamedConstant