Pass filename to Presentation "Insert Model" command in Inventor 2022 or newer

Pass filename to Presentation "Insert Model" command in Inventor 2022 or newer

MartinKunz
Contributor Contributor
132 Views
0 Replies
Message 1 of 1

Pass filename to Presentation "Insert Model" command in Inventor 2022 or newer

MartinKunz
Contributor
Contributor

Hello,

 

I'm looking for a way to pass the filename to the "Insert Model" command in Presetation Environment so Inventor does not display the file selection dialog but rather uses the file I provided and inserts the Assembly as the first scene right away.

 

I found an older solution for the problem that works in older Inventor Versions (up to 2021) but doesn't work in 2022 and newer ( https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/api-insert-the-assembly-into-present... )

 

The sample from the original post creates a new Presentation file after setting the filename in the internal clipboard via PostPrivateEvent, but it also works fine if the presentation file is already open and we Execute the "Insert Model" command.

 

VBA source code from the link above, but changed to Execute the Insert Model command:

Sub InsertToPrestention()

Dim oCM As CommandManager
Set oCM = ThisApplication.CommandManager
oCM.ClearPrivateEvents

Dim sFile As String
sFile = "C:\Temp\Block.iam"

oCM.PostPrivateEvent kFileNameEvent, sFile

oCM.ControlDefinitions("PublisherInsertModelCmd").Execute
End Sub

 

This works fine in Inventor 2020 and 2021 (presumably also older versions) if the Presentation document does not yet have a scene (if it already has one, the Insert Model button is also greyed out in the UI - so no surprise that the macro won't work in that situation)

 

However, the same macro doesn't work in 2022 or 2023. Inventor apparently ignores the filename in the clipboard and shows the file selection dialog.

 

Is there a way to pass a filename in the newer Inventor Versions?

Maybe we just have to modify the passed file name in some way?

 

0 Likes
133 Views
0 Replies
Replies (0)