Inventor FileUIEvent.OnFileSaveAsDialog overwrite default dialog not working

Inventor FileUIEvent.OnFileSaveAsDialog overwrite default dialog not working

ChristianAhlers
Contributor Contributor
286 Views
2 Replies
Message 1 of 3

Inventor FileUIEvent.OnFileSaveAsDialog overwrite default dialog not working

ChristianAhlers
Contributor
Contributor

Hello,

I am trying to overwrite the default save dialog and replace it with my own. I have already done this in previous versions of Inventor and it worked without any problems.
But now, in version 2025, I have no success.

The event is registered in the Activate function of my plugin and does not throw an error. However, when I then save and my own dialog should appear, only the standard Inventor dialog appears.

Can anyone recognize an error or has a similar problem?

 

Here is my short code:

 

 public void Activate ( Inventor.ApplicationAddInSite addInSiteObject, bool firstTime )
 {
     // This method is called by Inventor when it loads the addin.
     // The AddInSiteObject provides access to the Inventor Application object.
     // The FirstTime flag indicates if the addin is loaded for the first time.

     // Initialize AddIn members.
     m_inventorApplication = addInSiteObject.Application;          

     FileUIEvents fileUIEvents = m_inventorApplication.FileUIEvents;
     fileUIEvents.OnFileSaveAsDialog += FileUIEvents_OnFileSaveAsDialog;

     // TODO: Add ApplicationAddInServer.Activate implementation.
     // e.g. event initialization, command creation etc.
 }



 private void FileUIEvents_OnFileSaveAsDialog ( ref string[ ] FileTypes, bool SaveCopyAs, int ParentHWND, out string FileName, NameValueMap Context, out HandlingCodeEnum HandlingCode )
 {
     SaveDialog saveDialog = new SaveDialog( );

     bool result = ( bool ) saveDialog.ShowDialog( );

     if ( result )
     {
         HandlingCode = HandlingCodeEnum.kEventCanceled;
         FileName = null;
     }
     else
     {
         HandlingCode = HandlingCodeEnum.kEventCanceled;
         FileName = null;
     }

 }



0 Likes
287 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @ChristianAhlers.  I am not familiar with writing code in C#.net, but I can follow your code OK, due to how similar it is to vb.net.  I just checked on the Form.ShowDialog official documentation website (link below), and it says that this applies to .NET Framework 4.8.1 and other versions.  It does not mention regular .NET, so I can only assume that it will no longer work with the newer system being used in Inventor 2025, since they stepped forward to using regular .NET.

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.showdialog 

Same for the DialogResult Enum..., because it is .NET Framework 4.8.1 (and earlier), and Windows Desktop 9 and earlier.

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.dialogresult 

I will be interested in seeing the next best alternatives myself, because I still use that method in several of the solutions where I work.

Edit:  The System.Windows.Forms.Form object is the same way.  I am not sure if the whole System.Windows.Froms Namespace is only supported in those code systems listed above or not.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

ChristianAhlers
Contributor
Contributor

Hi Wesley,

 

I hope the Inventor team give us an alternative if the function will not longer work in .net.

Thank you for your listings.

0 Likes