Imports System.IO
Imports System.Runtime.InteropServices
Module Example
    <STAThread()> _
    Sub Main()
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objPartDocument As SolidEdgePart.PartDocument = Nothing
        Dim objStudyOwner As SolidEdgePart.StudyOwner = Nothing
        Dim objStudy As SolidEdgePart.Study = Nothing
        Dim objThermalStudy As SolidEdgePart.Study = Nothing
        Dim objLoadOwner As SolidEdgePart.LoadOwner = Nothing
        Dim objModels As SolidEdgePart.Models = Nothing
        Dim objModel As SolidEdgePart.Model = Nothing
        Dim objModelBody As SolidEdgeGeometry.Body = Nothing
        Dim objGeomArray(0) As Object
        Dim estudyType As SolidEdgePart.FEAStudyTypeEnum_Auto
        Dim eMeshType As SolidEdgePart.FEAMeshTypeEnum_Auto
        Dim dThickness As Double = 0
        Dim dwInputOptions As UInteger = 0
        Dim ulNumModes As ULong = 7
        Dim dFreqlow As Double = 0
        Dim dFreqHigh As Double = 1.0
        Dim cmdLineOpts As String = ""
        Dim nastranKeywordOpts As String = ""
        Dim dwResultoptions As UInteger = 0
        'Thermal Options
        Dim dConvectionExp As Double = 0
        Dim dEnclosureAmbientEle As Double = 0
        Dim dwThrmlOptions As UInteger = 0
        Try
            OleMessageFilter.Register()
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            objPartDocument = objApplication.ActiveDocument
            ' Get Study Owner 
            objStudyOwner = objPartDocument.StudyOwner
            'Add Thermal Study
            estudyType = SolidEdgePart.FEAStudyTypeEnum_Auto.eStudyTypeSSHT_Auto
            eMeshType = SolidEdgePart.FEAMeshTypeEnum_Auto.eMeshTypeTetrahedral_Auto
            objStudyOwner.AddThermalStudy(estudyType,
                                        eMeshType,
                                        dThickness,
                                        dwInputOptions,
                                        ulNumModes,
                                        dFreqlow,
                                        dFreqHigh,
                                        cmdLineOpts,
                                        nastranKeywordOpts,
                                        dwResultoptions,
                                        dwThrmlOptions,
                                        dEnclosureAmbientEle,
                                        dConvectionExp,
                                        objStudy)
            objThermalStudy = objStudy
            objModels = objPartDocument.Models
            objModel = objModels.Item(1)
            ' Get the study geometries
            objModelBody = objModel.Body()
            objGeomArray(0) = Nothing
            objGeomArray(0) = objModelBody
            ' Deselect the geometry from study
            objThermalStudy.SetGeometries(objGeomArray)
            objThermalStudy.GetLoadOwner(objLoadOwner)
            'Get Thermal Options
            objThermalStudy.GetThermalStudyOptions(dwThrmlOptions, dEnclosureAmbientEle, dConvectionExp)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            OleMessageFilter.Revoke()
        End Try
    End Sub
End Module