How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Valued Contributor
Valued Contributor

Hi,

 

I would like to automatically check and copy some properties and references in the 'BeforeSaveAs' or 'OnSaveAs' Event.

 

So i want to catch when the user hits SaveAs or replaces a model with a copy of that model. I want to check and copy the corresponding draft with it if possible.

 

Is there some way to do this?

 

Thanks in advance!

 

 

Edit:

1 step closer (I hope)

 

I've installed the "Solid Edge Add-In No UI"

 

I created a new project (MyAfterSaveAsEvent), and it shows all (or at least some) events of solid Edge. I've added some code to the "BeforeDocumentSave" and  "AfterDocumentSave" which at the moment just tells the user a copy was made (See attachment).

 

My question: What do I do now? Can't build it, because it can't register. I don't know how and if I should register this one.

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9
5 REPLIES

Re: How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Wow, just wrote a long reply and lost it after posting it...

 

What I was saying is that I'll be able to reply more in depth later tonight. There is more than one way to write a Solid Edge addin but my recommended approach is detailed in my Solid Edge Community Templates Quick Start video. Also, you'll want to download the Solid Edge Community Samples on GitHub. Click the Download ZIP button on the page to get everything. Once downloaded and extracted, navigate to the AddIn/DemoAddIn[cs|vb] folder and a more complete example.

 

Everything I just mentioned is just a starting point for creating yourself a new addin. I'll try to answer your specific questions later tonight.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Valued Contributor
Valued Contributor

Hi Jason,

 

I have got the 'Community Samples' and I watched the Quick Start Video, but the registration doesn't work. 

 

"The term 'Register-SolidEdgeAddIn' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again. "

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9

Re: How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Sometimes you have to restart Visual Studio after using the template. I haven't seen it in awhile but I have seen what you're talking about in the past. A restart always fixed it.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Valued Contributor
Valued Contributor

Hello Jason,

 

When creating a new project, a message pops up (see attachment)

Also, I'm on a work-computer, where I i don't have all the administrative rights. Might this be part of the problem?

 

 

 

___________________________
The truth is .... I am Dutch
VB.NET - C# - VS Ex 2015 - ST9

Re: How can i run my code on 'OnSaveAs' or 'ReplaceByCopy' Event

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Possibly. I'd have to setup a test environment to be sure. Even if we get past that though, the Register-SolidEdgeAddIn commandlet executes RegAsm.exe who does require administrative privileges because it must register the .dll as a COM component under the HKEY_CLASSES_ROOT\CLSID\{GUID} key. A basic requirement of COM development is administrator privileges on the development machine. If you are unable to get that access on your machine, I'm not sure what your options are at that point.

Jason Newell
Applications Architect
www.jasonnewell.net