AnsweredAssumed Answered

Selection Filter Macro Problem

Question asked by Marshall Wilson on Sep 17, 2020
Latest reply on Sep 17, 2020 by Marshall Wilson

Because I do not like to have sketches referencing solid body vertices, I am trying to set up a macro that will activate the following selection filters: sketches, sketchpoints, sketch segments, midpoints, and dimensions.

 

I started with the macro found here in the API help, and I modified it somewhat by replacing the selfils() array with enumeration values here. Also, I removed the routine at the end where it is supposed to toggle the filter on and off because it did not work.

 

So now the macro (below) works OK - in that it sets the filters. But there's an issue. When I am doing a sketch, and set the filters I want manually, it allows me to select sketch points and segments, etc on other sketches higher up in the tree, which is what I need. However when I use the macro, it seems to set the filters, but they only seem to allow me to select sketch elements in the same sketch I am currently editing. When I manually clear them and go back and manually select the filters I want, I get the desired functionality.

 

Is there something I am doing wrong in the macro? Or is there something else I am unaware of?

 

Disclaimer: I have not worked on a Macro in a long long time!

 

Thanks!

M

 


Option Explicit

 

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim SelMgr As Object
Dim boolstatus As Boolean

 


Sub main()
Dim params As Variant
Dim selfils(5) As Long

 

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set SelMgr = swModel.SelectionManager

 

'Clear all existing selection filters

 

params = swApp.GetSelectionFilters
swApp.SetSelectionFilters params, False
params = swApp.GetSelectionFilters

 

'Define filters to select

 

selfils(0) = 9 'Sketches
selfils(1) = 11 'Sketchpoints
selfils(2) = 10 'Setchsegs
selfils(4) = 59 'Midpoints
selfils(5) = 14 'Dimensions
swApp.SetSelectionFilters (selfils), True

 

End Sub

Outcomes