Solid Edge Part Type Library
Add2 Method
Specifies a reference object for multi-level interpart (or an occurrence, if only one level is involved).
Specifies the source geometry.
Description
Adds an InterpartConstruction object to the referenced collection. Allows you create an interpart construction without in-place activation.
Syntax
Visual Basic
Public Function Add2( _
   ByVal PartTarget As Object, _
   ByVal AsmSource As Object _
) As InterpartConstruction
Parameters
PartTarget
Specifies a reference object for multi-level interpart (or an occurrence, if only one level is involved).
AsmSource
Specifies the source geometry.
Example
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 
        Dim objSEApplication As SolidEdgeFramework.Application = Nothing
        Dim oAsmDoc As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim oInterpartConstruction As SolidEdgePart.InterpartConstruction = Nothing  
        Dim oReferenceToOcc2 As SolidEdgeFramework.Reference = Nothing

        Dim oOccs As SolidEdgeAssembly.Occurrences = Nothing
        Dim oOcc1 As SolidEdgeAssembly.Occurrence = Nothing
        Dim oOcc2 As SolidEdgeAssembly.Occurrence = Nothing
        Dim oPart1 As SolidEdgePart.PartDocument = Nothing
        Dim oPart2 As SolidEdgePart.PartDocument = Nothing
        Dim objFaces As SolidEdgeGeometry.Faces = Nothing
        Dim objFace As SolidEdgeGeometry.Face = Nothing
        Dim SEInstallDir As DirectoryInfo
                
        Try
            'Get the SolidEdge Application object
            objSEApplication = Marshal.GetActiveObject("SolidEdge.Application")
            SEInstallDir = GetTrainingFolder()
            'Open the sample Assembly document
            oAsmDoc = objSEApplication.Documents.Open(SEInstallDir.FullName + "\Pin1.asm")
            oOccs = oAsmDoc.Occurrences
            'Set a reference to an occurrence in the assembly document
            oOcc1 = oOccs.Item(1)
            oOcc2 = oOccs.Item(2)

            oPart1 = CType(oOcc1.OccurrenceDocument, SolidEdgePart.PartDocument)
            oPart2 = CType(oOcc2.OccurrenceDocument, SolidEdgePart.PartDocument)
            'Set a reference to a topological element in the occurrence's Part model
            objFaces = oPart2.Models.Item(1).ExtrudedProtrusions.Item(1).Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll)
            'Create a Reference elemenet, which maps back to the topological element from the assembly
            oReferenceToOcc2 = oAsmDoc.CreateReference(oOcc2, objFaces.Item(1))
            'Pass the Reference objects in to the Part Inter-Part Copy command - first is the target and second arg is the source - always to the top doc
            oInterpartConstruction = oPart1.Constructions.InterpartConstructions.Add2(oOcc1, oReferenceToOcc2)
            'Update Path finder
            oAsmDoc.UpdatePathfinder(SolidEdgeAssembly.AssemblyPathfinderUpdateConstants.seRebuild)

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
    Function GetTrainingFolder() As DirectoryInfo
        Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
        Dim objInstallFolder As DirectoryInfo = Nothing
        Dim objTrainingFolder As DirectoryInfo = Nothing

        Try
            objInstallData = New SEInstallDataLib.SEInstallData
            objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
            objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
        Catch
        Finally
            If Not (objInstallData Is Nothing) Then
                Marshal.FinalReleaseComObject(objInstallData)
                objInstallData = Nothing
            End If
        End Try

        Return objTrainingFolder
    End Function

End Class
See Also

InterpartConstructions Collection  | InterpartConstructions Members