MACRO LIBRARY

Create axes through points normal to plane

Free public access. No account or subscription required.

Files

Create axes through points normal to plane

Code

'Preconditions: 3D sketch containing sketch points is selected. Plane1 exists.
'Results: axes are created through all sketch points normal to Plane1
    
'Be sure to have axis visibility turned on.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSketch As SldWorks.Sketch
Dim vSketchPts As Variant
Dim swSketchPt As SldWorks.SketchPoint
Dim i As Integer
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    swModel.SketchManager.Insert3DSketch True
    Set swSketch = swModel.SketchManager.ActiveSketch
    vSketchPts = swSketch.GetSketchPoints2
    swModel.SketchManager.Insert3DSketch True
    For i = 0 To UBound(vSketchPts)
        Set swSketchPt = vSketchPts(i)
        swSketchPt.Select4 False, Nothing
        swModel.Extension.SelectByID2 "Plane1", "PLANE", 0, 0, 0, True, 0, Nothing, 0
        Debug.Print swModel.InsertAxis2(True)
    Next i
End Sub