Solid Edge Assembly Type Library
ChangeSource Method
Name of the assembly document for which the IAC is being edited or if the parent IAC document is changed, then the filename of that document.
Number of specified components.
Array of specified components.
Description
This method needs to be called only if the caller wants to change the parent assembly filename. In which case, we need to know what components need to be included and/or excluded.
Syntax
Visual Basic
Public Sub ChangeSource( _
   ByVal FileName As String, _
   ByVal SpecifiedComponentSelection As AssemblyCopyComponentConstants, _
   Optional ByVal NumSpecifiedComponents As Variant, _
   Optional ByVal SpecifiedComponents As Variant _
) 
Parameters
FileName
Name of the assembly document for which the IAC is being edited or if the parent IAC document is changed, then the filename of that document.
SpecifiedComponentSelection
ValueDescription
seAssemblyCopyComponentsExcludeAll
seAssemblyCopyComponentsExcludeSpecified
seAssemblyCopyComponentsIncludeAll
seAssemblyCopyComponentsIncludeSpecified
NumSpecifiedComponents
Number of specified components.
SpecifiedComponents
Array of specified components.
Example
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
See Also

AssemblyCopy Object  | AssemblyCopy Members