is there an idiouts guide... 101 type of class? with Revit there is a nice zip file that has a template for the creation of a Revit addin and a great blog community controlled by Jeremy T. With Navisworks, there is a massive (lots of content of different types all in one place) example solution available, and some documentation that no where really states that I can find... this is how to start.
What are the basics I need to put into a Navisworks plugin? I tried the following and nothing loads in Navisworks, this type of basics is where I am not able to progress:
WPFDocuPaneAddin.cs
using System;
using System.Linq;
using Autodesk.Navisworks.Api.Plugins;
namespace WpfDockPane
{
[Plugin("WpfDockPane.WPFDockPaneAddin", "ADSK",
DisplayName = "WPFDockPaneAddin",
ToolTip = "Basic CSharp Dock Pane Plugin")]
public class WPFDockPaneAddin : AddInPlugin
{
public override int Execute(params string[] parameters)
{
if (Autodesk.Navisworks.Api.Application.IsAutomated)
{
throw new InvalidOperationException("Invalid when running using Automation");
}
//Find the plugin
PluginRecord pr =
Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("WpfDockPane.WPFDocPanePlugin.ADSK");
if (pr != null && pr is DockPanePluginRecord && pr.IsEnabled)
{
//check if it needs loading
if (pr.LoadedPlugin == null)
{
pr.LoadPlugin();
}
DockPanePlugin dpp = pr.LoadedPlugin as DockPanePlugin;
if (dpp != null)
{
//switch the Visible flag
dpp.Visible = !dpp.Visible;
}
}
return 0;
}
}
}
WPFDocPanePlugin.cs
using System.Windows.Forms.Integration;
using Autodesk.Navisworks.Api.Plugins;
namespace WpfDockPane
{
#region WPFDocPanePlugin
[Plugin("WpfDockPane.WPFDocPanePlugin", "ADSK",
DisplayName = "WPFDocPanePlugin",
ToolTip = "Basic WPF Docking Pane Plugin")]
[DockPanePlugin(150, 200, FixedSize = false)]
class WPFDocPanePlugin : DockPanePlugin
{
public override System.Windows.Forms.Control CreateControlPane()
{
//create an ElementHost
ElementHost eh = new ElementHost();
//assign the control
eh.AutoSize = true;
eh.Child = new WPFHelloWorldControl();
eh.CreateControl();
//return the ElementHost
return eh;
}
public override void DestroyControlPane(System.Windows.Forms.Control pane)
{
pane.Dispose();
}
}
#endregion
}
WPFHelloWorldControl.xaml
<UserControl x:Class="WpfDockPane.WPFHelloWorldControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="200" Width="150">
<Grid>
<Label Canvas.Left="18" Canvas.Top="77" Height="28" Name="label1" VerticalAlignment="Top">Hello World in WPF!!!</Label>
</Grid>
</UserControl>
WPFHellowWorldControl.xaml.cs
using System.Windows.Controls;
namespace WpfDockPane
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class WPFHelloWorldControl : UserControl
{
public WPFHelloWorldControl()
{
InitializeComponent();
}
}
}
I added references to Autodesk.Navisworks.Api, Autodesk.Navisworks.Controls & WindowsFormsIntegration
I put the following post build event:
mkdir "C:\Program Files\Autodesk\Navisworks Manage 2015\Plugins\$(TargetName)"
copy "$(TargetDir)" "C:\Program Files\Autodesk\Navisworks Manage 2015\Plugins\$(TargetName)"
I pointed the Debug Start Action to Roamer.exe
It builds sucessfully, but there are no Ribbon tools within Manage which I think maybe is trying to be acoumplished with the [Plugin code, but again this is all just really a guess...
So does anyone have a good guide as to how to get started with this API?
Thanks so much for reading to here, and thanks if you have anything that can help.
hi Drew,
happy new year!
Sorry for any of your frustration.
Although we have not a specific resources library for Navisworks API, we have posted many articles on our AEC blog:
http://adndevblog.typepad.com/aec
regarding the question of WPF, I have written 2 blogs:
could you check if they could help you?