Replace text in dimensions in the drawing (holes, welds)

Replace text in dimensions in the drawing (holes, welds)

pavol_krasnansky
Enthusiast Enthusiast
282 Views
2 Replies
Message 1 of 3

Replace text in dimensions in the drawing (holes, welds)

pavol_krasnansky
Enthusiast
Enthusiast

Hello.
1. question
I have the below code for replace text in an HoleThreadNote. Replace of the text "PRIEBEŽNE" to "Through" works fine. Replace of the text "HĹBKA" to "Depth" does not work. It is the same. Where is the problem?
2. question
Is it also possible to replace the text in the welding note?
Thank you

 

Sub Main()
	Dim oDoc As Document
	oDoc = ThisDoc.Document
	If oDoc.DocumentType = kDrawingDocumentObject Then
		Dim oDrawDoc As DrawingDocument
		oDrawDoc = ThisDoc.Document
		Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager
		Dim oDimStyle As DimensionStyle
		oDimStyle = oStylesMgr.DimensionStyles.Item("Name_Of_Your_DimensionStyle")
		Dim oSheet As Sheet	
		For Each oSheet In oDrawDoc.Sheets
			oSheet.Activate
			For Each oHoleThreadNote As HoleThreadNote In oSheet.DrawingNotes.HoleThreadNotes
				oHoleThreadNote.FormattedHoleThreadNote = oHoleThreadNote.FormattedHoleThreadNote.Replace("PRIEBEŽNE", "Through") ' It is OK
				oHoleThreadNote.FormattedHoleThreadNote = oHoleThreadNote.FormattedHoleThreadNote.Replace("HĹBKA", "Depth") ' It is NOT OK
				oHoleThreadNote.Style = oDimStyle
			Next
		Next
		oDrawDoc.Update()
	End If
End Sub
0 Likes
283 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor

For me everything works as expected. 

But you can try to use RegEx.Replace instead of String.Replace and try to omit 'Ĺ' from check. 

'oHoleThreadNote.FormattedHoleThreadNote = oHoleThreadNote.FormattedHoleThreadNote.Replace("HĹBKA", "Depth") ' It is NOT OK
oHoleThreadNote.FormattedHoleThreadNote = System.Text.RegularExpressions.Regex.Replace(oHoleThreadNote.FormattedHoleThreadNote, "H.BKA","Depth")

 

Message 3 of 3

pavol_krasnansky
Enthusiast
Enthusiast

Thank you, but that didn't help me. The same problem is also with:

oHoleThreadNote.FormattedHoleThreadNote = oHoleThreadNote.FormattedHoleThreadNote.

0 Likes