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 ObjPartDoc As SolidEdgePart.PartDocument = Nothing
Dim objSketches3d As SolidEdgePart.Sketches3D = Nothing
Dim objSketch3d As SolidEdgePart.Sketch3D = Nothing
Dim objLines3d As SolidEdgePart.Lines3D = Nothing
Dim objLine3d As SolidEdgePart.Line3D = Nothing
Dim objDimensions As SolidEdgeFrameworkSupport.Dimensions = Nothing
Dim objDimension As SolidEdgeFrameworkSupport.Dimension = Nothing
Dim objDimInitData As SolidEdgeFrameworkSupport.DimInitData = Nothing
Dim objDimPlane As SolidEdgePart.RefPlane = Nothing
Dim bIsTrueDim As Boolean = False
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"))
End If
If objApp Is Nothing Then
MessageBox.Show("Could not get application.")
End If
ObjPartDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objSketches3d = ObjPartDoc.Sketches3D
' Add new 3D skecth
objSketch3d = objSketches3d.Add()
If objSketch3d Is Nothing Then
MessageBox.Show("Failed to create sketch ")
End If
'Get Lines3D collection
objLines3d = objSketch3d.Lines3D
' Add new line
objLine3d = objLines3d.Add(-0.1, 0.03, 0.05, 0.05, 0.06, 0.07)
'Get Dimensions collection
objDimensions = objSketch3d.Dimensions
objDimInitData = objDimensions.DimInitData
objDimPlane = ObjPartDoc.RefPlanes.Item(1)
If Not objLine3d Is Nothing Then
'igDimTypeLinear - Line length
Call objDimInitData.SetType(SolidEdgeFrameworkSupport.DimTypeConstants.igDimTypeLinear)
Call objDimInitData.SetAxisMode(SolidEdgeFrameworkSupport.DimAxisModeConstants.igDimAxisModeDefault)
Call objDimInitData.ClearPlane()
Call objDimInitData.SetPlane(objDimPlane)
Call objDimInitData.SetTrue3DSketchDimension(True)
Call objDimInitData.SetNumberOfParents(1)
Call objDimInitData.SetParentByIndex(0, objLine3d, False, False, False, False, 0.0, 0.0, 0.0)
objDimension = objDimensions.AddDimension(objDimInitData)
' Create driving dimension
objDimension.Constraint = True
End If
bIsTrueDim = objDimension.True3DSketchDimension
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class