AnsweredAssumed Answered

Trouble with example code

Question asked by Edwin Thompson on Jul 12, 2016
Latest reply on Jul 13, 2016 by Edwin Thompson

I'm trying to follow an example but am not sure how to address the error:

 

The code that was copied is shown below.  The error is shown at the bottom.

 

Any ideas how to fix this are very appreciated.  Any explanation of the "bigger picture" would also be very helpful.... thank you.

 

'following dim's are for Holewizard example

        Dim swModel As ModelDoc2

        Dim swModelDocExt As ModelDocExtension

        Dim swFeatMgr As FeatureManager

        Dim swFeat As Feature

        Dim swSketchMgr As SketchManager

        Dim sketchLines As Object

        Dim status As Integer

        Dim boolstatus As Boolean

        Dim P1(2) As Double

        Dim P2(2) As Double

        Dim P3(2) As Double

 

        ' Create the model for the wizard hole

        swApp.ResetUntitledCount(0, 0, 0)

        swModel = swApp.NewDocument("C:\Documents and Settings\All Users\Application Data\SOLIDWORKS\SOLIDWORKS 2014\templates\Slot Test Part.prtdot", 0, 0, 0)

        swApp.ActivateDoc2("Part1", False, status)

        swModel = swApp.ActiveDoc

        swSketchMgr = swModel.SketchManager

        swModelDocExt = swModel.Extension

        swFeatMgr = swModel.FeatureManager

        sketchLines = swSketchMgr.CreateCornerRectangle(-0.05096498314664, 0.05060941349678, 0, 0.1021670127265, -0.05037236706354, 0)

        boolstatus = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)

        boolstatus = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

        boolstatus = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

        boolstatus = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

 

        swFeat = swFeatMgr.FeatureExtrusion2(True, False, False, 0, 0, 0.381, 0.381, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, True, True, True, 0, 0, False)

 

        'Create three points for the reference plane

 

        P1(0) = -0.0141556764402858

        P1(1) = 0.00194061273859598

        P1(2) = 0

        P2(0) = -0.0141556764402858

        P2(1) = 0.00194061273859598

        P2(2) = 1

        P3(0) = -0.149976101832345

        P3(1) = -0.988792859011662

        P3(2) = 0

 

        'Create the reference plane

        swModel.CreatePlaneFixed2(P1, P2, P3, False)

 

        'Select the reference plane

        boolstatus = swModelDocExt.SelectByID2("Plane1", "PLANE", -0.0156784487003801, -0.00916715285390111, 0.0558270998665543, False, 0, Nothing, 0)

 

        ' Create the hole wizard hole

       swFeat = swFeatMgr.HoleWizard5(swFeatMgr.swWzdGeneralHoleTypes.swWzdCounterSink, swModel.swWzdHoleStandards.swStandardAnsiMetric, swModel.swWzdHoleStandardFastenerTypes.swStandardAnsiMetricFlatHead82, "M2", swModel.swEndConditions.swEndCondThroughAll, 0.0102, 0.010312189893273, 0, 0.0044, 1.57079632679489, 0.000152189893272978, 0, 2.05948851735331, 0, 0, 0, 1, 0, 0, 0, "", False, True, True, True, True, False)

 

Outcomes