Hi,
I've got a problem with the event sink of the FileOpenDialog in C#. I want to disable the default Inventor file dialog. If I leave my delegate function with the HandlingCodeEnum.kEventCanceled setting, the default Inventor dialog box appears anyway.
The event sink written in VBA woks fine!
What I've done wrong?
Here is my code:
this.fileUIEvents = app.FileUIEvents;
// Open
this.fileUIEvents.OnFileOpenDialog += new FileUIEventsSink_OnFileOpenDialogEventHandler(fileUIEvents_OnFileOpenDialog);
private void fileUIEvents_OnFileOpenDialog(ref string[] fileTypes, int parentHWND, out string fileName,
NameValueMap context, out HandlingCodeEnum handlingCode)
{
fileName = "C:\\MindaModels\\Stange200x30.ipt";
handlingCode = HandlingCodeEnum.kEventCanceled;
}
Can you help me?
Thanks.
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Just want to check is it working there if you set the HandlingCode=kEventHandled?
Hello Mr. Zhang,
thank you for your reply. The handling code kEventHandled also doesn't work.
I'm wondering, it works very well in VisualBasic but it doesn't work in C#. I can't change the signature of the fileUIEvents_OnFileOpenDialog method because of compiler erros. I think the filename and/or the handling code are not excactly transmitted to the internel Inventor event function for opening a file.
My inventor version is: Autodesk Inventor 2012 64-bit-Edition Build: 160, Release: 2012 RTM
Can you debug the project and see if the event can be fired successfully? And also you can refer to a C# sample in Inventor SDK to see how the event works:
\SDK\DeveloperTools\Samples\VCSharp.NET\AddIns\SimpleAddIn
You can install the DeveloperTools.msi in below folder:
Windows XP: <Inventor install folder>\SDK
Windows Vista: C:\Users\Public\Documents\Autodesk\Inventor <version>\SDK
Windows 7: C:\Users\Public\Documents\Autodesk\Inventor <version>\SDK
Thank you for your reply.
Unfortunately in the samples there are no examples with FileUIEvents.
I can debug the code and the file open event was triggered successfully. My handling code works also successfully and opens from outside the Document (part, assembly), but then the file open dialog box additionaly appers. The user should not be able to open a document form the file system. Inventor does not respond to my handling code. I don't know what I can do.
Hello joerituijn,
unfortunately this issue is still noct resolved. I think it is a bug. Do you know where I can report this bug?
Thanks
I don't know where you'd report this. However, this forum is moderated by Autodesk, I assume they're aware of the issue.
Can you attach a sample project to reproduce this issue?
I created a test environment from scratch. Sure enough, no problems there! Now I'm going through my own project again to see what I can find. Must be something simple I overlook....
Ok, a little workaround.
You should use the .Net3.5 Framework. That works!
The "bug" still appears with the .Net4.0 Framework.
(I've created a sample with the "InventorNetAddinWizard" and this sample works. This wizard creates a .Net3.5 class library.)
Thanks
That is strange, I have tested this with a .NET 4.0 framework and it works just fine (in my newly created project). In my case, the .NET framework change to 3.5 doesn't make a difference.
If you changed the .Net Framework 3.5 to 4 in your Inventor 2012 addin project in VS2010, can you try below to see if it solves the problem:
1. Open the Properties window for the Autodesk.Inventor.Interop reference.
2. Find the property "Embed Interop Types", and change its value to False(it defaults to True).
3. Test the project to see if the event works now.
How about that?! It works! Awesome! A bit sad that I spend nearly a day solving it.... But still, glad it works!