Private Sub Form_Load()
Dim objApp As SolidEdgeFrameWork.Application
Dim objDoc As SolidEdgeDraft.DraftDocument
Dim objSheet As SolidEdgeDraft.Sheet
Dim objline As SolidEdgeFrameworkSupport.Line2d
Dim objDim As SolidEdgeFrameworkSupport.Dimension
Dim ObjDimStyle As SolidEdgeFrameworkSupport.DimStyle
Dim strSecUppTol As 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.DraftDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
'getting the Active Sheet object
Set objSheet = objDoc.ActiveSheet
'create a line
Set objline = objSheet.Lines2d.AddBy2Points(x1:=0.1, y1:=0.1, x2:=0.3, y2:=0.3)
'create a dimension object
Set objDim = objSheet.Dimensions.AddLength(Object:=objline)
'get dim style of the dimension
Set ObjDimStyle = objDim.Style
'set DualDisplay property of dimstyle to true
ObjDimStyle.DualDisplay = True
'set the dimension display type to tolerance
objDim.DisplayType = igDimDisplayTypeTolerance
'Set the Primary Upper and Lower Tolerances. If the Primary tolerances are not set
'secondary tolerances are not displayed.
objDim.PrimaryUpperTolerance = "0.01"
objDim.PrimaryLowerTolerance = "0.01"
'get SecondaryUpperTolerance
strSecUppTol = objDim.SecondaryUpperTolerance
'set SecondaryUpperTolerance
objDim.SecondaryUpperTolerance = "0.04"
' USER DISPLAY
' Release objects
Set objApp = Nothing
Set objDoc = Nothing
Set objSheet = Nothing
Set objline = Nothing
Set objDim = Nothing
Set ObjDimStyle = Nothing
End Sub