Imports System.IO
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
Dim objDoc As SolidEdgePart.PartDocument
Dim objBalloons As SolidEdgeFrameworkSupport.Balloons
Dim objBalloon As SolidEdgeFrameworkSupport.Balloon
Dim objPMI As SolidEdgeFrameworkSupport.PMI
Dim objEdges As SolidEdgeGeometry.Edges
Dim objEdge1 As SolidEdgeGeometry.Edge
Dim objRefPlanes As SolidEdgePart.RefPlanes
Dim objAnnotPlane As SolidEdgePart.RefPlane
Dim objAnnotInitData As SolidEdgeFrameworkSupport.AnnotInitData
Dim dblStartPoint() As Double
Dim dblEndPoint() As Double
Try
'Get Application object
objApp = Marshal.GetActiveObject("SolidEdge.Application")
'Get Part document containing an extruded part(Ex:- Cube)
objDoc = objApp.ActiveDocument
'Get the PMI object from the document
objPMI = Nothing
objDoc.PMI_ByModelState(objPMI)
'Get the balloon collection from the PMI object
objBalloons = objPMI.Balloons
'get the edge
objEdges = objDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Edges(SolidEdgeConstants.FeatureTopologyQueryTypeConstants.igQueryAll)
objEdge1 = objEdges.Item(1)
objAnnotPlane = objDoc.RefPlanes.Item(4)
objAnnotInitData = objBalloons.AnnotInitData
dblStartPoint = {0.0}
dblEndPoint = {0.0}
objEdge1.GetEndPoints(StartPoint:=dblStartPoint, EndPoint:=dblEndPoint)
'create balloon with terminator element.
Call objAnnotInitData.ClearTerminatorElement()
Call objAnnotInitData.SetPlane(objAnnotPlane)
Call objAnnotInitData.SetTerminatorElement(objEdge1, False, True, dblStartPoint(0), dblStartPoint(1), dblStartPoint(2))
objBalloon = objBalloons.AddBalloon(AnnotInitData:=objAnnotInitData)
Call objBalloon.AddVertex(x:=0.04, y:=0.05, z:=0.005)
objBalloon.Callout = True
objBalloon.BalloonText = "123"
objBalloon.Leader = True
objBalloon.CalloutParallel = True
objBalloon.BreakLine = True
Catch ex As Exception
MsgBox(ex.ToString)
objApp = Nothing
objDoc = Nothing
objBalloons = Nothing
objBalloon = Nothing
objPMI = Nothing
objEdges = Nothing
objEdge1 = Nothing
objRefPlanes = Nothing
objAnnotPlane = Nothing
objAnnotInitData = Nothing
If Not objDoc Is Nothing Then
objDoc.Close(False)
objDoc = Nothing
End If
End Try
End Sub
End Class