FileInteractiveResolving Event and getting Name of Unresolved files

FileInteractiveResolving Event and getting Name of Unresolved files

albarney99
Advocate Advocate
565 Views
1 Reply
Message 1 of 2

FileInteractiveResolving Event and getting Name of Unresolved files

albarney99
Advocate
Advocate

Using the Labs I have got the Event Handler working and I can capture the FileInteractiveResolving event so am getting a Message Box when I want to see it.

 

I however don't know how to actually get the file name/names of the Unresolved files that are about to appear in the dialog box.

 

If I use the Active document it is still associated with the current document I started in as it hasn't actually got to the point of opening the new file.

 

How do I get the unresolved paths of the file I am opening?

 

We are trying to automate the NW creation and I want to put any Unresolved files in a Log file so we can keep an eye if files are dropping out of the model.

 

Below works ok except the Model Collection is from the file already open, not the file you are in the process of opening.

 

     Public Overrides Sub OnLoaded()
            AddHandler Autodesk.Navisworks.Api.Application.FileInteractiveResolving, AddressOf XXXX_NW_Event_FileInteractiveResolving_Handler
     End Sub
     Public Overrides Sub OnUnloading()
            RemoveHandler Autodesk.Navisworks.Api.Application.FileInteractiveResolving, AddressOf XXXX_NW_Event_FileInteractiveResolving_Handler
     End Sub
     Public Sub XXXX_NW_Event_FileInteractiveResolving_Handler(ByVal sender As Object, ByVal e As System.EventArgs)
           MessageBox.Show("Start XXXX_NW_Event_FileInteractiveResolving_Handler")
            Dim my_nw_actdoc As Autodesk.Navisworks.Api.Document = Autodesk.Navisworks.Api.Application.ActiveDocument
            Dim my_model_col As Autodesk.Navisworks.Api.ModelItemEnumerableCollection = my_nw_actdoc.Models.RootItems
            For Each my_model As Autodesk.Navisworks.Api.ModelItem In my_model_col
                MessageBox.Show("my_model.DisplayName : " & vbCrLf & my_model.DisplayName & vbCrLf & "my_model.Model.FileName : " & vbCrLf & my_model.Model.FileName & vbCrLf & "my_model.Model.SourceFileName : " & vbCrLf & my_model.Model.SourceFileName)
            Next
MessageBox.Show("End XXXX_NW_Event_FileInteractiveResolving_Handler") End Sub

 

 

0 Likes
566 Views
1 Reply
Reply (1)
Message 2 of 2

alexisDVJML
Collaborator
Collaborator

 

// sender=null, e.FileReference etc filled, called once per referenced aka included documents, depth first? include actual root document
//  comment: called repeatedly at launch with avatar files, twice for each document !
Application.FileResolving += (object sender, FileResolvingEventArgs e) =>
{ Debug.Print($"FileResolving '{e.FileReference}'"); };
Application.FileResolved += (object sender, FileResolvedEventArgs e) =>
{ Debug.Print($"FileResolved '{e.FileReference}'"); }; // sender=null, e.FileReference etc filled, called once per referenced aka included documents, depth first? include actual root document

See above for the events for FileResolving/Resolved.
For these events, you can use e.FileReference to get which file for each of the 2 events, maybe you could check for call to Resolving without call to Resolved.

 

For FileInteractiveResolving event you are using, you get even more info in the FileInteractiveResolvingEventArgs so probably can directly use these ifo to do what you want, but I have not used this event yet.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes