Replace text

Good morning

I need to replace a chain of a few texts and annotation points.

I have the following texts and points:


Where XXXXXX are numbers different in each case.

I need to change both the texts and points: A-TG-H - by of B-YH-J-
that everything stays as it is: B-YH-J-XXXXXXXX

But I can’t find option to replace in Rhino v5.

Can you help me?
Thank you!

FindText is what you are looking for.
It will select all instances or one-by-one.
If you want to apply some sort of process automation I’d recommend Grasshopper.


there is a script writen by @dale , it runs in V5 i used it a while ago. Runing it was a bit hard for me but i will share how i made it run (not sure if its the easy way)

1- copy the text from site
2- create a text file then open it > paste what you have copied from the site > save (i named my file as β€œreplacetext.rvb”)
3- open rhino
4-type "loadscript"
5- click "Add"
6- Find your replacetext.rvb file and sellect it. in the same window click β€œLoad” then "Close"
7- type β€œRunscript” in the new window sellect replacetext script and click "OK"
8- it will ask you what to search for and what to replace with and if the search is case sensitive.


It works only with the text, but ir doesn’t work with the annotation points.

Thanks for your help!

then i dont know who wrote that script :wink:
maybe someone can tweak it.

Option Explicit

’ ReplaceText.rvb – August 2011
’ If this code works, it was written by Dale Fugier.
’ If not, I don’t know who wrote it.
’ Works with Rhino 4.0.

’ Replaces text
Sub ReplaceText

Const RH_TEXTDOT = 8192

Dim arrObjects, strObject
Dim strOldText, strNewText, strFind, strReplace 
Dim strTitle, nCompare, nCount

strTitle = "Replace Text"
nCount = 0

arrObjects = Rhino.ObjectsByType(RH_ANNOTATION + RH_TEXTDOT)
If IsNull(arrObjects) Then
	Call Rhino.Print("No text objects found.")
	Exit Sub
End If

strFind = Rhino.StringBox("Text string to find:",, strTitle)
If IsNull(strFind) Then Exit Sub

strReplace = Rhino.StringBox("Text string to replace with:",, strTitle)
If IsNull(strReplace) Then Exit Sub

nCompare = MsgBox("Perform case-sensitive replacement?", vbYesNoCancel + vbQuestion, strTitle)
If (nCompare = vbYes) Then
	nCompare = vbBinaryCompare
ElseIf (nCompare = vbNo) Then
	nCompare = vbTextCompare
	Exit Sub
End If

If (StrComp(strFind, strReplace, nCompare) = 0) Then Exit Sub

Call Rhino.EnableRedraw(False)
For Each strObject In arrObjects
	If Rhino.IsText(strObject) Then
		strOldText = Rhino.TextObjectText(strObject)
		strNewText = Replace(strOldText, strFind, strReplace, 1, -1, nCompare)
		If (StrComp(strOldText, strNewText, nCompare) <> 0) Then
			Call Rhino.TextObjectText(strObject, strNewText)
			nCount = nCount + 1
		End If
	End If
	If Rhino.IsTextDot(strObject) Then
		strOldText = Rhino.TextDotText(strObject)
		strNewText = Replace(strOldText, strFind, strReplace, 1, -1, nCompare)
		If (StrComp(strOldText, strNewText, nCompare) <> 0) Then
			Call Rhino.TextDotText(strObject, strNewText)
			nCount = nCount + 1
		End If
	End If

Call Rhino.EnableRedraw(True)

Call Rhino.Print(CStr(nCount) & " text object(s) modified.")

End Sub

1 Like

dalechangetextscriptwithtextdot.rvb (2.1 KB)

1 Like

It Works!


can anyone implement. the star β€œ*” feature. what i mean;

search for is β€œXYZ*” script finds XYZ1, XYZ2, XYZ3 … and replaces everthing with what is wanted.


edit: and to be able to replace with nothing, erasing