Hole Wizard

I am having trouble properly creating a Hole Wizard featurefrom a VB macro. To test the macro I made a simple part with a3"x3" rectangle sketched on the Front plane and then extruded backalong the negative Z axis.

I wrote a test macro that creates a sketch on the Front plane (sothat I know it is on the extrude feature) containing four sketchpoints. It then selects the four sketch points and the plane thatthey lie on and invokes the HoleWizard2 method. The problem that Ihave is that not only does it create the holes at my four sketchpoints, it also wants to create a hole at the origin. If the partdoes not happen to overlap the origin then the feature creationfails.


Option Explicit
Dim swApp As SldWorks.SldWorks
Dim objPart As SldWorks.ModelDoc2
Dim objPoint() As SldWorks.SketchPoint
Dim objHoleFeature As SldWorks.feature
Dim objSketch As Variant
Dim status As Variant
Dim i As Integer

Sub main()

Set swApp = Application.SldWorks
Set objPart = swApp.ActiveDoc

objPart.Extension.SelectByID "Front", "PLANE", 0, 0, 0, True, 0,Nothing

objPart.InsertSketch2 True

ReDim objPoint(3)

Set objPoint(0) = objPCBPart.CreatePoint2(1000 / 39370.0787402,1000 / 39370.0787402, 0)
Set objPoint(1) = objPCBPart.CreatePoint2(2000 / 39370.0787402,1000 / 39370.0787402, 0)
Set objPoint(2) = objPCBPart.CreatePoint2(1000 / 39370.0787402,2000 / 39370.0787402, 0)
Set objPoint(3) = objPCBPart.CreatePoint2(2000 / 39370.0787402,2000 / 39370.0787402, 0)

objPart.InsertSketch2 True

objPart.Rebuild swRebuildAll

Set objSketch = objPCBPart.SelectionManager.GetSelectedObject6(1,-1)

objPart.ClearSelection2 True

For i = 0 To 3
objPoint(i).Select2 True, 0
Next i

objPart.Extension.SelectByID "Front", "PLANE", 0, 0, 0, True, 0,Nothing

Set objHoleFeature = objPCBPart.FeatureManager.HoleWizard2( _
swWzdHole, _
swStandardAnsiInch, _
swStandardAnsiInchAllDrillSizes, _
"#1", _
swEndCondThroughAll, _
125 / 39370.0787402, _
63 / 39370.0787402, _
1, _
0, _
0, _
0, _
0, _
0, _
0, _
-1, _
-1, _
-1, _
-1, _
-1, _
"", _
False, _
True, _
True, _
True, True)

objHoleFeature.Name = "Mounting Holes"

objSketch.Select2 False, 0

objPart.EditDelete

End Sub


I thought that maybe the problem was that the Hole Wizard wanted tosee a face selected instead of the Front plane, so I commented outall of the selection code and manually selected the points and theface. When I ran the macro it still created the hole at the origin.I am quite puzzled.

I looked atthisthread but it held no revelations for me.

Can anyone offer me some wisdom?

Thanks,
Andy FabansSolidworksApi macros