Imports System.IO
Imports System.Runtime.InteropServices
Module Example
<STAThread()> _
Sub Main()
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim objSelectSet As SolidEdgeFramework.SelectSet = Nothing
Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objOccurrences As SolidEdgeAssembly.Occurrences = Nothing
Dim objOccurrence As SolidEdgeAssembly.Occurrence = Nothing
Dim objHighlightSets As SolidEdgeFramework.HighlightSets = Nothing
Dim objHighlightSet As SolidEdgeFramework.HighlightSet = Nothing
Dim objTrainingFolder As DirectoryInfo
Dim objFileInfo As FileInfo
Dim i As Integer
Try
OleMessageFilter.Register()
objTrainingFolder = GetTrainingFolder()
objFileInfo = New FileInfo(Path.Combine(objTrainingFolder.FullName, "Try It\BrakePedalAssy.asm"))
objApplication = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
objApplication.Visible = True
objDocuments = objApplication.Documents
objAssemblyDocument = objDocuments.Open(objFileInfo.FullName)
objHighlightSets = objAssemblyDocument.HighlightSets
objSelectSet = objApplication.ActiveSelectSet
objOccurrences = objAssemblyDocument.Occurrences
' Add individual Occurrence objects to SelectSet.
' This method can cause significant GUI performance problems
' because the screen redraws after each Add() call.
For i = 1 To objOccurrences.Count
objSelectSet.Add(objOccurrences.Item(i))
Next
' Clear the SelectSet.
objSelectSet.RemoveAll()
' Create a new HighlightSet
objHighlightSet = objHighlightSets.Add()
' Demonstrate adding HighlightSet to SelectSect (Added in V17).
For i = 1 To objOccurrences.Count
objHighlightSet.AddItem(objOccurrences.Item(i))
Next
' Add entire HighlightSet to SelectSet.
' This is the fastest way to add a large collection of objects.
objSelectSet.Add(objHighlightSet)
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