Navisworks API

Navisworks API

Reply
New Member
p.kieftenbeld
Posts: 2
Registered: ‎05-03-2012
Message 1 of 2 (169 Views)

DataProperty Value 'Unknown'

169 Views, 1 Replies
05-03-2012 12:41 AM

Anyone,

 

When I go through the DataProperties of an element I get all the properties as shown in the properties window.

Sometimes however (for area's and volumes), I get the value 'Unkown', while in the propety value in de properties window is set to a value.

 

I use the following C# code:

 

   foreach (ModelItem item in Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems)
            {             

                foreach (Autodesk.Navisworks.Api.PropertyCategory o in item.PropertyCategories)
                {
                    foreach (Autodesk.Navisworks.Api.DataProperty p in o.Properties)
                    {
                        if (p.Value.ToString() == "Unknown")
                        {
            
                        }
                    }

                }
            }


Does anyone have an idea how to get to the original value?

         

New Member
p.kieftenbeld
Posts: 2
Registered: ‎05-03-2012
Message 2 of 2 (167 Views)

Re: DataProperty Value 'Unknown'

05-03-2012 01:05 AM in reply to: p.kieftenbeld

Problem solved:

 

 private object getPropertyValue(Autodesk.Navisworks.Api.DataProperty property)
        {
            object obj = null;
             switch(property.Value.DataType)
                        {
                 case VariantDataType.Boolean:
                     obj = property.Value.ToBoolean();
                     break;
                 case VariantDataType.DateTime:
                     obj = property.Value.ToDateTime();
                     break;
                 case VariantDataType.DisplayString:
                     obj = property.Value.ToDisplayString();
                     break;
                 case  VariantDataType.Double:
                     obj = property.Value.ToDouble();
                     break;
                 case VariantDataType.DoubleAngle:
                     obj = property.Value.ToDoubleAngle();
                     break;
                 case VariantDataType.DoubleArea:
                     obj = property.Value.ToDoubleArea();
                     break;
                 case VariantDataType.DoubleLength:
                     obj = property.Value.ToDoubleLength();
                     break;
                 case VariantDataType.DoubleVolume:
                     obj = property.Value.ToDoubleVolume();
                     break;
                 case VariantDataType.IdentifierString:
                     obj = property.Value.ToIdentifierString();
                     break;
                 case VariantDataType.Int32:
                     obj = property.Value.ToInt32();
                     break;
                 case VariantDataType.NamedConstant:
                     obj = property.Value.ToNamedConstant();
                     break;
                 case VariantDataType.None:
                     obj = property.Value.ToString();
                     break;
                 case VariantDataType.Point3D:
                     obj = property.Value.ToString();
                     break;
             }
            return obj;                     
        }

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.