I'm trying to create a new sketch on a selected face of my model using the following code, but can't make it work :
Dim _myFace As SolidEdgeGeometry.Face = _application.ActiveDocument.SelectSet.Item(1)
Dim objSketchs As SolidEdgePart.Sketchs = _application.ActiveDocument.Sketches
Dim objSketch As SolidEdgePart.Sketch = Nothing
objSketch = objSketchs.AddByPlanarFace(_myFace)
objSketch.Name = "Sketch_Face"
Dim objProfile As SolidEdgePart.Profile = objSketch.Profile
objProfile.Circles2d.AddByCenterRadius(0, 0, 0.2)
Catch ex As Exception
The code crash when creating the sketch using AddByPlanarFace.
Any help to create a sketch on a selected face would be appreciated.
I did some searching and ran across this post. The code in that post passes a "RefPlane" to the "Face" parameter of the AddByPlanarFace method. I'll be the first to admit that's not obvious due to the naming of the method and parameter. Looking at the SDK documentation for AddByPlanarFace, the description states "Adds a non-merging sketch on the specified plane." which gives a clue that we should use a RefPlane in the parameter.