Files
Simplified macro feature skeleton
Code
Modules: Macro_feature
'Simplified macro feature skeleton
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vMacroMethods As Variant
Dim swFeat As SldWorks.Feature
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'MACRO METHODS
Dim MacroMethods(8) As String
'Regen function
MacroMethods(0) = swApp.GetCurrentMacroPathName 'the path of the macro where the macro feature functions reside
MacroMethods(1) = "Feature_Module" 'the name of the module in the macro where the regen function resides
MacroMethods(2) = "swmRebuild" 'the name of the regen function
'Edit definition function
MacroMethods(3) = swApp.GetCurrentMacroPathName 'the path of the macro where the macro feature functions reside
MacroMethods(4) = "Feature_Module" 'the name of the module in the macro where the edit definition function resides
MacroMethods(5) = "swmEditDefinition" 'the name of the edit definition function
'Security function (optional)
MacroMethods(6) = swApp.GetCurrentMacroPathName 'the path of the macro where the macro feature functions reside
MacroMethods(7) = "Feature_Module" 'the name of the module in the macro where the security function resides
MacroMethods(8) = "swmSecurity" 'the name of the security function
vMacroMethods = MacroMethods
'Create the macro feature
Set swFeat = swModel.FeatureManager.InsertMacroFeature3("MacroFeature", Empty, vMacroMethods, _
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, 0)
End Sub
Modules: Feature_Module
Function swmRebuild(app As Variant, model As Variant, feat As Variant) As Variant
Debug.Print "Rebuild"
End Function
Function swmEditDefinition(app As Variant, model As Variant, feat As Variant) As Variant
Debug.Print "Edit"
End Function
Function swmSecurity(app As Variant, model As Variant, feat As Variant) As Variant
swmSecurity = SwConst.swMacroFeatureSecurityOptions_e.swMacroFeatureSecurityByDefault
End Function