In the past, it is impossible for an application of .NET control to communicate with a plugin. Now you can. The solution is very simple. It is just similar to what is mentioned in the other post:
Dynamic Loading of Plugin
In short, if you want to use any plugin, you can load it firstly and call the relevant method of the plugin. The following is repeating as the other post demos. It assumes a plugin has been deployed to <Navisworks Install Path>\Plugins\BasicPlugIn_LoadTest.ADSK\. Navisworks can load it when it is launching, while your .NET control application needs to load it explicitly.
This is the test demo source. Download Test_dynamic_load
using Autodesk.Navisworks.Api.Controls;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
privatevoid button1_Click(object sender, EventArgs e)
{
string plugin_name_to_load = "BasicPlugIn_LoadTest.ADSK";
PluginRecord dotest = null;
try
{
dotest = Autodesk.Navisworks.Api.Application.Plugins. FindPlugin(plugin_name_to_load);
if (dotest != null)
{
// the plugin has been loaded. exit.
MessageBox.Show("the plugin " +
plugin_name_to_load +
" has been loaded!");
return;
}
else
{
// load the plugin assembly
Autodesk.Navisworks.Api.Application.Plugins.AddPluginAssembly
(path of the dll);
// get the plugin record.
PluginRecord otherpluginrecord =
Autodesk.Navisworks.Api.Application.Plugins.
FindPlugin(plugin_name_to_load);
if (otherpluginrecord != null)
{
//loaded
if (!otherpluginrecord.IsLoaded)
{
//load the plugin
otherpluginrecord.LoadPlugin();
MessageBox.Show("the plugin " +
plugin_name_to_load +
has been loaded by AddPluginAssembly!");
//get the plugin of the record
Plugin otherplugin =
otherpluginrecord.LoadedPlugin;
//call one method of the plugin
//since we do not know the type of the other plugin,
//use InvokeMember
string[] pa = { "dummy" };
otherplugin.GetType().InvokeMember("Execute",
System.Reflection.BindingFlags.InvokeMethod,
null, otherplugin, pa);
}
}
else
{
// any other problems
MessageBox.Show(
"My app has tried to load the plugin " +
plugin_name_to_load +
" but it is still null. Please check the path name!");
}
}
}
catch (Exception ex)
{
// any exception
}
}