Solid Edge Part Type Library
AddSimplifyDuplicate Method
Total number of bodies to duplicate.
Array of bodies to be duplicated.
Occurrences used to duplicate originate their position.
Number of occurrences used to calculate position of duplicate occurrence position.
Array of occurrences used to calculate position of duplicate occurrence position.
Name of the feature.
Returns duplicate feature.
Description
This method will create a new duplicate body feature.
Syntax
Visual Basic
Public Sub AddSimplifyDuplicate( _
   ByVal numBodies As Long, _
   ByRef Bodies() As Object, _
   ByVal FromOccurrence As Object, _
   ByVal numOccurrences As Long, _
   ByRef ToOccurrences() As Object, _
   ByVal Name As String, _
   ByRef Duplicate As Object _
) 
Parameters
numBodies
Total number of bodies to duplicate.
Bodies
Array of bodies to be duplicated.
FromOccurrence
Occurrences used to duplicate originate their position.
numOccurrences
Number of occurrences used to calculate position of duplicate occurrence position.
ToOccurrences
Array of occurrences used to calculate position of duplicate occurrence position.
Name
Name of the feature.
Duplicate
Returns duplicate feature.
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 objAssy As SolidEdgeAssembly.AssemblyDocument = Nothing
        Dim objSimpAssys As SolidEdgeAssembly.SimplifiedAssemblies = Nothing
        Dim objSimpAssy As SolidEdgeAssembly.SimplifiedAssembly = Nothing
        Dim objSimpModel As Object = Nothing
        Dim objEnclosures As SolidEdgePart.Enclosures = Nothing
        Dim objOccs As SolidEdgeAssembly.Occurrences = Nothing
        Dim objOcc As SolidEdgeAssembly.Occurrence = Nothing
        Dim objRef As SolidEdgeFramework.Reference = Nothing
        Dim objEnc As SolidEdgePart.Enclosure = Nothing

        Dim objSubOccs As SolidEdgeAssembly.SubOccurrences = Nothing
        Dim objSubOcc As SolidEdgeAssembly.SubOccurrence = Nothing
        Dim objModels As SolidEdgePart.Models = Nothing
        Dim objModel As SolidEdgePart.Model = Nothing
        Dim objMRefPlanes As SolidEdgePart.RefPlanes = Nothing
        Dim objMRefPlane As SolidEdgePart.RefPlane = Nothing
        Dim objBody As SolidEdgeGeometry.Body = Nothing
        Dim bodyArray As System.Array = Array.CreateInstance(GetType(SolidEdgeGeometry.Body), 1)
        Dim occArray As System.Array = Array.CreateInstance(GetType(SolidEdgeFramework.Reference), 1)

        Dim objFromOcc As SolidEdgeAssembly.Occurrence = Nothing

        Dim objDuplicate As SolidEdgePart.Duplicate = Nothing



        Try
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")
            SEInstallDir = GetTrainingFolder()
            objAssy = objApplication.Documents.Open(SEInstallDir.FullName + "\Coffee Pot.asm")

            'objAssy = objApplication.ActiveDocument
            objOccs = objAssy.Occurrences
            objFromOcc = objOccs.Item(1)
            objOcc = objOccs.Item(4)
            objSubOccs = objOcc.SubOccurrences
            For Each subocc As SolidEdgeAssembly.SubOccurrence In objSubOccs
                If (subocc.ThisAsOccurrence.Subassembly = False) Then
                    objSubOcc = subocc
                End If
            Next
            objRef = objSubOcc.Reference
            objRef = objAssy.CreateReference(objOcc, objSubOcc.ThisAsOccurrence)
            occArray(0) = objRef
            objSimpAssys = objAssy.SimplifiedAssemblies
            objSimpAssy = objSimpAssys.AddModel

            objSimpModel = objSimpAssy.SimplifiedModel
            objMRefPlanes = objSimpModel.RefPlanes
            objMRefPlane = objMRefPlanes(1)
            objModels = objSimpModel.Models
            'Following code creates a simplified enclosure around one part suboccurrence of the first occurrence in the assembly.
            objModels.AddSimplifyEnclosure(1, occArray, objMRefPlane, SolidEdgePart.EnclosureTypeConstant.igEnclosureTypeBox, "body", objEnc)


            objModel = objModels.Item(1)
            objBody = objModel.Body
            bodyArray(0) = objBody
            'Following code creates a duplicate body of the simplified enclosure
            objModels.AddSimplifyDuplicate(1, bodyArray, objFromOcc, 1, occArray, "duplicate test", objDuplicate)

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally

        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

Models Collection  | Models Members