Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objSEApplication As SolidEdgeFramework.Application
Dim objDoc As SolidEdgeAssembly.AssemblyDocument
Dim P1X, P1Y, P1Z, P2X, P2Y, P2Z As Double
Dim SEInstallDir As DirectoryInfo
Dim objZones As SolidEdgeAssembly.Zones = Nothing
Dim objZone As SolidEdgeAssembly.Zone = Nothing
Try
' Get the application
objSEApplication = Marshal.GetActiveObject("SolidEdge.Application")
SEInstallDir = GetTrainingFolder()
objDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\carrier.asm")
objZones = objDoc.Zones
objZone = objZones.Add(0.05, 0.05, 0.05, 0.2, 0.2, 0.2)
objZone.Name = "ZoneName"
objZone.Overlap = True
'Show Parts
objZone.ShowOnlyParts()
'Hide Parts
'objZone.HideParts()
Catch ex As Exception
MsgBox(ex.ToString)
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 Class