Author Topic: Search text field  (Read 222 times)

badboi

  • Newbie
  • *
  • Posts: 21
    • View Profile
Search text field
« on: August 28, 2011, 08:32:21 PM »
Is there a way to search for text fields in rhino and zoom to them?  For example, if there is a text in my drawing, I want to search for it and have my screen zoom in.

thanks,

ledisnomad

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Search text field
« Reply #1 on: September 01, 2011, 06:52:12 AM »
Hi, badboi.

This was a perfect little task for a Rhinoscript. See if this works for you:

Code: [Select]
Option Explicit
'Script written by Damon Sidel
'Script copyrighted by Damon Sidel
'Script version Thursday, September 01, 2011 8:36:04 AM

Call ZoomToText()
Sub ZoomToText()

Call Rhino.Command("_SelAll")
Dim arrObj : arrObj = Rhino.SelectedObjects()
If IsNull(arrObj) Then Exit Sub

Call Rhino.Command("_SelNone")

Dim strObj, done
'Dim arrOpts : arrOpts = Array("Yes", "No")
'Dim arrVals : arrVals = Array(True, False)
For Each strObj In arrObj

If IsText(strObj) Then
Call Rhino.SelectObject(strObj)
Call Rhino.ZoomSelected()
End If

done = Rhino.GetString("Is this the text at which you want to look? (Type 'y' or hit enter to continue.)")
If (done="y") Then Exit Sub
'done = Rhino.GetBoolean("Is this the text at which you want to look?",arrOpts,arrVals)
'If (done=True) Then Exit Sub
Call Rhino.Command("_SelNone")

Next

End Sub

badboi

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Search text field
« Reply #2 on: September 01, 2011, 11:00:35 AM »
thats pretty cool!

but for my purposes I wanted to type in the exact phrase I was looking for such as "A1" and for the screen to zoom to that phrase.  In my case, I have a numerical sequence from A1....to A100 randomly on the screen which I want to seek



ledisnomad

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Search text field
« Reply #3 on: September 05, 2011, 09:09:09 AM »
Well, you should have said so! That's no more difficult to achieve than what I did already. Hope it helps.

Code: [Select]
Option Explicit
'Script written by Damon Sidel
'Script copyrighted by Damon Sidel
'Script version Thursday, September 01, 2011 8:36:04 AM

Call ZoomToText()
Sub ZoomToText()


Dim strText : strText = Rhino.GetString("Enter the text for which you are looking")
If IsNull(strText) Then Exit Sub

Call Rhino.Command("_SelAll")
Dim arrObj : arrObj = Rhino.SelectedObjects()
If IsNull(arrObj) Then Exit Sub

Call Rhino.Command("_SelNone")

Dim strObj, str
For Each strObj In arrObj

If IsText(strObj) Then
str = Rhino.TextObjectText(strObj)
Call Rhino.Print(str)
If (str=strText) Then
Call Rhino.SelectObject(strObj)
Call Rhino.ZoomSelected()
Exit Sub
End If
End If

Next

End Sub

badboi

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Search text field
« Reply #4 on: September 05, 2011, 06:38:05 PM »
AMAZING!!!!!!!!!!!
WORKS LIKE A CHARM.

all I can say is good karma is coming your way.




ledisnomad

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Search text field
« Reply #5 on: September 06, 2011, 02:12:28 PM »
Glad I could help!