Reply

Simple question? (BeforeSave and OnConnection)

[ Edited ]

Hi everybody,

 

I have made my first C# program ever and it is Solid Edge Addin. :cheer:

 

The program actually works, but what I want to do is to use it frequently, but I have not managed to do that.

 

My program works in following way (i took an example from .NET Programmers Guide (provided by Siemens PLM and found by Google)):

 

1. Onconnection (works with first time) contains BeforeSave event call.

2. Opening assembly and saving it.

3. Program works and do what it is supposed to do.

4. Closing assembly.

5. Opening new assembly... Onconnection does not happen and therefore BeforeSave-event does not work.

 

So, what I do wrong? It is obvious (for me... I don't know is it obvious...) that I should not but the beforesave to the Onconnection. My program does not have GUI at all, so what I'm supposed to do?

 

This is the snippet of code, what is inside OnConnection-method:

m_document = (SolidEdgeFramework.SolidEdgeDocument)m_application.ActiveDocument;
            try
            {
                m_docevents = (SolidEdgeFramework.ISEDocumentEvents_Event)m_document.DocumentEvents;
                m_docevents.BeforeSave += new SolidEdgeFramework.ISEDocumentEvents_BeforeSaveEventHandler(m_docevents_BeforeSave);
            }

 

I have spent hours to find somekind of solution for this, but my knowledge about C# programming is in baby steps. So therefore I hope, that you guys are able to help my kind of newbie. Smiley Happy

 

Posted by: barbwire
Post date: 8/20/2012 3:37:31 AM

3 REPLIES

Re: Simple question? (BeforeSave and OnConnection)

[ Edited ]

Well,

 

I got this issue resolved by myself. :woohoo:

 

It seems, that document event was in wrong place after all and I had to use another event (application event) in the OnConnection()-method. When application event happened, it called my method where document event was initialized. It resolved my issue and everything works now.

 

Posted by: barbwire
Post date: 8/23/2012 3:42:16 AM

Re: Simple question? (BeforeSave and OnConnection)

Hi barbwire,

 

I know it's hard to get replies to anything but would you be able to post up the corrected code for your fix? I do not understand your correction explaination and it's easier to see the code...

 

I want to firgure this out so I can learn how to connet to the mouse events and get it to tell me the document X Y coordinates that are clicked...

 

Thanks for any replies

Re: Simple question? (BeforeSave and OnConnection)

See the Samples repostiory on GitHub for the MouseEvents sample.

Jason Newell
Applications Architect
www.jasonnewell.net