Imports System.Runtime.InteropServices
Public Class AnnotAlignmentShape
Private Sub btnAnnotAlignmentShape_Click(sender As System.Object, e As System.EventArgs) Handles btnAnnotAlignmentShape.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objLine As SolidEdgeFrameworkSupport.Line2d = Nothing
Dim objCircle As SolidEdgeFrameworkSupport.Circle2d = Nothing
Dim objDraftDoc As SolidEdgeDraft.DraftDocument = Nothing
Dim objAlignmentShape As SolidEdgeFrameworkSupport.AnnotAlignmentShape = Nothing
Dim objType As Type = Nothing
Dim DrawingView As SolidEdgeDraft.DrawingView = Nothing
Dim DrawingViews As SolidEdgeDraft.DrawingViews = Nothing
Dim DrawingView1 As SolidEdgeDraft.DrawingView = Nothing
Dim balloons As SolidEdgeFrameworkSupport.Balloons = Nothing
Dim balloon As SolidEdgeFrameworkSupport.Balloon = Nothing
Dim itemNumberDir As SolidEdgeFrameworkSupport.DimItemNumDirConstants = Nothing
Dim objFirstballoon As SolidEdgeFrameworkSupport.Balloon = Nothing
Dim nIndex As Integer
Dim PointX As Double
Dim PointY As Double
Dim objSheet As SolidEdgeDraft.Sheet = Nothing
Dim objAnnotAlignmentShapes As SolidEdgeFrameworkSupport.AnnotAlignmentShapes = Nothing
Dim objAnnotAlignmentShape As SolidEdgeFrameworkSupport.AnnotAlignmentShape = Nothing
Dim dPointX(0 To 5) As Double
Dim dPointY(0 To 5) As Double
Dim bClosedAlignmentShape As Boolean
Dim bUniformSpacing As Boolean
Dim bMinimumSpacing As Boolean
Dim dMinimumSpacingValue As Double
Dim dPointX1(0 To 5) As Double
Dim dPointY1(0 To 5) As Double
Dim dPointX2(0 To 5) As Double
Dim dPointY2(0 To 5) As Double
Dim nVertexCount As Integer
Try
' Create/get the application with specific settings
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
'Get reference to active document
objDraftDoc = objApplication.ActiveDocument
'Get reference to sheet
objSheet = objDraftDoc.ActiveSheet
'Populate array for x-coordinate of points of Annotation Alignment Shape
dPointX(0) = 0.0
dPointX(1) = 0.1
dPointX(2) = 0.1
dPointX(3) = 0.0
dPointX(4) = 0.0
'Populate array for y-coordinate of points of Annotation Alignment Shape
dPointY(0) = 0.0
dPointY(1) = 0.0
dPointY(2) = 0.1
dPointY(3) = 0.1
dPointY(4) = 0.0
objAnnotAlignmentShapes = objSheet.AnnotAlignmentShapes
'Add balloon in the sheet
balloons = objSheet.Balloons
balloon = balloons.Add(0.1, 0.1, 0)
balloon.Leader = True
balloon.AddVertex(0.1, 0.1, 0)
' for AddAnnotAlignmentShape and other properties specific to alignment shapes.
objAnnotAlignmentShape = objAnnotAlignmentShapes.AddAnnotAlignmentShape(dPointX, dPointY)
Call balloon.SetAlignmentShape(objAnnotAlignmentShape, 0.05, 0.0)
Call balloon.GetAlignmentShape(objAlignmentShape, PointX, PointY)
'TRUE If the Annotation Alignment Shape is closed
bClosedAlignmentShape = objAnnotAlignmentShape.ClosedAlignmentShape
'Set value for Uniform Spacing
objAnnotAlignmentShape.UniformSpacing = True
bUniformSpacing = objAnnotAlignmentShape.UniformSpacing
objAnnotAlignmentShape.MinimumSpacing = True
bMinimumSpacing = objAnnotAlignmentShape.MinimumSpacing
'Set value for Minimum Spacing
objAnnotAlignmentShape.MinimumSpacingValue = 0.05
dMinimumSpacingValue = objAnnotAlignmentShape.MinimumSpacingValue
'Get X and Y coordinates of Annotation Alignment Shape
objAnnotAlignmentShape.GetGeometry(dPointX1, dPointY1)
'Get Number of vertes of Annotation Alignment Shape
nVertexCount = objAnnotAlignmentShape.VertexCount
'Insert vertex point in Annotation Alignment Shape
objAnnotAlignmentShape.InsertVertex(0.05, 0.0)
'Remove vertex point from Annotation Alignment Shape
objAnnotAlignmentShape.RemoveVertex(2)
'Modify vertex point from Annotation Alignment Shape
objAnnotAlignmentShape.ModifyVertex(1, 0.1, 0.0)
balloons = objSheet.Balloons
DrawingViews = objSheet.DrawingViews
objAnnotAlignmentShapes = objSheet.AnnotAlignmentShapes
DrawingView = DrawingViews.Item(1)
objAnnotAlignmentShape = objAnnotAlignmentShapes.Item(1)
DrawingView1 = objAnnotAlignmentShape.DrawingView
'Set and get item number direction
objAnnotAlignmentShape.ItemNumberDirection = SolidEdgeFrameworkSupport.DimItemNumDirConstants.igDimItemNumberDirectionClockwise
itemNumberDir = objAnnotAlignmentShape.ItemNumberDirection
' Set and get first balloon
objFirstballoon = objAnnotAlignmentShape.FirstBalloon
nIndex = objFirstballoon.Index
objAnnotAlignmentShape.FirstBalloon = balloons.Item(2)
'Dim DrawingView1 As SolidEdgeDraft.DrawingView
objSheet = objDraftDoc.ActiveSheet
DrawingViews = objSheet.DrawingViews
DrawingView = DrawingViews.Item(1)
' for set and get alignment drawing view
objAnnotAlignmentShape.DrawingView = DrawingView
DrawingView1 = objAnnotAlignmentShape.DrawingView
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class