Solid Edge Assembly Type Library
CreateDuplicate Method
Name of duplicate pattern.
Number of occurrences to duplicate. These occurrences must be at the same level of the active document.
Array containing occurrences to duplicate. These occurrences must be at the same level of the active document.
Occurrence or suboccurrence representing where the duplicate should originate.
Number of 'To' occurrences or suboccurrences where the duplicate occurrences should be placed.
Array containing 'To' occurrences or suboccurrences where the duplicate occurrences should be placed.
Description
Creates a duplicate pattern
Syntax
Visual Basic
Public Function CreateDuplicate( _
   ByVal PatternName As String, _
   ByVal NumberOfMasters As Long, _
   ByRef MasterOccurrences() As Object, _
   ByVal FromOccurrence As Object, _
   ByVal NumberOfToOccurrences As Long, _
   ByRef ToOccurrences() As Object _
) As AssemblyPattern
Parameters
PatternName
Name of duplicate pattern.
NumberOfMasters
Number of occurrences to duplicate. These occurrences must be at the same level of the active document.
MasterOccurrences
Array containing occurrences to duplicate. These occurrences must be at the same level of the active document.
FromOccurrence
Occurrence or suboccurrence representing where the duplicate should originate.
NumberOfToOccurrences
Number of 'To' occurrences or suboccurrences where the duplicate occurrences should be placed.
ToOccurrences
Array containing 'To' occurrences or suboccurrences where the duplicate occurrences should be placed.
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 objApplication As SolidEdgeFramework.Application = Nothing
        Dim SEInstallDir As DirectoryInfo
        Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim objAsmPatterns As SolidEdgeAssembly.AssemblyPatterns = Nothing
        Dim objAsmPattern As SolidEdgeAssembly.AssemblyPattern = Nothing
        Dim PartsToPattern(3) As Object
        Dim ToOccurrences(2) As Object
        Dim FromOccurrence As Object


        Try
            ' Create/get the application with specific settings
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")

            SEInstallDir = GetTrainingFolder()

            ' open the document.
            objAssemblyDocument = objApplication.Documents.Open(SEInstallDir.FullName + "\carrier.asm")

            PartsToPattern(0) = objAssemblyDocument.Occurrences.Item(1)

            ToOccurrences(0) = objAssemblyDocument.Occurrences.Item(4)

            objAsmPatterns = objAssemblyDocument.AssemblyPatterns
  
            FromOccurrence = objAssemblyDocument.Occurrences.Item(3)

            objAsmPattern = objAsmPatterns.CreateDuplicate("Duplicate Test", 1, PartsToPattern, FromOccurrence, 1, ToOccurrences)

            Dim msg = MsgBox("Do you want to edit this duplicate Component?", MsgBoxStyle.YesNo, "Create Duplicate")

            If msg = MsgBoxResult.Yes Then
                objAsmPattern.EditDuplicate(1, PartsToPattern, FromOccurrence, 1, ToOccurrences, "Rename Duplicate")
            End If
            objAssemblyDocument.UpdatePathfinder(SolidEdgeAssembly.AssemblyPathfinderUpdateConstants.seRebuild)

        Catch ex As Exception
            MsgBox(Err.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

AssemblyPatterns Collection  | AssemblyPatterns Members