Showing results for 
Search instead for 
Did you mean: 

Can you Add a Plane by 3 Points using sketches?

Valued Contributor
Valued Contributor


I need to create a plane by 3 points (RefPlanes.AddBy3Points). I would prefer to do it using lines2d on sketches.

I searched though this forum and saw several other people have asked for help on this though the years, but no one seems to have provided a solution.

If someone has been successful in doing this, could you post the code?



I am a VB.NET module which throws a message "No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))" for me.




Posted by: Curt Nisly
Post date: 6/18/2009 10:26:34 AM


RE: Can you Add a Plane by 3 Points using sketches?

Valued Contributor
Valued Contributor


This code works!

Private Sub Command1_Click()

    Dim objApp As Application

    Dim objPart As SolidEdgePart.PartDocument

    Dim objRefPlanes As SolidEdgePart.RefPlanes

    Dim objRefPlane(1 To 3) As SolidEdgePart.RefPlane

    Dim objSketches As SolidEdgePart.Sketchs

    Dim objSketch(1 To 3) As SolidEdgePart.Sketch

    Dim objProfiles(1 To 3) As SolidEdgePart.Profiles

    Dim objProfile(1 To 3) As SolidEdgePart.Profile

    Dim objLines2d(1 To 3) As SolidEdgeFrameworkSupport.Lines2d

    Dim objLine2d(1 To 3) As SolidEdgeFrameworkSupport.Line2d

    Dim objPoints2d(1 To 3) As SolidEdgeFrameworkSupport.Points2d

    Dim objPoint2d(1 To 3) As SolidEdgeFrameworkSupport.Point2d

    Dim edgeSet(1 To 3) As Object

    Dim keyPoints(1 To 3) As KeyPointType

    Dim objRefPlane3P As SolidEdgePart.RefPlane


    Dim i As Integer


    Dim X1(1 To 3) As Double

    Dim Y1(1 To 3) As Double

    Dim X2(1 To 3) As Double

    Dim Y2(1 To 3) As Double

    Dim Z(1 To 3) As Double


    X1(1) = 0.1

    Y1(1) = 0

    X2(1) = 0.1

    Y2(1) = 0.1

    X1(2) = 0

    Y1(2) = 0

    X2(2) = 0

    Y2(2) = 0.1

    X1(3) = -0.1

    Y1(3) = 0

    X2(3) = -0.1

    Y2(3) = 0.1

    Z(1) = 0.1

    Z(2) = 0.2

    Z(3) = 0.15


    ' Connect to a running instance of Solid Edge

    Set objApp = GetObject(, "SolidEdge.Application")

    ' Create a new part document

    Set objPart = objApp.Documents.Add("SolidEdge.PartDocument")

    ' Get a reference to the ref planes collection

    Set objRefPlanes = objPart.RefPlanes

    ' Get a reference to the sketches collection

    Set objSketches = objPart.Sketches



    For i = 1 To 3

        ' Add a new reference plane

        Set objRefPlane(i) = objRefPlanes.AddParallelByDistance(objRefPlanes(0), Z(i), SolidEdgePart.ReferenceElementConstants.igNormalSide, , , False)

        ' Add a new sketch

        Set objSketch(i) = objSketches.Add()

        ' Get a reference to the profiles collection

        Set objProfiles(i) = objSketch(i).Profiles

        ' Add a new profile

        Set objProfile(i) = objProfiles(i).Add(objRefPlane(i))

        ' Get a reference to the lines2d collection

        Set objLines2d(i) = objProfile(i).Lines2d

        ' Draw a line

        Set objLine2d(i) = objLines2d(i).AddBy2Points(X1(i), Y1(i), X2(i), Y2(i))

        ' Get a reference to the pointss2d collection

        Set objPoints2d(i) = objProfile(i).Points2d

        ' Draw a point

        Set objPoint2d(i) = objPoints2d(i).Add(X1(i), Y1(i))

        ' Show the profile

        objProfile(i).Visible = True

    Next i


    Set edgeSet(1) = objProfile(1).CurveBody.Curves(1)

    Set edgeSet(2) = objProfile(2).CurveBody.Curves(1)

    Set edgeSet(3) = objProfile(3).CurveBody.Curves(1)



    keyPoints(1) = KeyPointType.igKeyPointStart

    keyPoints(2) = KeyPointType.igKeyPointStart

    keyPoints(3) = KeyPointType.igKeyPointStart


    Set objRefPlane3P = objRefPlanes.AddBy3Points(3, edgeSet, keyPoints, False)


    Set objApp = Nothing

    Set objPart = Nothing

    Set objRefPlanes = Nothing

    Set objSketches = Nothing

    For i = 1 To 3

        Set objRefPlane(i) = Nothing

        Set objSketch(i) = Nothing

        Set objProfiles(i) = Nothing

        Set objProfile(i) = Nothing

        Set objLines2d(i) = Nothing

        Set objLine2d(i) = Nothing

        Set objPoints2d(i) = Nothing

        Set objPoint2d(i) = Nothing

        Set edgeSet(i) = Nothing


    Set objRefPlane3P = Nothing

End Sub


Posted by: Curt Nisly
Post date: 6/19/2009 10:17:13 AM