Sorry,
I posted to early, got it working, it was just a setting in the styles.
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'set whether to define the balloon size by text height
oBalloon.Style.ScaleToTextHeight = False
oBalloon.Style.StretchBalloonToText = False
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
also I found another way around it by using sketched symbols with prompted entries.
Please see code below if you're interested.
Thanks
Paul
Public Sub AttachLeaderTextToBalloon(oBalloon As Inventor.Balloon, ByVal Position As String, _
ByVal LeaderText As String, ByVal BalloonNumberId As Integer, _
Optional ByVal AddAttribute As Boolean = False)
'Adds a Leader Text To A Balloon, Balloon To Be Parsed From The Call
'Along With The Positiion And The Text Value.
'Dim oApp = ThisApplication
'Ref This Document (The Active Document)
Dim oDrawingDocument As Inventor.DrawingDocument
oDrawingDocument = oApp.ActiveDocument
'Ref The Sheet (The Active Document Sheet)
Dim oSheet As Inventor.Sheet
oSheet = oDrawingDocument.ActiveSheet
Dim dBalloonDiameter As Double
dBalloonDiameter = oBalloon.Style.BalloonDiameter
'set whether to define the balloon size by text height
oBalloon.Style.ScaleToTextHeight = False
oBalloon.Style.StretchBalloonToText = False
'Variables For The Balloon Positio
Dim dBalloonPositionX As Double = Nothing
Dim dBalloonPositionY As Double = Nothing
' Create Leader Points And Geometry Intent From Balloon.
Select Case Position
Case 0 ' Bottom Center (6 O'clock)
dBalloonPositionX = oBalloon.Position.X
dBalloonPositionY = oBalloon.Position.Y - (dBalloonDiameter / 2)
Case 90 ' Mid Left (9 O'clock)
dBalloonPositionX = oBalloon.Position.X - (dBalloonDiameter / 2)
dBalloonPositionY = oBalloon.Position.Y
Case 180 ' Mid Right (9 O'clock)
dBalloonPositionX = oBalloon.Position.X
dBalloonPositionY = oBalloon.Position.Y + (dBalloonDiameter / 2)
Case 270 ' Top Center (12 O'clock)
dBalloonPositionX = oBalloon.Position.X + (dBalloonDiameter / 2)
dBalloonPositionY = oBalloon.Position.Y
End Select
'Set Transient Geometry for This Application
Dim oTG As TransientGeometry = oApp.TransientGeometry
'Leader Point On Circumference Of Balloon
Dim oPtItent As Point2d = Nothing
' Add the GeometryIntent to the leader points collection.
' This is the geometry that the balloon will attach to.
Dim oBalloonIntent As GeometryIntent
oPtItent = (oTG.CreatePoint2d(dBalloonPositionX, dBalloonPositionY))
oBalloonIntent = oSheet.CreateGeometryIntent(oBalloon, oPtItent)
'Set Leader Point Positions
Dim oLeaderPoints As ObjectCollection = oApp.TransientObjects.CreateObjectCollection
oLeaderPoints.Add(oTG.CreatePoint2d(dBalloonPositionX, dBalloonPositionY))
oLeaderPoints.Add(oBalloonIntent)
'Add Leader Text To Balloon (Currently The Text Does Not Move With The Balloon, Requires More Work)
Dim oLeaderText As LeaderNote = oSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, LeaderText)
' Align The Text Correctly Dependant On Balloon Position.
Select Case Position
Case 0 ' Bottom Center (6 O'clock)
'Align The Text To The Bottom/Center
oLeaderText.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
oLeaderText.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextUpper
Case 90 ' Mid Left (9 O'clock)
'Align The Text To The Right
oLeaderText.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextRight
Case 180 ' Mid Right (9 O'clock)
'Align The Text To The Top/Center
oLeaderText.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextCenter
oLeaderText.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextLower
Case 270 ' Top Center (12 O'clock)
'Align The Text To The Left
oLeaderText.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
End Select
'Add Attributes To Sketched Symbol
If AddAttribute = True Then
'The Following Code Adds The LeaderText Which Has Just Been Created "oLeaderText"
'To A Attribute Set Called "oLeaderTextToDelete" This Then Enables The Dim "oLeaderText"
'To Be Identified And Deleted If Needed.
' Add the attributes to the Dimension which has just been added
Dim attbSets As AttributeSets = oLeaderText.AttributeSets
'Checks If Attribute Set Already Exists
If Not attbSets.NameIsUsed("oLeaderTextToDelete") Then
'Creates Attribute Set
Dim attbSet As AttributeSet = attbSets.Add("oLeaderTextToDelete")
'Adds Attribute And Value To "oLeaderTextToDelete"
Dim attb As Inventor.Attribute = _
attbSet.Add("oLeaderTextGroup1", ValueTypeEnum.kStringType, BalloonNumberId)
End If
End If
End Sub
Code for Sketched Symbol:
Public Sub AttachSketchedSymbolToBalloon(oBalloon As Inventor.Balloon, ByVal SketchedSymbolName As String, _
ByVal Position As String, ByVal PromtedTextLine1 As String, _
ByVal BalloonNumberId As Integer, Optional ByVal AddAttribute As Boolean = False)
'Adds a Sketched Symbol To A Balloon, Ballon To Be Parsed From The Call
'Along With The Positiion And The Text Value.
'Dim oApp = ThisApplication
'Ref This Document (The Active Document)
Dim oDrawingDocument As Inventor.DrawingDocument
oDrawingDocument = oApp.ActiveDocument
'Ref The Sheet (The Active Document Sheet)
Dim oSheet As Inventor.Sheet
oSheet = oDrawingDocument.ActiveSheet
Dim dBalloonDiameter As Double
dBalloonDiameter = oBalloon.Style.BalloonDiameter
'set whether to define the balloon size by text height
oBalloon.Style.ScaleToTextHeight = False
oBalloon.Style.StretchBalloonToText = False
'Variables For The Balloon Positio
Dim dBalloonPositionX As Double = Nothing
Dim dBalloonPositionY As Double = Nothing
' Create Leader Points And Geometry Intent From Balloon.
Select Case Position
Case 0 ' Bottom Center (6 O'clock)
dBalloonPositionX = oBalloon.Position.X
dBalloonPositionY = oBalloon.Position.Y - (dBalloonDiameter / 2)
Case 90 ' Mid Left (9 O'clock)
dBalloonPositionX = oBalloon.Position.X - (dBalloonDiameter / 2)
dBalloonPositionY = oBalloon.Position.Y
Case 180 ' Mid Right (9 O'clock)
dBalloonPositionX = oBalloon.Position.X
dBalloonPositionY = oBalloon.Position.Y + (dBalloonDiameter / 2)
Case 270 ' Top Center (12 O'clock)
dBalloonPositionX = oBalloon.Position.X + (dBalloonDiameter / 2)
dBalloonPositionY = oBalloon.Position.Y
End Select
'Set Transient Geometry for This Application
Dim oTG As TransientGeometry = oApp.TransientGeometry
'Leader Point On Circumference Of Balloon
Dim oPtItent As Point2d = Nothing
' Add the GeometryIntent to the leader points collection.
' This is the geometry that the balloon will attach to.
Dim oBalloonIntent As GeometryIntent
oPtItent = (oTG.CreatePoint2d(dBalloonPositionX, dBalloonPositionY))
oBalloonIntent = oSheet.CreateGeometryIntent(oBalloon, oPtItent)
'Set Leader Point Positions
Dim oLeaderPoints As ObjectCollection = oApp.TransientObjects.CreateObjectCollection
oLeaderPoints.Add(oTG.CreatePoint2d(dBalloonPositionX, dBalloonPositionY))
oLeaderPoints.Add(oBalloonIntent)
' Get the first symbol definition, Symbol can be named as a string
Dim oSketchSymbol As SketchedSymbolDefinition = oDrawingDocument.SketchedSymbolDefinitions(SketchedSymbolName)
' This sketched symbol definition contains two prompted string inputs. An array
' must be input that contains the strings for the prompted strings.
Dim sPromptStrings(0) As String
'Weld Size
sPromptStrings(0) = PromtedTextLine1
' Create the symbol with a leader
Dim oSketchedSymbol As SketchedSymbol
oSketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSketchSymbol, oLeaderPoints, 0.0, 1, sPromptStrings)
'set whether to define the balloon size by text height
oBalloon.Style.StretchBalloonToText = True
'Add Attributes To Sketched Symbol
If AddAttribute = True Then
'The Following Code Adds The SketchedSymbol Which Has Just Been Created "oSketchedSymbol"
'To A Attribute Set Called "oSketchedSymbolToDelete" This Then Enables The Dim "oSketchedSymbol"
'To Be Identified And Deleted If Needed.
' Add the attributes to the Dimension which has just been added
Dim attbSets As AttributeSets = oSketchedSymbol.AttributeSets
'Checks If Attribute Set Already Exists
If Not attbSets.NameIsUsed("oSketchedSymbolToDelete") Then
'Creates Attribute Set
Dim attbSet As AttributeSet = attbSets.Add("oSketchedSymbolToDelete")
'Adds Attribute And Value To "oSketchedSymbol"
Dim attb As Inventor.Attribute = _
attbSet.Add( _
"oSketchedSymbolGroup1", ValueTypeEnum.kStringType, BalloonNumberId)
End If
End If
End Sub