- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have something that it seems to me should work, but it still isn't working right for me yet. I am able find and isolate the trailing text after the last ">" character in the formatted text. But all my attempts to change the formatting for just that portion of the formatted text have failed so far, for some reason.
What I have found is that it is adding the extra text (formatting specifications) that I specify to the formatted text of the hole note, but so far it doesn't seem to be having any visible effect on what is being shown.
I've included several comments throughout the code, to help explain what's going on.
Here's what I've got so far:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oHoleNotes As HoleThreadNotes = oSheet.DrawingNotes.HoleThreadNotes
Dim oHN As HoleThreadNote
Dim oStr, oEndText, oOtherText, oNewEndText As String
Dim oEndPos As Integer
If oHoleNotes.Count > 0 Then
For Each oHN In oHoleNotes
oStr = oHN.FormattedHoleThreadNote
' MsgBox(oStr,,"")
' Dim oPos1 As Integer = InStr(oStr, "<", vbTextCompare)
' If oPos1 > 1 Then
' 'The "<" symbol is not the first character in the string
' 'so we can capture and highlight any text before that position
' Dim oStartText As String = oStr.Split("<").First
' End If
'check if there is any text after the last ">" character
'this counts characters from end until it finds that character
oEndPos = InStr(StrReverse(oStr), ">")
If oEndPos > 1 Then
'There is more text after the last ">" character in the string
'this splits the string into an array of sub-strings, divided by that symbol
'then gets the last sub-string in that resulting array (this works)
oEndText = oStr.Split(">").Last
'isolating the rest of the formatted text, without that last part, so it can be formatted seperately
'this doesn't modify the original, just get data from it
oOtherText = oStr.Replace(oEndText, "") '(this works too)
'create a replacement for that oEndText, that contains the special formatting
oNewEndText = "<StyleOverride Bold='True' Underline='True'>" & oEndText & "</StyleOverride>"
'set the new value of the target hole note's formatted text
oHN.FormattedHoleThreadNote = oOtherText & oNewEndText
End If
Next
End IfAlthough I have worked with FormattedText in similar ways before, I don't really consider myself to be a 'guru' in XML at this time. Maybe someone else can see what mistake I may be making in my formatting statement/text, or if what I'm trying to do here just is not possible, etc.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE'
.
Wesley Crihfield
(Not an Autodesk Employee)