I want to make a very simple program that I will use in Navisworks Manage 2023 to get the names of all the currently selected elements. I have never ran an external program in Navisworks before so I may be doing something wrong with the building of the .dll file or maybe there is something else I am missing (I have seen some sources saying I need a .xml file and other tutorials I have watched never even mention a .xml file).
Here is my C# source code in question, but I know how to write in C# so I am not sure this is the issue:
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
namespace ModelLister
{
[Plugin("ExportSelectedItems", "YourCompany", ToolTip = "Exports names of selected items to a text file", DisplayName = "Export Selected Items")]
public class ExportSelectedItems : AddInPlugin
{
public override int Execute(params string[] parameters)
{
// Get the current selection
ModelItemCollection selectedItems = Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems;
// Extract names
List<string> itemNames = new List<string>();
foreach (var item in selectedItems)
{
itemNames.Add(item.DisplayName);
}
// Ask user to select file location
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Text Files (*.txt)|*.txt";
saveFileDialog.DefaultExt = "txt";
saveFileDialog.AddExtension = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
// Write names to file
File.WriteAllLines(saveFileDialog.FileName, itemNames);
}
return 0;
}
}
}
These are the only errors that are being thrown, but I genuinely don't believe that they are related to me:
Error NWTreeComboControl, Name='mTreeComboControl' DropDownWidth NWRibbonResizeControl.MaxWidth Double DropDownWidth property not found on object of type NWTreeComboControl.
Error NWRibbonTreeCombo Orientation RibbonItemControl.Orientation, Name='mRibbonItemControl' Orientation Orientation property not found on object of type NWRibbonTreeCombo.
Error QuickAccessRedoButton Current ContentPresenter.NoTarget Object Current property not found on object of type QuickAccessRedoButton.
Error QuickAccessUndoButton Current ContentPresenter.NoTarget Object Current property not found on object of type QuickAccessUndoButton.
Error SeparatorData name TextBlock.Text String name property not found on object of type SeparatorData.
Error SeparatorData image Image.Source ImageSource image property not found on object of type SeparatorData.
Error SeparatorData alignment StackPanel.Tag Object alignment property not found on object of type SeparatorData.
These get thrown when I run my program from the built in Debug>Attach to Process thing in Visual Studio Community 2022
I have tried creating a .xml file, I have tried moving the .dll file out of the Plugins folder in Navisworks, I have tried placing the referenced .dll files into the Plugins folder in Navisworks with my .dll file.