Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objDoc As SolidEdgeDraft.DraftDocument = Nothing
Dim objSheet As SolidEdgeDraft.Sheet = Nothing
Dim objSheets As SolidEdgeDraft.Sheets = Nothing
Dim objDimensions As SolidEdgeFrameworkSupport.Dimensions = Nothing
Dim objHzDim As SolidEdgeFrameworkSupport.Dimension = Nothing
Dim objLines As SolidEdgeFrameworkSupport.Lines2d = Nothing
Dim objHzLine As SolidEdgeFrameworkSupport.Line2d = Nothing
Dim strComment As String
Try
' Create/get the application with specific settings
objApp = Marshal.GetActiveObject("SolidEdge.Application")
If objApp Is Nothing Then
objApp = Activator.CreateInstance(Type.GetTypeFromProgID("SolidEdge.Application"))
objApp.Visible = True
End If
objDoc = objApp.Documents.Add("SolidEdge.DraftDocument")
'Get the sheets collection
objSheets = objDoc.Sheets
'Get the active sheet
objSheet = objDoc.ActiveSheet
'Get the lines collection and dimensions collection.
objLines = objSheet.Lines2d
objDimensions = objSheet.Dimensions
'Add a horizontal line and a vertical line
objHzLine = objLines.AddBy2Points(x1:=0.2, y1:=0.2, x2:=0.3, y2:=0.2)
'Add dimensions to the lines that are created above.
objHzDim = objDimensions.AddLength(Object:=objHzLine)
'set the Comment
objHzDim.SetComment("LineLength")
'get the comment
strComment = objHzDim.GetComment
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class