I have used this method with the Save or Open FileDialog codes before, and it works, but I had not tried using it in this situation yet, when I posted, but it sounded like it might work too.
Unfortunately, when I tried it that way with the following code it didn't work, for some reason.
Dim oPath As String = ThisDoc.Path
Dim oOldName As String = ThisDoc.FileName(False)
Dim oPrefix As String = "01-"
Dim oNewFullName As String = oPath & "\" & oPrefix & oOldName & ".ipt"
'This writes this string onto the Clipboard (understood as a filename).
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oNewFullName)
ThisApplication.CommandManager.ControlDefinitions.Item("iLogic.PlaceComponent").Execute
I think it may have something to do with loss of system 'focus', but I'm not sure.
However, there may be another route to do this, without using executing this command.
You're familiar with using the following code right?:
Component.Visible("ComponentName") = False 'or True
'and
Component.Replace()
Well, how this newer function?
Components.Add()
ThisRule.Components (this is a IManagedComponents object, and you don't need to put ThisRule in front of it.)
It provides the Add, AddiPart, AddContentCenterPart, Delete and other functions in iLogic Assemblies.
I generally don't use the "Place iLogic Component" tool, due to how our filing system is set-up, so I haven't messed with it very much. In Inventor 2021, within the iLogic rule editor dialog > Snippets > System tab > iLogic Assemblies/Components > there are 12 snippets, one of which is called "Add Component". Below is the code within:
Dim componentA = Components.Add("a:1", "a.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)
Wesley Crihfield

(Not an Autodesk Employee)