Here is the code :
'in module
Private Sub startcmd()
Dim dd
Set cls = New Class2
End Sub
'in "Class2" class module
Private Sub fileUIEvts_OnPopulateFileMetadata(ByVal FileMetadataObjects As ObjectsEnumerator, ByVal Formulae As String, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
Dim oMetaData As FileMetadata
Dim str As String
str = ThisApplication.CommandManager.ActiveCommand 'Put here a breakpoint to watch Context
If FileMetadataObjects.Count > 0 Then
For Each oMetaData In FileMetadataObjects
oMetaData.FileName = "FG filename" & oMetaData.FileName
oMetaData.FullFileName = "FG fullfilename"
oMetaData.FileNameOverridden = True
Next oMetaData
HandlingCode = kEventHandled
End If
End Sub
1/ You use the command "Insert a profile" :
-in the FG dialog box, select the profile and place it
-when you "Apply" or "OK", you stop on the breakpoint, so you ca watch Context, wich contains Item 1 = "Frame Generator" and item 2 = "Frame".
-the event fire several times, you can know why by testing Item 2 : frame, skeleton or member, then for each set values for oMetadata.
2/ You use the command "Create a piping route" :
-the event fire, so you stop on the breakpoint. Problem : Context = 0 !! So, how can you know if you are on the Piping assembly, or on the piping route ?