this code was working yesterday............

BHW = BHW * 2

Wp = BHW

If Wp >= 2.4615 Then

    BHW = Wp / 3

    BHW = Round(BHW, 4)

    pcs = 3

    ElseIf Width >= 1.5385 Then

        BHW = Wp / 2

        BHW = Round(BHW, 4)

        pcs = 2

        Else

            BHW = Wp

            pcs = 1

End If

swApp.SetUserPreferenceToggle swInputDimValOnCreate, False

Dim p As Variant

p = BHW

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", -3.76684764192319, -0.101600000000019, 1.22315445601786, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", -3.76684764192319, -0.101600000000019, 1.22315445601786, False, 0, Nothing, 0)

Part.Extension.MoveOrCopy True, 1, True, -3.771899999999, -1.231899999999, 0, -3.771899999999, -0.949341206192355, 0

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Point17", "SKETCHPOINT", -4.025899999999, -1.71134120619236, 0, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Point2", "SKETCHPOINT", -4.025899999999, -1.993899999999, 0, True, 0, Nothing, 0)

Set myDisplayDim = Part.AddDimension2(-4.35170400834219, -0.0508, 1.85353174991881)

Set myDimension = Part.Parameter("D3@Sketch18")

myDimension.SystemValue = p

Part.ClearSelection2 True

But today when I execute the code I get the following error at the red hi-lighted code

"run time error 91

Object variable or With Block variable not set"

So I created a macro using the macro wizard and it produced this code

' ******************************************************************************

' C:\Users\mskinner\AppData\Local\Temp\swx1932\Macro1.swb - macro recorded on 12/20/12 by mskinner

' ******************************************************************************

Dim swApp As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = _

Application.SldWorks

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("Arc1", "SKETCHSEGMENT", -2.49959671869474, -4.9999999999768E-04, 1.22054583491369, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Arc9", "SKETCHSEGMENT", -2.49816985133083, -4.99999999998985E-04, 1.03362621024193, True, 0, Nothing, 0)

Dim myDisplayDim As Object

Set myDisplayDim = Part.AddDimension2(-2.77212838520089, -0.1026, 1.10782331316507)

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("D3@Sketch18@bhtest.SLDPRT", "DIMENSION", -2.77640898729261, -4.99999999998457E-04, 1.10925018052898, False, 0, Nothing, 0)

Dim myDimension As Object

Set myDimension = Part.Parameter("D3@Sketch18")

myDimension.SystemValue = 0.86339934

Part.ClearSelection2 True

End Sub

but when I execute the code I get the same error.

and like I said initially the original code executed without error yesterday

thanks,

Michael

SolidworksApi macros