Navisworks API

Reply
New Member
Posts: 2
Registered: ‎05-03-2012
Message 1 of 2 (141 Views)

DataProperty Value 'Unknown'

141 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
Posts: 2
Registered: ‎05-03-2012
Message 2 of 2 (139 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;                     
        }

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community