Files
Insert axes concentric to cylindrical faces of selected feature Associated model(s)
Code
Module:
'Tool for adding reference axes concentric to the cylindrical faces owned _
by selected features.
'Preconditions: Features are selected in the feature tree.
'Example: Open "insert axes.SLDPRT" and select one or more of the body _
features before running.
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swFace As SldWorks.Face2
Dim swSurf As SldWorks.Surface
Dim swEnt As SldWorks.Entity
Dim vFaces As Variant
Dim colSelFeats As New Collection
Dim i As Integer, j As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
For i = 1 To swSelMgr.GetSelectedObjectCount2(-1)
If TypeOf swSelMgr.GetSelectedObject6(i, -1) Is Feature Then
colSelFeats.Add swSelMgr.GetSelectedObject6(i, -1)
End If
Next i
swModel.ClearSelection2 True
For i = 1 To colSelFeats.Count
Set swFeat = colSelFeats.Item(i)
vFaces = swFeat.GetFaces
If IsEmpty(vFaces) = False Then
For j = 0 To UBound(vFaces)
Set swFace = vFaces(j)
Set swSurf = swFace.GetSurface
If swSurf.IsCylinder Then
Set swEnt = vFaces(j)
swEnt.Select False
swModel.InsertAxis2 True
End If
Next j
End If
Next i
End Sub