Is it possible call "Datasmtih Export" plugin in navisworks's custom plugin?

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,

1 Like

Hi ,

Thank you for the replay. I can call the plugin now. Can I save the model automictically with this popup?

Regards,

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.

See https://apidocs.co/apps/navisworks/2018/T_Autodesk_Navisworks_Api_ApplicationParts_ApplicationAutomation.htm

Cheers,

Hi ,

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,

Hi ,

Any suggestion?

Regards,

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. :slight_smile:

Cheers,

Hi ,

Is there any example to call “Datasmtih Export” plugin with python?

Regards,

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,

Is there any updates on this plugin? Tho python does work, it is still needed to manually trigger a python script (the python terminal is externally installed as a plugin too). Is it still impossible to avoid the save file dialogue? It will be very helpful if it works. Many thanks.

Hi Antonie, is there any update regarding avoiding the save dialog popup in C#?