|
![]() |
A value type that can store data of one of several different types.
Namespace: Autodesk.Navisworks.Api
Assembly: Autodesk.Navisworks.Api (in Autodesk.Navisworks.Api.dll)
Syntax
Visual Basic |
---|
Public Class VariantData _ Inherits NativeHandle |
C# |
---|
public class VariantData : NativeHandle |
Visual C++ |
---|
public ref class VariantData : public NativeHandle |
Remarks
Considered an immutable value type.
Remarks
This class is used to store data of several different types.
The most common usage of this class can be found when performing a specific search using the Search and SearchCondition classes.
For more information on searches see 'Properties and Searching' in the 'Developer guide'.
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
System..::..Object
Autodesk.Navisworks.Api..::..NativeHandle
Autodesk.Navisworks.Api..::..VariantData
Autodesk.Navisworks.Api..::..NativeHandle
Autodesk.Navisworks.Api..::..VariantData