Imports System.Runtime.InteropServices
Public Class ChangeSourceIAC
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 objIACDoc2 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 ChspecComponents As Array = Array.CreateInstance(GetType(System.Object), 2)
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
' From top level Assembly get BlockH.par:1 occ (blockH.par in sub-folder)
objAsmDoc = objApplication.ActiveDocument
' From top level Assembly get BlockH.par:1 occ (blockH.par in sub-folder)
objAsmDoc = objApplication.ActiveDocument
'open the IAC document
objIACDoc = objApplication.Documents.Open("C:\TestFiles\IACMirror\Blocks\BlockAB.asm")
specComponents(0) = objIACDoc.Occurrences.Item(1)
specComponents(1) = objIACDoc.Occurrences.Item(2)
numComp = 2
'Get assembly Copies
objAsmCopies = objAsmDoc.AssemblyCopies
objAsmCopy = objAsmCopies.Add(FileName:="C:\TestFiles\IACMirror\Blocks\BlockAB.asm", SpecifiedComponentSelection:=SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsIncludeSpecified,
NumSpecifiedComponents:=numComp,
SpecifiedComponents:=specComponents)
eType = objAsmCopy.AssemblyCopyType
'changesource
objIACDoc2 = objApplication.Documents.Open("C:\TestFiles\IACMirror\Blocks\BlockCD.asm")
ChspecComponents(0) = objIACDoc2.Occurrences.Item(1)
ChspecComponents(1) = objIACDoc2.Occurrences.Item(2)
objAsmCopy.ChangeSource(FileName:="C:\TestFiles\IACMirror\Blocks\BlockCD.asm",
SpecifiedComponentSelection:=SolidEdgeAssembly.AssemblyCopyComponentConstants.seAssemblyCopyComponentsExcludeSpecified,
NumSpecifiedComponents:=1,
SpecifiedComponents:=ChspecComponents)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class