Private Sub Form_Load()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Dim objProfile As SolidEdgePart.Profile
Dim objDimns As SolidEdgeFrameworkSupport.Dimensions
Dim objD1 As SolidEdgeFrameworkSupport.Dimension
Dim objLines As SolidEdgeFrameworkSupport.Lines2d
Dim objRelns As SolidEdgeFrameworkSupport.Relations2d
Dim sDumpStatus As String ' Used for temporary storage of datadump return string
' 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 an empty Profile
Set objProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:= _
objDoc.RefPlanes(1))
' Create Line objects in the Profile
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.04, y2:=0.01)
Call objLines.AddBy2Points(x1:=0.04, y1:=0.01, x2:=0.04, y2:=0.04)
Call objLines.AddBy2Points(x1:=0.04, y1:=0.04, x2:=0, y2:=0.04)
Call objLines.AddBy2Points(x1:=0, y1:=0.04, x2:=0, y2:=0)
' Relate the Lines 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(5), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(5), Index1:=igLineEnd, object2:=objLines(6), Index2:=igLineStart)
Call objRelns.AddKeypoint(Object1:=objLines(6), Index1:=igLineEnd, object2:=objLines(1), Index2:=igLineStart)
If objProfile.End(ValidationCriteria:=igProfileClosed) <> 0 Then
MsgBox ("Invalid Profile")
End If
' Creating a Dimensions Collection object
Set objDimns = objProfile.Dimensions
'Add a dimension using AddCoordinate method
Call objDimns.AddCoordinateOrigin(Object:=objLines(1), x:=0.01, y:=0, z:=0, _
keyPoint:=True)
Set objD1 = objDimns.AddCoordinate(Obj1:=objLines(3), x1:=0.01, y1:=0.01, z1:=0, keyPoint1:=True, _
Obj2:=objLines(5), x2:=0.04, y2:=0.04, z2:=0, keyPoint2:=True)
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objProfile = Nothing
Set objDimns = Nothing
Set objLines = Nothing
Set objD1 = Nothing
Set objRelns = Nothing
End Sub