Exploring Dynamo-Navisworks interactions

Hi.
I’m exploring Navisworks API in order to automate some repetitive activities in Navisworks like selection sets creation, clash test creation and so on.

After installing NavisPythonShell (NPS), I’m writing some script to manage objects, getting properties value, execute search, etc. and I realize that it would be great if I could access to Navisworks objects (Document, Models, ModelItems) directly from Dynamo Studio.

My first step is to get the “Document object” in Dynamo as output of a python node.

Using NPS in Navisworks I simply have to write the following codeline:
doc = Application.ActiveDocument

Getting the same result in Dynamo is harder!
Here I post one of my tests.

As you can see, I managed to import correctly some Navisworks assemblies (Api, Api.Automation, Api.Controls) and to open an nwf file, but I can’t get the Document object yet (OUT is null!)

I’ve tried to use Dynaworks17 package, but it seems that the output of OpenNavisFile.OpenFile is not what I’m looking for. Maybe it use Navisworks.ComApi?

Having access to the Navisworks objects, allows to develop several custom node using Navisworks.Api, but I really need to get the Document object first.

Any idea to help me solving this task?

2 Likes

Hi @m.ravelli

Have you tried looking into NavisPythonShell?

Also look into the Dynaworks package.

Thanks for your answers.

I tried both option:

  • I developed some scripts to run with NavisPythonShell (using Navisworks.Api) and I managed to define several functions to perform actions like selecting Navisworks objects (Document, Models, ModelItems), searching, creating selection sets, creating clash detection test, and so on…
    But there’s a problem with this approach: not so many people can write Python scripts to resolve specific tasks. This is the reason why I’m trying to develop something more user-friendly in Dynamo Studio.

  • Using Dynaworks nodes, I realized that it’s a good tool to export and use data (properties, clash, …), but it isn’t able to automate processes in Navisworks.

So I need to get the “Navisworks Document object” in Dynamo Studio using Navisworks.Api (like Dynaworks node “OpenNavisFile.OpenFile” do with Navisworks.ComApi) in order to create some custom nodes that simply translate the functions I’ve already develped with NavisPythonShell.

I hope I was clear.

Has anyone figured out how to access a model running in a current open session of Navisworks using Python in Dynamo? Every post on here regarding Navisworks that is not about Dynaworks always seems be left open ended with no resolution…

Yes - we are all aware of Dynaworks. But I’m looking to use the Dynamo python editor and the Navisworks .Net Api. Specifically - i want to capture data from my Revit model - do some stuff to that data - then use the results to generate search sets in a Navisworks model. This should be easy - but as the post above illustrates - if you cannot get the active Navisworks document - then you can’t do much (and no - i don’t want to mess with the XML editing if i can avoid it).

1 Like

I’m going to have to ask around the office, but I believe that neither Dynamo Studio nor Dynamo Revit will want to work in this manor due to the inability to call the libraries required to open the respective APIs without launching from inside Navisworks or Revit - hence difficulty with pulling data from both active Revit and Navisworks files - pushing to an intermediate file format and running one or the other on automatic might be an alternative, but not necessarily a great one as I haven’t seen many great “live” ties to Navisworks at all. All this isn’t to say it can’t be done, but rather it will be difficult.

Can you elaborate on what exactly do you want to do in Revit, and then utilize that how in Navisworks? Will certainly help as I attempt to find out what I can about it. The more specific you can be the better.

Is accessing the libraries a problem with Revit and Navisworks specifically? I have been able to access multiple tools previously from Dynamo using Python (specifically Revit/SAP2000 and Revit/Tekla). Example done all with standard Dynamo nodes and Python scripting: https://www.dropbox.com/s/lptdmlnymtfsml8/Revit2Dynamo2Tekla.mp4?dl=0

Specifically - I am working on a large stadium project and will be doing a lot of work using timeliner. Right now, I would guess that I have around 2000 - 3000 unique search sets that I will be pairing up with timeliner tasks. The Revit Files are continually being edited, so I need a process that I can repeat time and again as things change. None of these search sets are created yet - but they all would basically be looking at the value of one particular parameter in Revit. My thought was to use Dynamo to look at Revit, get all the elements and find the value of that parameter, get the unique items from the really long list of values, then take that list of values into Python, connect into Navis, and loop thru that list creating all my Search Sets. The methods are there and seem pretty straightforward in the API documentation for creating Search Sets - the issue is simply getting Dynamo Python Editor to “see” the Active Document.

If you copy what the OP has in their script from the image in post 1 (substituting your own path to a Navis file), you can see that’s dynamo will fire up Navisworks and Open a File - but after that, it’s like all communication ceases.

Some observations - @m.ravelli is confusing the NavisworkApplication with the Application class. One opens a new Navis process, the other works with the Navisworks internals.

The Application class is designed using a singleton paradigm, so it can’t be instantiated and is only accessible from withing the Navisworks process itself. Reading the docs:

The Application class is a singleton, so has only static properties and cannot be instantiated directly. Used only within plug-ins this class provides the entry point to the Navisworks Application information.

This is one of the reasons why I looked into enabling NPS in the first place :slight_smile:

That’s not to say that you can’t communicate with a Navis process from an external app - Dynaworks is proof that this is definitely doable. However from what I can tell, it’s using the older COM interop api and not the .NET one. I haven’t looked into the COM documentation but it might be possible to do the kind of interactions you’re interested in.

As a side note, I’ve done similar tasks to what you outlined above by generating XMLs. Navisworks can exchange a ton of stuff through XMLs.

1 Like

Dimitar-
As a non-computer scientist - here’s my interpretation of what you said (please correct me if i’m wrong). “Singleton” means that essentially the only way to use the Navisworks .Net Api is thru a plugin launched from Dynamo - so no Dynamo, Grasshopper, other externally run program will be able to operate on Navisworks using that API. But if Dynamo were to be extended to Navisworks as a launched plugin in the same manner as it works in Revit, then there’s a pretty good chance that it would work (which would then beg the question - why is Dynamo not being extended as a plugin to other platforms that the user base is likely using…just look at the Autodesk Industry Collection and all the fun that could be had if Dynamo were a plugin to Navisworks, Recap, Autocad, etc…).

I have messed with editing Navis XMLs in the past for more manageable numbers of search sets. I have edited them but never generated directly from scratch which is what i’d like to do given the scale of this project. How are you able to generate the correct guids for each search set if you are creating the XML from scratch using Dynamo? If this is possible i’d gladly fork this conversation to a new post since it seems that the Navis/Dynamo discussion might be pointless until Dynamo is extended to Navisworks.

1 Like

My understanding is that singleton means the dlls contained within the .net api can only be run via navisworks - so launching Dynamo (or anything else) as if it were a navisworks add in is the only option here.

People have been working on ‘dynamo for ___’ with various levels of success. Advanced steel comes to mind as one such example. I’ll ask around and see what I can find on this type of endeavor for Navisworks, but no promises.

Instead of waiting an indeterminate amount of time for a Dynamo for Navisworks to be willed into existence, you (or another motivated individual) could utilize the Navisworks API and the open source nature of Dynamo to write ‘Dynamo for Navisworks’ as a Navisworks plug-in, but that type of project could prove to be rather time consuming.

As @Dimitar_Venkov mentioned, utilizing the com Navisworks api which Dynamo or any other program can access from outside Navisworks may be a better option, but your functionality will be limited to what’s in that api (less than the net one so no active document stuff), or you could utilize the in-between method of xml editing. Personally I think that the later seems more simple and worth exploring to achieve your end goal.

Yeah - writing the “Dynamo for Navisworks” plugin is way beyond my skill set. I’m motivated to do it, but a man’s got to know his limitations. It’s interesting to me that a niche market tool like Advanced Steel got the Dynamo add-in as opposed to something utilized more widely across the AEC world like Autocad or Navisworks. I guess my hope would be that Autodesk would handle the plugin and basic nodes part for all the primary platform products as they do with Revit and Advanced Steel and then let the community go wild on developing custom workflows and applications. If it were easy for anyone to do - then I imagine some of the more talented people in the community would have done so by now - something tells me that a Dynamo for Navisworks plugin is going to take Autodesk intervention.

I looked more into writing an XML from scratch this morning and discovered that the guids are not necessary for writing an XML (Navisworks assigns those upon import) so that process is actually really easy - I already wrote me up a script to take care of it this morning. I just find it a bit more cumbersome to update than i imagine a script operating directly on Navisworks would be.

1 Like

Don’t sell advanced steel short. Users do more with that then you would think. The lack of desire around an AutoCAD plug-in is likely due to the pivot to the ‘only one AutoCAD’ model which just occurred. My guess is that by making dynamo interact with the advanced aspects of advanced steel (drawing production from a single model and management of the database) makes for a good combo of value add for the users, user base which is familiar with Dynamo, and proof of concept for the other AutoCAD verticals. All speculation though.

Note that there are also examples of using Dynamo to drive base AutoCAD already out there (not always as a plug in either).

Navisworks by comparison is its own animal, so the tie there is more of a stand alone thing, so there is less to be gained by checking that box early. The long term goal is to have more of this interoperability in the platform.

I didn’t mean to sell Advanced Steel short - but it is a steel detailing software - so the market there is limited to mostly Steel Detailers (that don’t use Tekla or SDS/2).

Navisworks is used by Arch/Struct/MEP/GC/Subcontractors/Owners - the user base is much bigger for Navisworks, so the benefit and potential users of a Dynamo/Navisworks tool would have more overall impact in the AEC field than Dynamo/AdvancedSteel could. And I would venture a guess that at least 50% of the Navisworks users out there are also Revit users, and a whole bunch of those are Dynamo users too, so the learning curve would be small.

Just spoke with a couple of colleagues who will check to see what is underway (if anything).

@Ben_Osborne, feel free to message me directly and I can get into more specifics.

10-4. Thanks for listening to the squeaky wheel.

Squeaky wheels are the preferred kind! Otherwise everyone just thinks things are perfect and nothing improves!

You could probably port Dynamo to Navisworks, but you’d gain little by doing so. First of all, Navisworks exposes a lot less functionality through its api than Revit and secondly you’d have a new problem - how would you communicate between Navisworks’ Dynamo instance and Revit’s Dynamo instance? One won’t be able to see the internals of the other and you’d still need to create some exchange medium, either by using a file, or a db, or something like socket communication…

Writing XML files on the other hand is pretty straight forward. Luke Johnson has some nice examples on how to do that with Dynamo:

and

2 Likes

Is this a problem or a weakness with the Revit and Navisworks APIs? Robot Stuctural Analysis, Tekla, SAP2000 in my experience all seem to have no problem communicating with Revit’s Dynamo instance. Dynamo can act as a real-time bridge between Revit and them easily (I’ve even tested a small 4 way with Revit Dynamo Tekla Sap2000 before just for fun…). Big picture - I think it would be really cool if Dynamo could be a data bridge between all major products in the AEC industry collection. Enable the users - then see what useful workflows they come up with (like stealing Navisworks mesh geometry and Direct-Shaping that into Revit Families…)

3 Likes

Yes, my guess is that their dotNet APIs are specifically developed with interoperability in mind, unlike Revit and Navisworks.

Hi m.ravelli,

I tried installing the Navisworks Python shell by extracting the zip file to the APPDATA location, but when I run the Navisworks software I don’t see any buttons in the ribbon so I can’t start the python shell. I know it’s definitely loaded into Navisworks because when I tried to delete the folder when Navisworks is running, it won’t let me delete it. So my question is, how do I get the python shell buttons showing? Thanks a lot!

Rui