Cancel saving of document

Valued Contributor
Valued Contributor

 

Hello All,

I have one problem. I have to make some checks on event BeforeDocumentSave. If this checks fail then I need to Cancel or Abort saving process of Solid Edge document.

Dou you now anybody if it is possible? I am using C#, but it is not important I think.

Thank you for whatever response!

Petr

 

 

Posted by: Petr Bartoš
Post date: 9/12/2007 2:04:51 AM

3 REPLIES

RE: Cancel saving of document

Valued Contributor
Valued Contributor

Hi Petr and welcome to the forums.

 

Are you absolutely tied to using C#? Not that I have a problem with C#, actually I love it very much, but .NET addins in Solid Edge is a bit of an issue at the moment, as discussed previously here. I recommend using my VS.NET 2005 Addin templates which are available for download in the products section.

 

The ISEFileUIEvents interface makes what you're asking for possible. Specifically the OnFileSaveAsUI event. In C++, it looks something like this.

 

 

HRESULT CEventManager::XFileUIEvents::raw_OnFileSaveAsUI( BSTR *FileName, BSTR *AppendToTitle )

{

BOOL bOverride = FALSE;

 

if (bOverride == TRUE)

{

return S_OK;

}

else

{

return E_NOTIMPL;

}

}

 

 

You can also accomplish the same thing in .NET by using:

 

throw new System.NotImplementedException();

 

in place of return E_NOTIMPL;

 

If C++ is not an option for you, I do have a robust solution that mixes C++ & C#. I'd have to build the solution for you and send it to you because I do not have all of the templates for VS.NET 2005 worked out. If you're interested, just reply back with the name that you wish to use for your addin\.dll.

 

Posted by: Jason Newell
Post date: 9/12/2007 1:11:56 PM

RE: Cancel saving of document

Valued Contributor
Valued Contributor

 

Thank you,

You are right that this works, but unfortunately only for SaveAs with UI. What I need is cancel Save little deeper on ApplicationEvents_BeforeDocumentSave. But there is no Cancel option. Even if I “throw new System.Runtime.InteropServices.COMException(null, 1);” then operation of Save continues.

Do you have any experiences with this event? (ApplicationEvents_BeforeDocumentSave)

Petr

 

Posted by: Petr Bartoš
Post date: 9/12/2007 10:15:45 PM

RE: Cancel saving of document

Valued Contributor
Valued Contributor

 

I have found some solution (with help of this forum, but it works only in special case(when BeforeCommandRun event occurs)

Maybe it can help to someone...

void seAppEv_BeforeCommandRun(int theCommandID)

        {          

            if (theCommandID==57603)

            {             

                    KillCommand();                              

            }           

        }

        private void KillCommand()

        {

            SolidEdge.Framework.Interop.Command Command;

            Command = clsEvents.seApp.CreateCommand(1);

            Command.Start();           

            System.Runtime.InteropServices.Marshal.ReleaseComObject(Command);

            Command = null; 

        }

 

Posted by: Petr Bartoš
Post date: 9/13/2007 2:34:28 AM