|
![]() |
Namespace: Autodesk.Navisworks.Api.Plugins
Assembly: Autodesk.Navisworks.Api (in Autodesk.Navisworks.Api.dll)
Syntax
Remarks
This class can be used as a base class for a plugin to Navisworks when none of the other specialized plugin behaviour is required.
For example, if a user wishes to write a set of plugins which can be called by a third party program, and wants the benefits of the plugins architecture within Navisworks, they may choose to use this class as a base class.
Combining this class and InterfaceAttribute is an effective way of providing an easily identifiable customised plugin within the wider collection of plugins.
InterfaceAttribute can be used to group a collection of plugins; the plugins assigned the same InterfaceAttribute can be found using Application.Plugins.FindInterfaces.

Examples

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows.Forms; using System.Text; using Autodesk.Navisworks.Api.Controls; namespace VehicleAddin { [Plugin("VehiclePlugin", "ADSK")] //standard Plugin attribute [AddInPlugin(AddInLocation.AddIn, CallCanExecute = CallCanExecute.Always, LoadForCanExecute = false)] public class VehicleAddin : AddInPlugin { //When called this searches all the plugins for the attribute defined interface //then displays a message box with the plugin details public override int Execute(params string[] parameters) { //load the bike plugin PluginRecord bikePluginRecord = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("BikePlugin.ADSK"); if (bikePluginRecord != null) { if (!bikePluginRecord.IsLoaded) { bikePluginRecord.LoadPlugin(); } } StringBuilder output = new StringBuilder(); output.AppendLine("The following 'Vehicles.ADSK' interfaces were found:"); foreach (PluginRecord pr in Autodesk.Navisworks.Api.Application.Plugins.FindInterfaces("Vehicles.ADSK")) { output.Append("DisplayName="); output.Append(pr.DisplayName); output.Append(", IsLoaded="); output.Append(pr.IsLoaded); if (pr.IsLoaded && pr.LoadedPlugin is VehiclePlugins.VehiclePlugin) { output.Append(", Vehicle is "); output.Append((pr.LoadedPlugin as VehiclePlugins.VehiclePlugin).VehicleType); } output.AppendLine(); } MessageBox.Show(output.ToString()); return 0; } } } namespace VehiclePlugins { [Plugin("VehiclePlugin", "ADSK")] //standard Plugin attribute [Interface("Vehicles", "ADSK")] //All the vehicles implement the same interface so they can be easily searched for public abstract class VehiclePlugin : CustomPlugin { abstract public string VehicleType { get; } } [Plugin("CarPlugin", "ADSK")] //standard Plugin attribute [Interface("Vehicles", "ADSK")] //All the vehicles implement the same interface so they can be easily searched for) public class CarPlugin : VehiclePlugin { public override string VehicleType { get { return "a car"; } } } [Plugin("BikePlugin", "ADSK")] //standard Plugin attribute [Interface("Vehicles", "ADSK")] //All the vehicles implement the same interface so they can be easily searched for public class BikePlugin : VehiclePlugin { public override string VehicleType { get { return "a bike"; } } } [Plugin("TruckPlugin", "ADSK")] //standard Plugin attribute [Interface("Vehicles", "ADSK")] //All the vehicles identify with the same interface so they can be easily searched for public class TruckPlugin : VehiclePlugin { public override string VehicleType { get { return "a truck"; } } } }
Inheritance Hierarchy
Autodesk.Navisworks.Api.Plugins..::..Plugin
Autodesk.Navisworks.Api.Plugins..::..CustomPlugin
Autodesk.Navisworks.Api.Timeliner..::..TimelinerDataSourceProvider