Reply
Solved! Go to solution

Open existing asm in C#, error.

Hi, I have this code intended to open an existing solid edge assembly from a running instance of solid edge. But it does not open it at all and it gives me no error message. Please Help.

 

publicvoid openDocument(string fileName, string [] args)

{

SolidEdgeFramework.Application application = null;

SolidEdgeFramework.Documents documents = null;

 

try

{

OleMessageFilter.Register();

// Connect to running Solid Edge Instance

application = (SolidEdgeFramework.Application)

Marshal.GetActiveObject("SolidEdge.Application");

documents = application.Documents;

documents.Open(fileName);

}

catch (System.Exception ex)

{

System.Windows.Forms.MessageBox.Show(string.Concat("Error Opening Solid Edge File ", ex.ToString()));

Console.WriteLine(ex.Message);

}

finally

{

OleMessageFilter.Revoke();

}

 

}

 

5 REPLIES
Solution
Solution
Accepted by topic author SergioH
‎08-26-2015 04:32 AM

Re: Open existing asm in C#, error.

My first guess is that you have multiple Edge.exe's open and don't realize it. If you look in task manager, check to see how many there are. I've fallen into this trap myself and feel silly after I realize what's happening. Let's start with that and go from there.

Jason Newell
Applications Architect
www.jasonnewell.net
Solution
Solution
Accepted by topic author SergioH
‎08-26-2015 04:32 AM

Re: Open existing asm in C#, error.

Thanks Jason. That was my problem hidden edge.exe running, I fell silly now too.

Regards
Sergio Vallejo

Re: Open existing asm in C#, error.


But it does not open it at all and it gives me no error message

This is a solved question, but the above remark got me curious. So I went ahead and created a hidden Edge.exe using CreateObject.

Then run the code in question followed by making Edge.exe visible using Visible = True

I found the code had actually opened the file and found this to be useful in batch processing where SE can be kept invisible and files opened and processed.

 

A doubt though - will keeping SE invisible still let me process the files in batch mode ?

Are there any known APIs or commands which won't work when SE is hidden.

Thanks.

~Tushar

 

Re: Open existing asm in C#, error.

Tushar,

 

I recall past discussions about certain APIs not working as expected when Application.Visible = False but I don't remember the specifics. My suggestion is to just try it both ways and see if you get the expected results.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Open existing asm in C#, error.

If i'm not wrong, Save as PDF needs that Application is visible to work.

Apart from that i don't remember other issues with application not visible.

 

Regards,

Julian Guillo
Pixel Sistemas SL
Spain