VB.NET PMI EXAMPLE for adding DatumFrame on a face


I need help getting an example in How to create pmi datum frame (balloon or callout) on a face object in the 3d part env


I did a few tests and could create the balloon but NOT at...

I did a few tests and could create the balloon but NOT at the desired position, so I will leave you with the code for further investigation:

' PAR: Create a PMI balloon attached to a body face
' NOTE: the code creates the balloon but NOT at the desired position!!
Dim objDoc As PartDocument = objApp.ActiveDocument
Dim objModel As Model = objDoc.Models.Item(1)
Dim objBody As Body = objModel.Body
Dim objFaces As Faces = objBody.Faces(FeatureTopologyQueryTypeConstants.igQueryAll)
Dim objFace1 As Face = objFaces.Item(1)
' Compute the center point of the first face
Dim uvMin(1) As Double
Dim uvMax(1) As Double
objFace1.GetParamRange(uvMin, uvMax)
Dim params() As Double = {(uvMin(0) + uvMax(0)) / 2.0, (uvMin(1) + uvMax(1)) / 2.0}
Dim center(2) As Double
objFace1.GetPointAtParam(1, params, center)
Dim normal(2) As Double
objFace1.GetNormal(1, params, normal)
Dim objBalloons As Balloons = objDoc.PMI.Balloons
Dim initData As AnnotInitData = objBalloons.AnnotInitData
initData.SetConnectElement(objFace1, True, False, center(0), center(1), center(2))
'initData.SetTerminatorElement(objFace1, False, False, 0.0, 0.0, 0.0) ' causes exception during AddBalloon()
Dim objBall As Balloon = objBalloons.AddBalloon(initData)
objBall.BalloonText = "Test"
' Move the text a little bit away from the terminator
objBall.SetVertex(0, center(0), center(1), center(2))
objBall.AddVertex(center(0) + 0.1 * normal(0), center(1) + 0.1 * normal(1), center(2))
objBall.BalloonType = DimBalloonTypeConstants.igDimBalloonNone
' Setting the terminator type did not work for me...(was always created with Dot)
objBall.Style.OriginTerminatorType = DimTermTypeConstants.igDimStyleTermFilled
objBall.Style.TerminatorType = DimTermTypeConstants.igDimStyleTermFilled
objBall.Style.TerminatorDisplay = DimTermDisplayTypeConstants.igDimStyleTermBoth