Accessing takeoff data through the Navisworks API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I'm trying to access takeoff data through the Navisworks API, but so far I have had no luck. I tried using the pieces of code that are in the Navisworks .NET API documentation, but those bring me nowhere closer to the result.
I have tried quering the takeoff variables, but that results in column names not the values of the variables itself:
DocumentTakeoff docTakeoff = Autodesk.Navisworks.Api.Application.MainDocument.GetTakeoff(); List<TakeoffVariableDefinition> takeoffVariableDefinitions = docTakeoff.Objects.Variables.ToList();
In addition to that, I have also tried quering data (i.e object values in objects table) through SQL-like sentences, which also gives no result:
List<String> values = new List<String>();
cmd.CommandText = "select object_value from tk_object";
using (NavisWorksDataReader dataReader = cmd.ExecuteReader())
{
if (dataReader.Read())
{
values.Add(dataReader.NextResult().ToString())
}
return values;
}
Lastly I have also tried finding the variable (i.e model length) by name and getting it's value:
DocumentTakeoff docTakeoff = Autodesk.Navisworks.Api.Application.MainDocument.GetTakeoff();
TakeoffVariableCollection variableCollection = docTakeoff.Objects.SelectInputVariables(objectId);
Int32 lengthIndex = variableCollection.Find("ModelLength");
String value = null;
if (lengthIndex != -1)
{
TakeoffVariable lengthVariable = variableCollection.GetItem(lengthIndex);
value = lengthVariable.Value.ToString();
}
return value;
Could anyone explain what am I doing wrong or give me directions how to move on. Also it would be great to know, what are the tables in Navisworks API and what data do they correspond to. In the end, it should be possible to reach the quantification data (i.e. object, width, height, count), through a C# plugin.
Dan