Message 1 of 2
Changing Text Style when adding text with Ilogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a modified code for adding text to a drawing through ilogic. The only problem is that I want to be able to change text styles with it. That way some notes can be larger when necessary. I can go through and set the text style in the text style manager I think, but for some reason when I tell it to add text it adds it with the standard no matter what style I pass to it.
Thank you all in advance and below is the code.
'Creates Text at the specified point (using the drawing scale, not view scale) '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Function CreateText (oDrawingDoc As DrawingDocument, oText As String, OffsetDistanceX As Double, OffsetDistanceY As Double, Alignment As String, Style As String) 'Declaring Variables '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Dim oSheet As Sheet Dim oTG As TransientGeometry Dim oPoint1 As Point2d Dim TextPoint As Point2d Dim TextWidth As Double Dim oStylesMgr As DrawingStylesManager Dim oTextStyle As TextStyle '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Setting Text Style '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oStylesMgr = oDrawingDoc.StylesManager oTextStyle = oStylesMgr.TextStyles.Item(Style) 'Set the sheet and create the geometry for insertion '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oSheet = oDrawingDoc.Sheets.Item(1) oTG = ThisApplication.TransientGeometry TextPoint = oTG.CreatePoint2d(OffsetDistanceX, OffsetDistanceY) '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Creating category for text '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Dim oGeneralNotes As GeneralNotes oGeneralNotes = oSheet.DrawingNotes.GeneralNotes '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Creating text '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Dim oGeneralNote As GeneralNote oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(5, 5), oText) '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Get the Lengths of the Text '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ TextWidth = oGeneralNote.Width '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'This will align the text as specified '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ If Alignment = "Left" TextPoint.x = OffsetDistanceX Else If Alignment = "Center" TextPoint.x = OffsetDistanceX - TextWidth/2 Else If Alignment = "Right" TextPoint.x = OffsetDistanceX - TextWidth End If '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'This will place the text at the OffsetDistance Vertically '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ TextPoint.y = OffsetDistanceY '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 'Moving text to specified position '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ oGeneralNote.Position = TextPoint '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ End Function '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\