Create Sketch on selected Face

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi all,

 

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

            Try
                objSketch = objSketchs.AddByPlanarFace(_myFace)
                objSketch.Name = "Sketch_Face"

                Dim objProfile As SolidEdgePart.Profile = objSketch.Profile
                objProfile.Circles2d.AddByCenterRadius(0, 0, 0.2)
                objProfile.End(SolidEdgePart.ProfileValidationType.igProfileSingle)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

The code crash when creating the sketch using AddByPlanarFace.

 

Any help to create a sketch on a selected face would be appreciated.

 

Thanks

 

Romuald


Romuald BERTIN
2 REPLIES

Re: Create Sketch on selected Face

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

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.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Create Sketch on selected Face

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Thanks Jason,

 

I manage to make it work using ParallelByDistance tio create a plane on the surface then create a new sketch using this plane.

 

Romuald.


Romuald BERTIN