Imports System.Runtime.InteropServices
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objPartDoc As SolidEdgePart.PartDocument = Nothing
        Dim objEdges As SolidEdgeGeometry.Edges
        Dim objRuledSurfaces As SolidEdgePart.RuledSurfaces
        Dim objRuledSurface As SolidEdgePart.RuledSurface
        Dim objConstructions As SolidEdgePart.Constructions
        Dim objEdgArr As System.Array
        Dim objType As Type = Nothing
        Dim strRetStatusMsg As String
        strRetStatusMsg = ""
        Try
            'The following sample code assumes that SolidEdge application is running and part document is active with one square block in it.
            'This sample code will create Ruled Surface with one Edges as input.
            'If you want to create ruled surface for more than one edge they need to be tangentially connected.
            ' Create/get the application with specific settings
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            If objApplication Is Nothing Then
                ' Get the type from the Solid Edge ProgID
                objType = Type.GetTypeFromProgID("SolidEdge.Application")
                ' Start Solid Edge
                objApplication = Activator.CreateInstance(objType)
                ' Make Solid Edge visible
                objApplication.Visible = True
            End If
            'Get reference to active document
            objPartDoc = objApplication.ActiveDocument()
            'obtain the first model and get all its edges
            objEdges = objPartDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Edges(SolidEdgeConstants.FeatureTopologyQueryTypeConstants.igQueryAll)
            If Err().Number <> 0 Or objEdges Is Nothing Then
                strRetStatusMsg = "Could not open document "
            End If
            objEdgArr = Array.CreateInstance(GetType(Object), 1)
            objEdgArr(0) = objEdges.Item(1)
            'obtain constrction object
            objConstructions = objPartDoc.Constructions
            If Err().Number <> 0 Or objConstructions Is Nothing Then
                strRetStatusMsg = "Could not open document "
            End If
            objRuledSurfaces = objConstructions.RuledSurfaces
            'now create Ruled Surface
            objRuledSurface = objConstructions.RuledSurfaces.Add(1,
                                objEdgArr,
                                objEdges.Item(2),
                                0.1,
                                10.0, SolidEdgeConstants.RuledSurfaceTypeConstants.igRuledAlongAnAxis,
                                SolidEdgeConstants.RuledSurfaceDirectionConstants.igRuledSurfaceleft,
                                SolidEdgeConstants.RuledSurfaceSideConstants.igRuledSurfaceOutside)
            'Edit ruled Surface
            'Change distance
            objRuledSurface.RuledSurfaceDistance = 0.2
            'Change angle
            objRuledSurface.RuledSurfaceDistance = 11
            'Change Rul surface type 
            objRuledSurface.RuledSurfaceType = SolidEdgeConstants.RuledSurfaceTypeConstants.igRuledNatural
            'Change Rul surface Direction 
            objRuledSurface.RuledSurfaceDirection = SolidEdgeConstants.RuledSurfaceDirectionConstants.igRuledSurfacRight
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class