So I've done some searching and I'm an intermediate programmer at best. I can't figure out how to change my Macro to an Addin and have it register and startup with Solidworks. Can anyone help me convert this Macro to an Addin?
That's a bigger question than it might sound. Add-ins need to be compiled as dlls so you'll need something like Visual Studio first. That means you'll likely need to upgrade the language to VB.NET (or C#). There are free Express versions of Visual Studio if you're new to building add-ins. Then us the add-in template provided in the API SDK. Instructions are available here...
It looks like you have already added in hooks for notification/event handling. You may have already done this, but you can set up a shortcut to SolidWorks that runs your macro on startup so you get the event handling during the entire session. Create a new Windows shortcut to SLDWORKS.EXE and include /m "path to your macro" in the Target.
Thanks for the response. I actually used the shortcut target as menitoned above to test the macro to ensure it works. So as is I know it works it's just a matter of changing it to Vb.net or C#. I will download the example and see if I can figure it out from there.
The question I have is, if I don't need a UI portion, do I still put the macro methods under the UI methods section in SWaddinn.vb or do I break everything down into the respective sections (Event Handling, etc)?
The organization of the code is up to you. It might be convenient to keep them organized in the sections already built in the add-in template. But it isn't a requirement. The only exception are classes that "Implement" specific classes like PropertyManagerPage2Handler2 and swAddIn. These have some required procedures and your code will give you errors/warnings if you move these to another class or module. To simplify, don't move any code procedure that has the word "Implements" in the definition.
I was able to get the first part working which is an event handler that happens on FileOpenNotify from the Application object. The problem I"m having now is the FileSaveNotify that I've assigned for a DrawingDoc object does not seem to be executing. I attached the event handler the same way as the other one and everything. Both iSwApp and swDoc are declared WithEvents at the beginning of the program. Any thoughts?
AddHandler iSwApp.FileOpenNotify, AddressOf Me.iSwApp_FileOpenNotify
AddHandler swDoc.FileSaveAsNotify2, AddressOf Me.swDoc_FileSaveAsNotify2
Catch e As Exception
******Funciton that works***********
Private Function iSwApp_FileOpenNotify(ByVal FileName As String) As Long
'If statement to check to see if the document being opened is a drawing If FileName.Contains("SLDDRW") Then Call copyProps() Else Exit Function End If
****Function that isn't being called*************
Private Function swDoc_FileSaveAsNotify2(ByVal FileName As String) As Integer
'If statement to check to see if the document being saved is a drawing If FileName.Contains("SLDDRW") Then Call copyProps() Else Exit Function End If
Retrieving data ...