Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OnFileOpenDialog - HandlingCodeEnum.kEventCanceled does not work

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
ralf.lemke
894 Views, 15 Replies

OnFileOpenDialog - HandlingCodeEnum.kEventCanceled does not work

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.

15 REPLIES 15
Message 2 of 16
ralf.lemke
in reply to: ralf.lemke

Nobody has an idea?

Message 3 of 16
YuhanZhang
in reply to: ralf.lemke

Just want to check is it working  there if you set the HandlingCode=kEventHandled?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 4 of 16
ralf.lemke
in reply to: ralf.lemke

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

Message 5 of 16
YuhanZhang
in reply to: ralf.lemke

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



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 6 of 16
ralf.lemke
in reply to: ralf.lemke

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.

Message 7 of 16
joerituijn
in reply to: ralf.lemke

I have the same issue, did you ever resolve this problem?

Message 8 of 16
ralf.lemke
in reply to: ralf.lemke

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

Message 9 of 16
joerituijn
in reply to: ralf.lemke

I don't know where you'd report this. However, this forum is moderated by Autodesk, I assume they're aware of the issue. 

Message 10 of 16
YuhanZhang
in reply to: ralf.lemke

Can you attach a sample project to reproduce this issue?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 11 of 16
joerituijn
in reply to: YuhanZhang

I created a test environment from scratch. Sure enough, no problems there! Smiley Surprised Now I'm going through my own project again to see what I can find. Must be something simple I overlook....

Message 12 of 16
ralf.lemke
in reply to: joerituijn

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

Message 13 of 16
joerituijn
in reply to: ralf.lemke

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.

 

 

Message 14 of 16
YuhanZhang
in reply to: ralf.lemke

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.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 15 of 16
joerituijn
in reply to: YuhanZhang

How about that?! It works! Awesome! A bit sad that I spend nearly a day solving it.... But still, glad it works!

Message 16 of 16
ralf.lemke
in reply to: joerituijn

Hello Mr. Zhang,

 

it works for .NET 4.0!

 

Thank you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report