Imports System.IO
Imports System.Runtime.InteropServices
Module Example
    <STAThread()> _
    Sub Main()
        Dim objApplication As SolidEdgeFramework.Application = Nothing
        Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim objStudyOwner As SolidEdgePart.StudyOwner = Nothing
        Dim strScratchDirLoc As String = "F:\MyScratchDir"
        Try
            OleMessageFilter.Register()
            ' Connect to Solid Edge
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            objAssemblyDocument = objApplication.ActiveDocument
            objStudyOwner = objAssemblyDocument.StudyOwner
            objStudyOwner.SetNASTRANScratchDirectoryLocation(strScratchDirLoc)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            OleMessageFilter.Revoke()
        End Try
    End Sub
End Module