Imports System.Runtime.InteropServices
Public Class DimensionAutoArrange
Private Sub btnDimensionAutoArrange_Click(sender As System.Object, e As System.EventArgs) Handles btnDimensionAutoArrange.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim ObjDraftDocument As SolidEdgeDraft.DraftDocument = Nothing
Dim objSheet As SolidEdgeDraft.Sheet = Nothing
Dim objDrawingViews As SolidEdgeDraft.DrawingViews = Nothing
Dim objDrawingView As SolidEdgeDraft.DrawingView = Nothing
Dim objType As Type = Nothing
Try
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
If objApplication Is Nothing Then
' Get the type from the Solid Edge ProgID
objType = Type.GetTypeFromProgID("SolidEdge.Application")
' Start Solid Edge
objApplication = Activator.CreateInstance(objType)
' Make Solid Edge visible
objApplication.Visible = True
End If
ObjDraftDocument = objApplication.ActiveDocument
'getting the Active Sheet object
objSheet = ObjDraftDocument.ActiveSheet
objDrawingViews = objSheet.DrawingViews
objDrawingView = objDrawingViews(1)
'Add dimensions to select set which are connected to Drawing View.
objDrawingView.AddConnectedAnnotationsToSelectSet()
'Arrange the dimensions in select set.
objSheet.ArrangeDimensionsInSelectSet(1, False)
If Not ObjDraftDocument Is Nothing Then
ObjDraftDocument.Close(False)
ObjDraftDocument = Nothing
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class