Navisworks accessing ActiveDocument from Automation API

Navisworks accessing ActiveDocument from Automation API

Anonymous
Not applicable
3,012 Views
6 Replies
Message 1 of 7

Navisworks accessing ActiveDocument from Automation API

Anonymous
Not applicable

It seems that the only way to get access to the power of the Autodesk.Navisworks.Api from Autodesk.Navisworks.Api.Automation is by calling a plugin. This requires the plugin to be created, compiled and deployed through a separate VS project. Is there another way? I would like to be able to do something like this:

 

NavisworksApplication automationApplication = new Autodesk.Navisworks.Api.Automation.NavisworksApplication();
automationApplication.OpenFile("c:\\myModel.nwd");
Autodesk.Navisworks.Api.Application.ActiveDocument.SaveFile("c:\\myMode_2010l.nwd", DocumentFileVersion.Navisworks2010);

 The above code fails because the ActiveDocument is not set.

 

Thanks

0 Likes
3,013 Views
6 Replies
Replies (6)
Message 2 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

This is as designed. 

 

The Automation part of the .NET API is a small assembly that can be referenced by developer applications. It contains enough to start Navisworks and perform some basic actions; however complex actions should be achieved using a plug-in which can still be called through Automation. 

 

About your code above, why you did not use automationApplication.SaveFile directly? Currently, Navisworks is still single doucument. So after opening the file by automationApplication.OpenFile, it is the active document.

0 Likes
Message 3 of 7

Anonymous
Not applicable

I need to save as an older version of Navisowrks. The Automation API SaveFile method does not allow me to specify a Navisworks Document Version.

 

In any case, that was just a simple example. There is more complex functionality (like property based coloring) that I want to implement. I wanted to do it without having to create a separate plugin, but it seems it is not possible. This imposes a severe limitation on the design of my application. If only I could get an instance of the ActiveDocument from the Automation API, that would solve the problem. Do  you know if Autodesk has any plans of doing something like this?

0 Likes
Message 4 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi jbiaggini ,

 

Sorry I do not see a plan. Before logging a wish, I'd like to collect more requirement that is could be done by automation only. Basically, automation is to manipulate in application / document level such as you want to save to a lower version. I cannot guarantee this would be implemented, but  please feel free to raise more what you think are fine to be exposed in automation.

0 Likes
Message 5 of 7

Anonymous
Not applicable

After loading a document using the Automation API, I would like to be able to get an instance of the Autodesk.Navisworks.Api.ActiveDocument from the Automation API without having to call a plugin.

0 Likes
Message 6 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Thank you jbiaggini. I logged a wish to access ActiveDocument by automation, at least to expose the method SaveAs with file version.

0 Likes
Message 7 of 7

Anonymous
Not applicable

Can it be accessed through NavisWorks 2019 at this moment? 

0 Likes