Is there a way to trigger C# code right before a file is saved? I want to create or update custom property values automatically directly before a file is saved.
Is there a way to trigger C# code right before a file is saved? I want to create or update custom property values automatically directly before a file is saved.
Thanks Wayne.
This is great info!
I'd have to start listening for the event for every file correct?
I'd like this to be automatic and transparent to the user so they don't have to remember to run a macro. I wonder if an add-on could be created that would automatically register for the document load event every time a document is loaded?
Eric Snyder wrote:
Thanks Wayne.
This is great info!
I'd have to start listening for the event for every file correct?
I'd like this to be automatic and transparent to the user so they don't have to remember to run a macro. I wonder if an add-on could be created that would automatically register for the document load event every time a document is loaded?
Yep, that's pretty much what you'd do.
Yes you can. Here is example in API help file for monitoring assembly file display state pre and post changes
2018 SOLIDWORKS API Help - Fire Events When Display State Changes Example(C#)
For Assembly file delegates would be DAssemblyDocEvents_FileSaveAsNotify2EventHandler and DAssemblyDocEvents_FileSaveNotifyEventHandler for pre save. Then for post save you would use DAssemblyDocEvents_FileSavePostNotifyEventHandler and if user canceled the save, it would be DAssemblyDocEvents_FileSavePostCancelNotifyEventHandler
All the delegate events that can be monitored are listed at the bottom of this page in the API help file.
2018 SOLIDWORKS API Help - SolidWorks.Interop.sldworks Namespace