Navisworks API : Timeliner Part-2

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.

Timeliner Part-2 Demo

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)

figure 1.0 – AddInPlugin Location & Interface Attribute

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.
figure 1.1 – Abstract Members

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)

figure 1.2 – CreateDataSource

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)

figure 1.3 – AddAvailableFields Method

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)

figure 1.4 – ImportTasksCore

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)

figure 1.5 – Read csv Data

Custom StringToDateTime method for conversion of string/text to DateTime format for timeliner scheduling. (figure 1.6)

figure 1.6 – StringToDateTime method

“getSelectionSetByName” method returns a SelectionSet which display name have same string value with provided parameter string value. (figure 1.7)

figure 1.7 – getSelectionSetByName method

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)

figure 1.8 – UpdateDataSource

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 dll file.

figure 1.9 – Debug > Start External Program

That’s all for this tutorial, you can get the complete source code from here, Cheers!


Posted

in

, ,

by

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: