I believe you get the actual Document object from that 'context' entry, when it is provided, not just the name of the document. Below is a short example code showing how that event handler can be used from an iLogic rule. It just gathers information about the event, then writes that to the iLogic Log window, on the 'Trace' level. For this to work, you must have your iLogic Log level set to Trace level, but not need the 'Detailed Trace' setting turned on. I made this example a 'one shot' routine, so that it will only react to the event one time, then remove itself, for safety.
But if you truly want to get the application's 'active' document (not just the Document involved with this event), then get its FullFileName, then you would need to have access to the Inventor.Application object...presumably through a variable that was declared at a higher level within your overall code structure.
When this event fires, if the document being saved has not been saved before (initial save), then it might not report its 'FileName'. Similarly, if you get the Document object from the Contextual 'TopLevelDocument' entry, and it had not been saved before, its FullFileName will be empty.
Sub Main
If oFileUIEvents Is Nothing Then oFileUIEvents = ThisApplication.FileUIEvents
'use next line to start event handling, if you want to be ablt to remove it later
AddHandler oFileUIEvents.OnFileSaveAsDialog, AddressOf FileUIEvents_OnFileSaveAsDialog
End Sub
'use WithEvents & Handles if you do not need to 'remove' the event handler later
'Dim WithEvents oFileUIEvents As Inventor.FileUIEvents
Dim oFileUIEvents As Inventor.FileUIEvents
Sub FileUIEvents_OnFileSaveAsDialog(ByRef FileTypes() As String, _
SaveCopyAs As Boolean, ParentHWND As Long, ByRef FileName As String, _
Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum) 'Handles oFileUIEvents.OnFileSaveAsDialog
Dim oReport As New System.Text.StringBuilder()
oReport.AppendLine("FileUIEvents.OnFileSaveAsDialog Event Fired")
Dim sFileTypes As String = String.Concat(FileTypes)
oReport.AppendLine("FileTypes = " & sFileTypes)
oReport.AppendLine("SaveCopyAs = " & SaveCopyAs.ToString)
oReport.AppendLine("ParentHWND = " & ParentHWND.ToString)
oReport.AppendLine("FileName = " & FileName)
'check 'Top Level Document'
Dim bTopLevelDocEntryFound As Boolean = False
Dim oTopLevelDoc As Inventor.Document = Nothing
If Context IsNot Nothing AndAlso Context.Count > 0 Then
For i As Integer = 1 To Context.Count
Dim sName As String = Context.Name(i)
If sName = "TopLevelDocument" Then
bTopLevelDocEntryFound = True
oTopLevelDoc = Context.Value(sName)
End If
Next
End If
Dim sTopLevelDocFFN As String
If bTopLevelDocEntryFound Then
oReport.AppendLine("Context: 'TopLevelDocument' entry was present")
If oTopLevelDoc Is Nothing Then
oReport.AppendLine("Context: 'TopLevelDocument' = Nothing (no value)")
Else
oReport.AppendLine("Context: 'TopLevelDocument' TypeName = " & TypeName(oTopLevelDoc))
sTopLevelDocFFN = oTopLevelDoc.FullFileName
If sTopLevelDocFFN = "" Then
oReport.AppendLine("Context: 'TopLevelDocument' FullFileName = 'empty'(unsaved)")
Else
oReport.AppendLine("Context: 'TopLevelDocument' FullFileName = " & sTopLevelDocFFN)
End If
End If
Else
oReport.AppendLine("Context: 'TopLevelDocument' entry was not present")
End If
oReport.AppendLine("HandlingCode = " & HandlingCode.ToString)
Logger.Trace(vbCrLf & oReport.ToString)
'if using 'AddHandler', then uncomment next line to make this a 'one shot' routine
'a one shot routine is one that only reacts to an event one time
RemoveHandler oFileUIEvents.OnFileSaveAsDialog, AddressOf FileUIEvents_OnFileSaveAsDialog
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)