Imports System.Runtime.InteropServices
Public Class AddIACMirror
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 objIACDoc As SolidEdgeFramework.SolidEdgeDocument = Nothing
Dim objAsmCopies As SolidEdgeAssembly.AssemblyCopies = Nothing
Dim objAsmCopy1 As SolidEdgeAssembly.AssemblyCopy = Nothing
Dim objAsmCopy2 As SolidEdgeAssembly.AssemblyCopy = Nothing
Dim objAsmCopy3 As SolidEdgeAssembly.AssemblyCopy = Nothing
Dim objAsmCopy4 As SolidEdgeAssembly.AssemblyCopy = Nothing
Dim numComp As Long
Dim specComponents As Array = Array.CreateInstance(GetType(System.Object), 2)
Dim eType As SolidEdgeAssembly.AssemblyCopyTypeConstants = Nothing
Dim objType As Type = Nothing
Dim strLocalFileName As String = "C:\TestFiles\IACMirror\Blocks\Top.asm"
Dim strLocalIACName As String = "C:\TestFiles\IACMirror\Blocks\BlockAB.asm"
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
objAsmDoc = objApplication.Documents.Open(strLocalFileName)
'open the IAC document
objIACDoc = objApplication.Documents.Open(strLocalIACName)
specComponents(0) = objIACDoc.Occurrences.Item(1)
specComponents(1) = objIACDoc.Occurrences.Item(2)
numComp = 2
'Get assembly Copies
objAsmCopies = objAsmDoc.AssemblyCopies
'Mirror Plane is optional argument. If you dont need mirror copy then dont provide mirrorplane
objAsmCopy1 = objAsmCopies.Add(strLocalIACName,
SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsIncludeAll,
MirrorPlane:=objAsmDoc.AsmRefPlanes.Item(1))
If (objAsmCopy1 Is Nothing) Then
MsgBox("Could not create IAC with IncludeAll option !")
End If
objAsmCopy2 = objAsmCopies.Add(strLocalIACName,
SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsExcludeAll,
MirrorPlane:=objAsmDoc.AsmRefPlanes.Item(1))
If (objAsmCopy2 Is Nothing) Then
MsgBox("Could not create IAC with ExcludeAll option !")
End If
objAsmCopy3 = objAsmCopies.Add(FileName:=strLocalIACName,
SpecifiedComponentSelection:=SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsIncludeSpecified,
NumSpecifiedComponents:=numComp,
SpecifiedComponents:=specComponents,
IncludeAF:=False,
AddNewComponentsOnUpdate:=False,
CoordinateSystem:=objAsmDoc.CoordinateSystems.Item(2),
MirrorPlane:=objAsmDoc.AsmRefPlanes.Item(2))
If (objAsmCopy3 Is Nothing) Then
MsgBox("Could not create IAC with seAssemblyCopyComponentsIncludeSpecified option !")
End If
objAsmCopy4 = objAsmCopies.Add(FileName:=strLocalIACName,
SpecifiedComponentSelection:=SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsExcludeSpecified,
NumSpecifiedComponents:=1,
CoordinateSystem:=objAsmDoc.CoordinateSystems.Item(2),
SpecifiedComponents:=specComponents,
MirrorPlane:=objAsmDoc.AsmRefPlanes.Item(1))
If (objAsmCopy4 Is Nothing) Then
MsgBox("Could not create IAC with seAssemblyCopyComponentsExcludeSpecified option !")
End If
'close documents
objAsmCopy4 = Nothing
objAsmCopy3 = Nothing
objAsmCopy1 = Nothing
objAsmCopy2 = Nothing
objAsmCopies = Nothing
objIACDoc.Close(SaveChanges:=False)
objIACDoc = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class