Pre-select the componets in the assembly.
Then have the macro loop through each componet selected searchingfor specific hole wizard features then when found insert and mate apin to each...
I got to the part to where I need to get the face or loop thrufaces in the hole wizard feature.
Dim swApp As SldWorks.SldWorks
Dim swCompModel As SldWorks.ModelDoc2
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component
Dim swpart As SldWorks.PartDoc
Dim temp As String
Dim Part As Object
Dim theFeature As Object
Dim featCount As Long
Dim featName As String
Dim chk As String
Dim count As Integer
Dim swCompName As Object
Dim Face1 As Object
Dim Face2 As Object
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCompModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
For j = 1 To swSelMgr.GetSelectedObjectCount
count = 0
temp = swSelMgr.GetSelectedObjectType2(j)
Select Case temp
Case 20 ' ASSEMBLY MODEL OPEN body selected
Set swComp = swSelMgr.GetSelectedObjectsComponent2(j)
Set swModel = swComp.GetModelDoc
featCount = swModel.GetFeatureCount
For i = featCount To 1 Step -1
Set theFeature = swModel.FeatureByPositionReverse(featCount - i)
featName = theFeature.Name
chk = Left(featName, 5)
If chk = "CBORE" Then
Part.AddComponent "C:\SW_MacroLib\XXXX-A-000_SHCS.SLDPRT", 1, 1, 1
'not sure where to go from here....
count = count + 1
MsgBox "Found =" & featName
End If
Set theFeature = Nothing
'swApp.SendMsgToUser "Feature " + Str(i) + " is " + featName
Next i
MsgBox "Number CBORE's found =" & count
Case Else
MsgBox ("Incorrect Type Selected " & temp)
GoTo Skip
End Select
Skip:
temp = 0
'swModel.ClearSelection2 (True)
Next j
End Sub
SolidworksApi macros