Reply
Solved! Go to solution

[Solved] Cannot cast to SolidEdge.Framework.Interop.Window

[ Edited ]

Hey everyone,

 

The following code throws a System.InvalidCastException, although I'm pretty sure I'm doing it the right way:

 

SolidEdge.Framework.Interop.Window win = null;
win = (SolidEdge.Framework.Interop.Window)Application.ActiveWindow;

 

whereas "Application" is a property of the type SolidEdge.Framework.Interop.Application.

 

I also tried to access the Window through:

 

SolidEdge.Draft.Interop.DraftDocument.Windows.Item(i), but the cast also fails there.

 

What am I missing?

 

3 REPLIES

Re: Cannot cast to SolidEdge.Framework.Interop.Window

Problem solved:

 

Since I was in the 2D environment, I had to cast to SolidEdge.Draft.Interop.SheetWindow. The normal Window only works for 3D appearantly.

Solution
Solution
Accepted by topic author freijon
‎08-26-2015 04:32 AM

Re: Cannot cast to SolidEdge.Framework.Interop.Window

This is where Spy for Solid Edge can save you a lot of time and headaches. It takes the guesswork out of what the runtime type is of an object by telling you directly in the UI.

 

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Cannot cast to SolidEdge.Framework.Interop.Window

[ Edited ]

Wow thanks, thats absolutely awesome! I could have needed that a lot during my last project. Without this tool, its a lot of guessing and trial and error. I finished my project now, but I will use it in the future for sure!