Solid Edge Part Type Library
Item Method
Variant (input) index.
Description
The items in a collection.
Syntax
Visual Basic
Public Function Item( _
   ByVal Index As Variant _
) As Draft
Parameters
Index
Variant (input) index.
Example
Private Sub Form_Load()
    Dim objApp As SolidEdgeFramework.Application
    Dim objDoc As SolidEdgePart.PartDocument
    Dim objProfArr(1 To 2) As SolidEdgePart.Profile
    Dim objModel As SolidEdgePart.Model
    Dim objLines As SolidEdgeFrameworkSupport.Lines2d
    Dim objRelns1 As SolidEdgeFrameworkSupport.Relations2d
    Dim objDrfts As SolidEdgePart.Drafts
    Dim ObjFaceArr(1 To 4) As Object
    Dim objFaces As Object
    Dim objDftPln As SolidEdgePart.RefPlane
    Dim objDft1 As SolidEdgePart.Draft
    Dim objDft2 As SolidEdgePart.Draft
    Dim lngStatus As Long
    Dim dblAngArr(1 To 4) As Double
    ' Report errors
    Const PI = 3.14159265358979
    ' Create/get the application with specific settings
    On Error Resume Next
    Set objApp = GetObject(, "SolidEdge.Application")
    If Err Then
        Err.Clear
        Set objApp = CreateObject("SolidEdge.Application")
        Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
        objApp.Visible = True
    Else
        Set objDoc = objApp.ActiveDocument
    End If
    ' Draw the Profile
    Set objProfArr(1) = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(1))
    Set objLines = objProfArr(1).Lines2d
    Call objLines.AddBy2Points(x1:=0, y1:=0, x2:=0.06, y2:=0)
    Call objLines.AddBy2Points(x1:=0.06, y1:=0, x2:=0.06, y2:=0.06)
    Call objLines.AddBy2Points(x1:=0.06, y1:=0.06, x2:=0, y2:=0.06)
    Call objLines.AddBy2Points(x1:=0, y1:=0.06, x2:=0, y2:=0)
    ' Relate the Lines to make the Profile closed
    Set objRelns1 = objProfArr(1).Relations2d
    Call objRelns1.AddKeypoint(Object1:=objLines(1), Index1:=igLineEnd, Object2:=objLines(2), Index2:=igLineStart)
    Call objRelns1.AddKeypoint(Object1:=objLines(2), Index1:=igLineEnd, Object2:=objLines(3), Index2:=igLineStart)
    Call objRelns1.AddKeypoint(Object1:=objLines(3), Index1:=igLineEnd, Object2:=objLines(4), Index2:=igLineStart)
    Call objRelns1.AddKeypoint(Object1:=objLines(4), Index1:=igLineEnd, Object2:=objLines(1), Index2:=igLineStart)
    ' Check for the Profile Validity
    lngStatus = objProfArr(1).End(ValidationCriteria:=igProfileClosed)
    If lngStatus <> 0 Then
        MsgBox ("Profile not closed")
    End If
    ' Create the Base Protrusion Object
    Set objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _
                                                             ProfileArray:=objProfArr, profileplaneSide:=igRight, _
                                                             ExtrusionDistance:=0.02)
    objProfArr(1).Visible = False
    ' Check the status of Base Feature
    If objModel.ExtrudedProtrusions(1).Status <> igFeatureOK Then
        MsgBox ("Error in the Creation of Base Protrusion Feature object")
    End If
    ' Create an Array of Faces and DraftPlane
    Set objDftPln = objDoc.RefPlanes(1)
    Set objFaces = objModel.ExtrudedProtrusions(1).SideFaces
    Set ObjFaceArr(1) = objFaces(1)
    Set ObjFaceArr(2) = objFaces(2)
    Set ObjFaceArr(3) = objFaces(3)
    Set ObjFaceArr(4) = objFaces(4)
    ' Create the Draft Angle Array
    dblAngArr(1) = 45 * (PI) / 180
    dblAngArr(2) = 45 * (PI) / 180
    dblAngArr(3) = 45 * (PI) / 180
    dblAngArr(4) = 45 * (PI) / 180
    ' Create a Draft collection object
    Set objDrfts = objModel.Drafts
    ' Create a Draft
    Set objDft1 = objDrfts.Add(DraftPlane:=objDftPln, NumberOfFaceSets:=4, _
                               FaceSetArray:=ObjFaceArr, _
                               DraftAngleArray:=dblAngArr, _
                               DraftSide:=igOutside)
    ' Check the status of Base Feature
    If objDft1.Status <> igFeatureOK Then
        MsgBox ("Add method of Drafts object failed")
    End If
    ' Assign the Draft object to another object usig Item method
    Set objDft2 = objDrfts.Item(1)
    ' Release objects
    Set objApp = Nothing
    Set objDoc = Nothing
    Set objModel = Nothing
    Set objRelns1 = Nothing
    Set objLines = Nothing
    Set objProfArr(2) = Nothing
    Set objProfArr(1) = Nothing
    Set objDrfts = Nothing
    Set objDft1 = Nothing
    Set objDft2 = Nothing
    Set objDftPln = Nothing
    Set ObjFaceArr(1) = Nothing
    Set ObjFaceArr(2) = Nothing
    Set ObjFaceArr(3) = Nothing
    Set ObjFaceArr(4) = Nothing
    Set objFaces = Nothing
End Sub
See Also

Drafts Collection  | Drafts Members

Send comments on this topic.