Imports System.Runtime.InteropServices
Public Class AddVisible
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objAsmDoc As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objSimpls As SolidEdgeAssembly.SimplifiedAssemblies = Nothing
Dim objSimpl As SolidEdgeAssembly.SimplifiedAssembly = Nothing
Dim arrayExcludeOccs(0 To 4) As Object
Dim arrayIncludeOccs(0 To 4) As Object
Dim objType As Type = Nothing
Try
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
If objApplication Is Nothing Then
' Get the type from the Solid Edge ProgID
objType = Type.GetTypeFromProgID("SolidEdge.Application")
' Start Solid Edge
objApplication = Activator.CreateInstance(objType)
' Make Solid Edge visible
objApplication.Visible = True
End If
'Get reference to active document
objAsmDoc = objApplication.ActiveDocument
'If assembly is simplified return the collection of simplified assemblies
objSimpls = objAsmDoc.SimplifiedAssemblies
'Get the first item in the collection
objSimpl = objSimpls.Item(1)
If objAsmDoc Is Nothing Then
MsgBox("Could not open document ")
'GoTo ErrorHandler
End If
'simplified asssembly testing
arrayExcludeOccs(0) = objAsmDoc.Occurrences.Item(2)
arrayExcludeOccs(1) = objAsmDoc.Occurrences.Item(4)
arrayIncludeOccs(0) = objAsmDoc.Occurrences.Item(1)
'Add Visible faces
objSimpl = objSimpls.AddVisible(2, arrayExcludeOccs, 0, 1, arrayIncludeOccs, 0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class