iLogic general notes in one text box multiple text heights

iLogic general notes in one text box multiple text heights

Anonymous
Not applicable
2,023 Views
6 Replies
Message 1 of 7

iLogic general notes in one text box multiple text heights

Anonymous
Not applicable

Hi, 

 

I've been trying to figure out how to take the standard ilogic script for "add a general note" in the inventor help section and modify it so it will produce all the text in one text box as well as different height text for the title. Is this possible?

 

Script i'm trying to modify below:

 

Public Sub SheetTextAdd()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    ' Set a reference to the active sheet.
    Dim oActiveSheet As Sheet
    Set oActiveSheet = oDrawDoc.ActiveSheet
    
    ' Set a reference to the GeneralNotes object
    Dim oGeneralNotes As GeneralNotes
    Set oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
    
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    ' Create text with simple string as input. Since this doesn't use
    ' any text overrides, it will default to the active text style.
    Dim sText As String
    sText = "Drawing Notes"
    
    Dim oGeneralNote As GeneralNote
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 18), sText)

    ' Create text using various overrides.
    sText = "Notice: All holes larger than 0.500 n are to be lubricated."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 16), sText)

    ' Create a set of notes that are numbered and aligned along the left.
    Dim dYCoord As Double
    dYCoord = 14
    Dim dYOffset As Double
    Dim oStyle As TextStyle
    Set oStyle = oGeneralNotes.Item(1).TextStyle
    dYOffset = oStyle.FontSize * 1.5

    ' Simple single line text.
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "1.")
    sText = "This is note 1."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

    ' Two line text. The two lines are defined using the  tag within the text string.
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + 0.5)
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "2.")
    sText = "This is note 2,  which contains two lines."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

    ' Single line of text.
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + 0.5)
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "3.")
    sText = "This is note 3."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

    ' Three lines of text.
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + 0.5)
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "4.")
    sText = "This is note 4,  which contains  several lines."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + 0.5)
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "5.")
    
    sText = "Here is the last and final line of text."
    Set oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)
End Sub

 

Cheers

0 Likes
2,024 Views
6 Replies
Replies (6)
Message 2 of 7

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous 

 

Welcome to the forum.

 

You'll want to use formatted text to do this, here's an example, and another rule you can use to see the text formatting.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

creates 3 lines of different font size

' a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet

' a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry


oText1 = "Drawing Notes"
oFontSize1 = .1 *2.54 '2.54 coverts to inches
oText2 = "Some text"
oFontSize2 = .2 *2.54 '2.54 coverts to inches
oText3 = "Some more text"
oFontSize3 = .3 *2.54 '2.54 coverts to inches

Dim sFormattedText As String
sFormattedText = _
"<StyleOverride FontSize ='" & oFontSize1 & "'>" & oText1 & "</StyleOverride><Br/>" & _
"<StyleOverride FontSize ='" & oFontSize2 & "'>" & oText2 & "</StyleOverride><Br/>" & _
"<StyleOverride FontSize ='" & oFontSize3 & "'>" & oText3 & "</StyleOverride><Br/>"

oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 16), sFormattedText)

 

 

utility rule that will show you the formatting for the first general note on the sheet

' a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet

' a reference to the GeneralNotes object
Dim oGeneralNotes As GeneralNotes
oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes

oFormattedText = oGeneralNotes.Item(1).FormattedText

InputBox("Here is the formatted text for the 1st note on this sheet" _
& vbLf & vbLf & "Copy and paste it to examine the syntax", "iLogic", oFormattedText)

 

EESignature

Message 3 of 7

WCrihfield
Mentor
Mentor

Thanks @Curtis_Waguespack .  Do you know of any good references for all the available possibilities of the coding used within FormattedText.  I've done a little with it before, but only using what few code snippets I've seen other use here in the forums.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 7

Curtis_Waguespack
Consultant
Consultant

Hi @WCrihfield 

 

Unfortunately, I don't know of a good reference...  typically I'll create an example of the text I want to automate and then retrieve the formatting syntax using a rule like the second example above, and then sort of reverse engineer it.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor

@Curtis_Waguespack  It kind of looks like HTML.  Do you know if that is what it is?  If so, that would make it simpler to research, since there are tons of HTML resources online.

I've searched through several items within the online help for the Programming Interface, but in every instance where FormattedText is mentioned, I don't see any reference to where they are getting the formatting code they are using, or what type of coding it is.  It seems this something that should be addressed in future online help publishings.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

Curtis_Waguespack
Consultant
Consultant

Hi @WCrihfield,

 

Indeed it looks to be very much HTML based... Inventor might be handling some of it a bit differently than other html editors that I've used.... so I'm not sure that it's a 1 to 1 comparison... but I've not really ever paid that much attention to it.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

FYI

@Curtis_Waguespack  I asked MjDeck (Mike Deck) about it, and he said it is XML and gave me a link.  Here's the link.

https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1 

This explains it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)