Imports System.Runtime.InteropServices
Public Class ComponentSettingsIAC
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 objAsmCopy As SolidEdgeAssembly.AssemblyCopy = Nothing
Dim eType As SolidEdgeAssembly.AssemblyCopyTypeConstants = Nothing
Dim numComp As Long
Dim specComponents As Array = Array.CreateInstance(GetType(System.Object), 2)
Dim objType As Type = Nothing
Dim ActConstants As Array = Array.CreateInstance(GetType(SolidEdgeAssembly.AssemblyCopyActionConstants), 2)
Dim PlnConstants As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyPlaneConstants), 2)
Dim inArray As Array = Array.CreateInstance(GetType(System.Object), 2)
Dim outArray As Array = Array.CreateInstance(GetType(SolidEdgeAssembly.Occurrence), 2)
Dim ActionArray As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyActionConstants), 2)
Dim AdjustArray As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyPlaneConstants), 2)
Dim EnumArray As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyUserConstants), 2)
Dim inArray1 As Array = Array.CreateInstance(GetType(System.Object), 2)
Dim outArray1 As Array = Array.CreateInstance(GetType(SolidEdgeAssembly.Occurrence), 2)
Dim ActionArray1 As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyActionConstants), 2)
Dim AdjustArray1 As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyPlaneConstants), 2)
Dim EnumArray1 As Array = Array.CreateInstance(GetType(SolidEdgeConstants.AssemblyCopyUserConstants), 2)
Dim strLocalFileName As String = "C:\TestFiles\IACMirror\Blocks\Top.asm"
Dim strLocalIACName As String = "C:\TestFiles\IACMirror\Blocks\BlockCD.asm"
Dim objOcc As SolidEdgeAssembly.Occurrence
Dim occName As String
Dim objOcc1 As SolidEdgeAssembly.Occurrence
Dim occName1 As String
Dim objOcc2 As SolidEdgeAssembly.Occurrence
Dim occName2 As String
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 Assembly Document
objAsmDoc = objApplication.Documents.Open(strLocalFileName)
'IAC document filename is in strFiles(1) - IAC_testcase\Blocks\BlockAB.asm
'open the IAC document
objIACDoc = objApplication.Documents.Open(strLocalIACName)
'Get assembly Copies
objAsmCopies = objAsmDoc.AssemblyCopies
objAsmCopy = objAsmCopies.Add(FileName:=strLocalIACName,
SpecifiedComponentSelection:=SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsIncludeAll
)
If (objAsmCopy Is Nothing) Then
MsgBox("Could not create IAC with seAssemblyCopyComponentsIncludeAll option !")
End If
'Get definition
objAsmCopy.GetDefinition(inArray, outArray, ActionArray, AdjustArray, EnumArray)
objOcc = inArray(0)
occName = objOcc.Name
ActConstants(0) = SolidEdgeAssembly.AssemblyCopyActionConstants.seAssemblyCopyActionExclude
ActConstants(1) = SolidEdgeAssembly.AssemblyCopyActionConstants.seAssemblyCopyActionDefault
numComp = 2
objAsmCopy.ComponentSettings(numComp, inArray, ActConstants, AdjustArray)
inArray(0) = Nothing
inArray(1) = Nothing
outArray(0) = Nothing
outArray(1) = Nothing
'Test
objAsmCopy.GetDefinition(inArray1, outArray1, ActionArray1, AdjustArray1, EnumArray1)
objOcc1 = inArray1(0)
occName1 = objOcc1.Name
objOcc2 = inArray1(1)
occName2 = objOcc2.Name
If (occName = occName1) Then
If (ActionArray1(0) = SolidEdgeAssembly.AssemblyCopyActionConstants.seAssemblyCopyActionExclude) Then
MsgBox("Could not change action constant to Exclude")
End If
ElseIf (occName = occName2) Then
If (ActionArray1(1) = SolidEdgeAssembly.AssemblyCopyActionConstants.seAssemblyCopyActionExclude) Then
MsgBox("Could not change action constant to Exclude")
End If
Else
MsgBox("FAILED - Occname not same - Could not change action constant")
End If
'close documents
objAsmCopy = Nothing
objAsmCopies = Nothing
objIACDoc.Close(SaveChanges:=False)
objIACDoc = Nothing
objAsmDoc.Close(SaveChanges:=False)
objAsmDoc = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class