I'm working on a project, where I need to suppress only specific holes in a linear pattern. For example, I have 20 holes in a row, and I need to suppress holes 12, 13, and 14. There is a feature in Solidworks, where you can suppress referenced copies in a linear pattern, but I haven't found out yet how to select it using API. Maybe you can help me.
Here is the code I have so far for suppressing the whole feature, it might help:
Dim swApp As Object
Dim Part As Object
Dim Feature As SldWorks.Feature
Dim featureName As String
Dim action As String
Dim searchStr As String
Sub main()
Set swApp = Application.SldWorks
searchStr = "Lineares Muster1"
action = "Unsuppress"
swApp.ActivateDoc "LProfilL"
Set Part = swApp.ActiveDoc
Set PartDocExt = Part.Extension
Set Feature = Part.FirstFeature
Do While Not Feature Is Nothing
Let featureName = Feature.Name
If InStr(1, featureName, searchStr, 1) Then
status = PartDocExt.SelectByID2(featureName, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
If (action = "Suppress") Then
status = Part.EditSuppress2()
ElseIf (action = "Unsuppress") Then
status = Part.EditUnsuppress2()
End If
End If
Set Feature = Feature.GetNextFeature()
Loop
End Sub
Ok after some more research i found out about "SkippedItemArray":
Dim swApp As Object
Dim Part As Object
Dim skip As Variant
Dim skip2(0 To 3) As Long
Private Sub CommandButton1_Click()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SelectByID "Lineares Muster1", "BODYFEATURE", 0, 0, 0
Set SelMan = Part.SelectionManager
Set Feature = SelMan.GetSelectedObject5(1)
Set FeatureData = Feature.GetDefinition
skip = FeatureData.SkippedItemArray
skip2(0) = 4
skip2(1) = 5
skip2(2) = 6
skip2(3) = 7
skip = skip2
FeatureData.SkippedItemArray = (skip)
Feature.ModifyDefinition FeatureData, Part, Nothing
FeatureData.ReleaseSelectionAccess
End Sub