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
Dim objBaseProfile As SolidEdgePart.Profile
Dim objBaseProfileArray(0 To 2) As SolidEdgePart.Profile
Dim objBaseModel As SolidEdgePart.Model
Try
'Get Application object
objApp = Marshal.GetActiveObject("SolidEdge.Application")
'Add Part document
objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
'Get the PMI object from the document
objPMI = Nothing
objDoc.PMI_ByModelState(objPMI)
'Get the dimensions collection from the PMI object
objBalloons = objPMI.Balloons
' *** Creating the base feature
' Creating the profile for the base feature and validating it
objBaseProfile = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(1))
Call objBaseProfile.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.025)
objBaseProfile.Visible = False
' Creating the base extruded protrusion and validating it
objBaseProfileArray(0) = objBaseProfile
objBaseModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _
ProfileArray:=objBaseProfileArray, ProfilePlaneSide:=SolidEdgePart.FeaturePropertyConstants.igSymmetric, ExtrusionDistance:=0.1)
'get the edge, get the end points and then transform them into assembly space
'Create a reference (membassy) the edge
objEdges = objDoc.Models.Item(1).ExtrudedProtrusions.Item(1).Edges(SolidEdgeConstants.FeatureTopologyQueryTypeConstants.igQueryAll)
objEdge1 = objEdges.Item(1)
'objRefPlanes = objDoc.RefPlanes
objAnnotPlane = objDoc.RefPlanes.Item(1)
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.SetTerminatorElementEx(objEdge1, False, 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 = False
objBalloon.BalloonType = SolidEdgeConstants.DimBalloonTypeConstants.igDimBalloonOval
objBalloon.BalloonText = "123"
objBalloon.Leader = True
objBalloon.BreakLine = True
Dim obj1 As Object = Nothing
Dim dblX, dblY, dblZ As Double
Dim bool1 As Boolean
objBalloon.GetTerminator(obj1, dblX, dblY, dblZ, bool1)
Catch ex As Exception
MsgBox(ex.ToString)
Clipboard.SetText(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