Code:
Dim swApp As SldWorks.SldWorks
Dim myFeature As SldWorks.Feature
Dim Part As SldWorks.ModelDoc2
Dim myRefPlane As SldWorks.RefPlane
Dim boolstatus As BooleanOption Explicit
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.NewDocument("''pfad", 0, 0, 0) 'entsprechenden Pfad eingefügt
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, 0.01, 0, 0, 0, 0)
'ich benutze die deutsche Version, mit "Ebene vorn" werden aber auch keine Refebenen erzeugt
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, 0.02, 0, 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Dim vSkLines As Variant
vSkLines = Part.SketchManager.CreateCornerRectangle(-2.50462141853123E-02, 1.57487558892494E-02, 0, 2.75128867944718E-02, -0.015559011842391, 0)
Part.SketchManager.InsertSketch True
' Sketch to extrude
boolstatus = Part.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
' Start condition reference
boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 1.05020593408751E-03, -1.95369982668282E-03, 2.48175428318827E-02, True, 32, Nothing, 0)
' End condition reference
boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 6.8370744701368E-03, -0.004419862088339, 0.018892268568016, True, 1, Nothing, 0)
' Boss extrusion start condition reference is Plane2, and the extrusion end is offset 3 mm from the end condition reference, Plane1
Set myFeature = Part.FeatureManager.FeatureExtrusion3(True, False, True, swEndCondOffsetFromSurface, 0, 0.003, 0.003, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, swStartSurface, 0, False)
End Sub