Imports System.IO
Imports System.Runtime.InteropServices
Module Example
    <STAThread()> _
    Sub Main()
        Dim objTrainingFolder As DirectoryInfo = Nothing
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objDocuments As SolidEdgeFramework.Documents = Nothing
        Dim objPartDocument As SolidEdgePart.PartDocument = Nothing
        Dim objRefPlanes As SolidEdgePart.RefPlanes = Nothing
        Dim objRefPlane As SolidEdgePart.RefPlane = Nothing
        Dim objFeatures As Array
        Dim objFeature As Object
        Dim featureType As SolidEdgePart.FeatureTypeConstants
        Try
            OleMessageFilter.Register()
            objTrainingFolder = GetTrainingFolder()
            objApplication = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
            objApplication.Visible = True
            objDocuments = objApplication.Documents
            objPartDocument = objDocuments.Add("SolidEdge.PartDocument")
            objRefPlanes = objPartDocument.RefPlanes
            objFeatures = Array.CreateInstance(GetType(System.Object), 0)
            objRefPlane = objRefPlanes.Item(1)
            objPartDocument.PlaceFeatureLibrary(Path.Combine(objTrainingFolder.FullName, "bar.par"), objRefPlane, 0.0, 0.0, 0.0, objFeatures)
            For Each objFeature In objFeatures
                featureType = objFeature.Type
                Select Case featureType
                    Case SolidEdgePart.FeatureTypeConstants.igAssemblyWeldmentObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igAssemblyWeldmentObject
                    Case SolidEdgePart.FeatureTypeConstants.igBeadFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBeadFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igBendFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBendFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igBlueSurfFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBlueSurfFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igBodyFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBodyFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igBooleanFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBooleanFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igBreakCornerFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igBreakCornerFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igChamferFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igChamferFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igCloseCornerFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igCloseCornerFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igContourFlangeFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igContourFlangeFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igCoordinateSystemFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igCoordinateSystemFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igCopiedPartFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igCopiedPartFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igCopyConstructionObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igCopyConstructionObject
                    Case SolidEdgePart.FeatureTypeConstants.igCopySurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igCopySurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igDeleteBlendFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDeleteBlendFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDeleteFaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDeleteFaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDeleteHoleFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDeleteHoleFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDeleteRegionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDeleteRegionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDerivedCurveObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDerivedCurveObject
                    Case SolidEdgePart.FeatureTypeConstants.igDimpleFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDimpleFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDraftFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDraftFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igDrawnCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igDrawnCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igEtchFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igEtchFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igExtendSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igExtendSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igExtrudedCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igExtrudedCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igExtrudedProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igExtrudedProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igExtrudedSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igExtrudedSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igFaceMoveObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igFaceMoveObject
                    Case SolidEdgePart.FeatureTypeConstants.igFaceOffsetObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igFaceOffsetObject
                    Case SolidEdgePart.FeatureTypeConstants.igFaceRotateObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igFaceRotateObject
                    Case SolidEdgePart.FeatureTypeConstants.igFilletWeldFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igFilletWeldFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igFlangeFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igFlangeFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igGussetFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igGussetFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igHelixCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igHelixCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igHelixProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igHelixProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igHoleFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igHoleFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igInterpartConstructionObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igInterpartConstructionObject
                    Case SolidEdgePart.FeatureTypeConstants.igIntersectionCurveObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igIntersectionCurveObject
                    Case SolidEdgePart.FeatureTypeConstants.igIntersectionPointObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igIntersectionPointObject
                    Case SolidEdgePart.FeatureTypeConstants.igJogFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igJogFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLabelWeldFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLabelWeldFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLipFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLipFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLiveSectionObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLiveSectionObject
                    Case SolidEdgePart.FeatureTypeConstants.igLoftedCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLoftedCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLoftedFlangeFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLoftedFlangeFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLoftedProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLoftedProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLoftedSurfaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLoftedSurfaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igLouverFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igLouverFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igMatchFlangeFaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igMatchFlangeFaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igMidSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igMidSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igMirrorCopyFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igMirrorCopyFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igMirrorCopyGeometryObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igMirrorCopyGeometryObject
                    Case SolidEdgePart.FeatureTypeConstants.igMirrorPartFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igMirrorPartFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igModelCopyFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igModelCopyFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igNormalCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igNormalCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igNormalToFaceCutoutObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igNormalToFaceCutoutObject
                    Case SolidEdgePart.FeatureTypeConstants.igNormalToFaceProtrusionObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igNormalToFaceProtrusionObject
                    Case SolidEdgePart.FeatureTypeConstants.igOffsetSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igOffsetSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igPartingSplitFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igPartingSplitFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igPartingSurfaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igPartingSurfaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igPatternCopyGeometryObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igPatternCopyGeometryObject
                    Case SolidEdgePart.FeatureTypeConstants.igPatternFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igPatternFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igPatternPartFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igPatternPartFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igProjectCurveObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igProjectCurveObject
                    Case SolidEdgePart.FeatureTypeConstants.igRebendFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRebendFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igReplaceFaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igReplaceFaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igResizeBendObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igResizeBendObject
                    Case SolidEdgePart.FeatureTypeConstants.igResizeHoleObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igResizeHoleObject
                    Case SolidEdgePart.FeatureTypeConstants.igResizeRoundObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igResizeRoundObject
                    Case SolidEdgePart.FeatureTypeConstants.igRevolvedCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRevolvedCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igRevolvedProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRevolvedProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igRevolvedSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRevolvedSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igRibFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRibFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igRoundFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igRoundFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igSplitCurveObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSplitCurveObject
                    Case SolidEdgePart.FeatureTypeConstants.igSplitFaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSplitFaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igStitchSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igStitchSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igSurfaceByBoundaryObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSurfaceByBoundaryObject
                    Case SolidEdgePart.FeatureTypeConstants.igSweptCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSweptCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igSweptProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSweptProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igSweptSurfaceFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igSweptSurfaceFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igTabFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igTabFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igThickenFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igThickenFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igThinRegionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igThinRegionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igThinwallFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igThinwallFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igTrimSurfaceObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igTrimSurfaceObject
                    Case SolidEdgePart.FeatureTypeConstants.igTubeFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igTubeFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igUnbendFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igUnbendFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igVentFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igVentFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWebNetworkFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWebNetworkFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldBeadByExtrudedProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldBeadByExtrudedProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldBeadByRevolvedProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldBeadByRevolvedProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldBeadBySweptProtrusionFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldBeadBySweptProtrusionFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldChamferFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldChamferFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldExtrudedCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldExtrudedCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldHoleFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldHoleFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldMirrorFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldMirrorFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldPatternFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldPatternFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldRevolvedCutoutFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldRevolvedCutoutFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWeldRoundFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWeldRoundFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWireFeatureObject
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWireFeatureObject
                    Case SolidEdgePart.FeatureTypeConstants.igWrapSketch
                        'Handle type SolidEdgePart.FeatureTypeConstants.igWrapSketch
                End Select
            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            OleMessageFilter.Revoke()
        End Try
    End Sub
    Function GetTrainingFolder() As DirectoryInfo
        Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
        Dim objInstallFolder As DirectoryInfo = Nothing
        Dim objTrainingFolder As DirectoryInfo = Nothing
        Try
            objInstallData = New SEInstallDataLib.SEInstallData
            objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
            objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
        Catch
        Finally
            If Not (objInstallData Is Nothing) Then
                Marshal.FinalReleaseComObject(objInstallData)
                objInstallData = Nothing
            End If
        End Try
        Return objTrainingFolder
    End Function
End Module