Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objProfile As SolidEdgePart.Profile
Dim objRelns As SolidEdgeFrameworkSupport.Relations2d
Dim objLines As SolidEdgeFrameworkSupport.Lines2d
Dim lngSize As Long
Dim lngStatus As Long
' 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
'Create a Profile object
Set objProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(1))
Set objLines = objProfile.Lines2d
Call objLines.AddBy2Points(x1:=0, y1:=0, x2:=0.01, y2:=0)
Call objLines.AddBy2Points(x1:=0.01, y1:=0, x2:=0.01, y2:=0.01)
Call objLines.AddBy2Points(x1:=0.01, y1:=0.01, x2:=0, y2:=0.01)
Call objLines.AddBy2Points(x1:=0, y1:=0.01, x2:=0, y2:=0)
' Define Relations among the Line objects to make the Profile closed
Set objRelns = objProfile.Relations2d
Call objRelns.AddKeypoint(Object1:=objLines(1), Index1:=igLineEnd, Object2:=objLines(2), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(2), Index1:=igLineEnd, Object2:=objLines(3), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(3), Index1:=igLineEnd, Object2:=objLines(4), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(4), Index1:=igLineEnd, Object2:=objLines(1), Index2:=igLineStart)
' Validate the Profile
lngStatus = objProfile.End(ValidationCriteria:=igProfileClosed)
If lngStatus <> 0 Then
MsgBox ("Profile Invalid")
End If
lngSize = objProfile.Size
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objProfile = Nothing
Set objRelns = Nothing
Set objLines = Nothing
End Sub