Welcome to the thirteenth tutorial of
Navisworks® API series, this post is to cover how to automate the Timeliner Tasks from External Data Source, a csv scheduling data file, with primary properties such as .. Start/End Date, TaskType and Attached (SelectionSet) for the Timeliner Simulation.
Let’s cook! since we won’t be executing any command in this tutorial, AddInPlugin location is set to None. Interface attribute uses for grouping a collection of plugins which makes the plugin easier to be searched and found by the framework. (figure 1.0)
MainClass inherited from TimelinerDataSourceProvider class, which requires to implement abstract members and called by the framework. Inherited class provides connection to external scheduling data source and bringing data into Navisworks. (figure 1.1)
Following are list of abstract members (called by framework):
- CreateDataSource – to create a TimelinerDataSource.
- ImportTasksCore – called when the user selects Rebuild or Synchronize on the data source and is responsible for creating Timeliner task from the selected external data.
- UpdateDataSource – called when the user clicks edit in the DataSource tab.
- ValidateSettings – to validate TimelinerDataSource settings.
- DisposeManagedResources – as part of IDisposable.
- DisposeUnmanageResources – as part of IDisposable.
- IsAvailable – to determine if this TimelinerDataSourceProvider is available to import tasks, default returns true.
CreateDataSource returns TimelinerDataSource object which contains details of external project data and how to reconnect to that external data. ProjectIndentifier property link to data-source.csv file. DataSourceProviderId set plugin/base Id value, for Version just provide an optional number and provider name matching Plugin name. (figure 1.2)
AddAvailableFields method to populate the AvailableFields with the fields you wish users to be able to map. (In this tutorial, Task schedule are generated from ImportTasksCore method, this mapping method can be omitted too). (figure 1.3)
Mapped Available Fields to Timeliner Fields
ImportTasksCore method called when the user selects Rebuild or Synchronize on the data source and is responsible for creating Timeliner tasks from the selected external data, returns reports of calling ImportTasks. Report contains details of any issues encountered during a TimelinerTask Import operation. Create a parent/root TimelinerTask to hold the Timeliner Tasks generated from csv data source file. To do so, we will read csv stream data line by line and split line with ” , ” character till end of the stream data. (figure 1.4)
Array string “fields” to store separated value from each line and set Timeliner property value for; SynchronizationId, DisplayName, PlannedStartDate, PlannedEndDate & SimulationTaskTypeName respectively from string fields list by each index. Attach selection set for Timeliner simulation from the returns value of “getSelectionSetByName” custom method. (figure 1.5)
Custom StringToDateTime method for conversion of string/text to DateTime format for timeliner scheduling. (figure 1.6)
“getSelectionSetByName” method returns a SelectionSet which display name have same string value with provided parameter string value. (figure 1.7)
UpdateDataSource method called by the framework when the user clicks edit in the datasource tab, it check the datasource file that currently connected to project identifier. Respond was “Ok” if a new csv file was chosen and set to ProjectIdentifier, add available fields for mapping. (figure 1.7)
ValidateSetting, DisposeManagedResources, DisposeUnmanagedResources & IsAvailable abstract members we can just leave as default/empty.
We’ll add Post-build Command line for debugging purpose. (figure 1.9)
In Build Events tab, edit Post-build event :
xcopy /Y "$(TargetDir)." "D:\Autodesk\Navisworks Manage 2023\Plugins\$(TargetName)\" – to copy the output
That’s all for this tutorial, you can get the complete source code from here, Cheers!