InsertRefPlane (VBA) - Run-Time Error

Hello Guys,

I am trying to automate the placement of a plane perpendicular to a line.

To set the line I use this command:

Set skSegment = swModel.SketchManager.CreateLine(x1, y1, z1, x2, y2, z2)

To set the Reference Plane I use the following:

boolstatus = swModel.Extension.SelectByID2("Line1@3DSketch1", "EXTSKETCHSEGMENT", 59, -464, -450, True, 0, Nothing, 0)

boolstatus = swModel.Extension.SelectByID2("Point1@3DSketch1", "EXTSKETCHPOINT", 59, -464, -450, True, 1, Nothing, 0)

Set swRefPlane = swModel.FeatureManager.InsertRefPlane(2, 0, 4, 0, 0, 0)

swModel.ClearSelection2 True

I get this error when trying to set the reference plane:

Finally, when I use the solidwork design environement (i.e. using my mouse) I am able to place the Reference Plane without any problems.

Any ideas?

Matthieu

SolidworksApi macros