I am creating a plugin in navisworks manage 2022. Can I call the “Datasmtih Export” plugin within my custom plugin?
Hi tak_Iam !
Here’s an example snippet of C# to export a Datasmith scene using your own plugin :
PluginRecord Record = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("DatasmithNavisworksExporter.EpicGames");
Plugin Plugin = Record.LoadPlugin();
string[] Params = { @"C:\temp\test.udatasmith", "Merge=3", "Origin=10, 20.0, 300"};
Plugin.GetType().InvokeMember("Execute", System.Reflection.BindingFlags.InvokeMethod, null, Plugin, Params);
Hope this helps !
Cheers,
Antoine
Hi Antoine,
Thank you for the replay. I can call the plugin now. Can I save the model automictically with this popup?
Regards,
Tak
is it possible save the model automictically?
If you want to automate the export, you will need to use the Autodesk.Navisworks.Api.Application.Automation.ExecuteAddInPlugin method of Navisworks.
Cheers,
Antoine
Hi Antoine,
I tried 2 case, but both are not ok.
case 1: without params
result: err message requires target path
case 2: with params
result: still have save popup box
Regards,
Tak
Hi Antoine,
Any suggestion?
Regards,
Tak
Hey tak_Iam,
I checked with our dev team, and exporting (with a path and no Explorer window) with our plugin from another plugin is actually not currently supported.
You can currently either export with the Explorer window using the snippet I sent you, or use Python and run Navisworks using the “automation” api to avoid the dialog.
We will be looking into adding that functionality in the plugin in the future.
Cheers,
Antoine
Hi Antoine,
Is there any example to call “Datasmtih Export” plugin with python?
Regards,
Tak
Hi tak_Iam,
This snippet of python should get you started :
import sys
import clr
# add location of navisworks assembly dlls
sys.path.append(r'C:\Program Files\Autodesk\Navisworks Manage 2022')
# Add Navisworks assemblies
clr.AddReference('Autodesk.Navisworks.Api')
clr.AddReference('Autodesk.Navisworks.Automation')
from Autodesk.Navisworks.Api import *
from Autodesk.Navisworks.Api.Automation import *
navisworks_app = NavisworksApplication() # Create an app instance
source_fpath = r'C:\Program Files\Autodesk\Navisworks Manage 2022\Samples\snowmobile.nwd'
navisworks_app.OpenFile(source_fpath, [])
print(f'Exporting {source_fpath}...', end='')
if 0 == navisworks_app.ExecuteAddInPlugin('DatasmithNavisworksExporter.EpicGames', [
r'C:\temp\test.udatasmith',
'Merge=8', # merge hierarchies up to depth 8
'Origin=10, 20.0, 300.0', # origin location
]):
print("DONE")
else:
print("FAILED")
navisworks_app.Dispose() # exit app
# Or keep open (say, need to review app console output for debugging)
# navisworks_app.StayOpen()
Cheers,
Antoine