Annotation dot text to curve script


#1

Hi,

I have in the past used a script that now for some reason gives problems.
I am on W7 Rhino 4

Here is the script, if someone could please assist to see what is wrong.
I used it by selecting a whole bunch of annotation dots, run the script, it ask what font size and then changed the whole bunch at once and deletes the annotation dots.

! _-Runscript  ( 

Private dblTextHeight
If IsEmpty(dblTextHeight) Then
  dblTextHeight = 1
End If


Sub   TextObjectifySelDot
   
  Dim arrDot, arrbln, strDelete
  
  arrDots = Rhino.ObjectsByType(8192)
  arrSelDot =Rhino.GetObjects("Select dots to convert",,,,,arrDots)
  arrBln = Array("Yes", "No")

  
  If Not IsArray(arrSelDot) Then
   MsgBox "No Dots are in the file"
   Exit Sub
  
   Else
     Height = Rhino.GetReal("Text height:", dblTextHeight)
     If Not IsNull(Height) Then
       dblTextHeight = Height
       Else Exit Sub
     End If
     
    strDelete = Rhino.GetString("Delete Dots?", "Yes", arrBln) 
    If IsNull(strDelete) Then
      Exit Sub
    End If
     
     Rhino.EnableRedraw(False) 
    For Each strDot In arrSelDot
      strText= Rhino.TextDotText(strDot)
      If IsEmpty(strText) Then
         Exit For
          End If
      arrPt = Rhino.TextDotPoint(strDot)
      strPt = Rhino.Pt2str(arrpt)
      Rhino.Command "! -TextObject Output=Curves Height=" _
     & CStr(dblTextHeight) &" " &Chr(34) &strText &Chr(34)_
        &" " &strpt &" " 
      'Rhino.AddText strText,arrPt,dblHeight
      If StrDelete = "Yes" Then
        Rhino.DeleteObject(strDot)
      End If
      Next
      Rhino.EnableRedraw(True)
      
  End If
End Sub

  TextObjectifySelDot
)

Thanks
Cobus


#2

Right away I see that you have some undefined variables. You define arrDot, but then use arrDots. Height is another one that is undefined. Start with that. However, since you don’t use Option Explicit, you might get away with it. Personally, I always use Option Explicit and make sure I define my variables correctly.

Dan


#3

Hi,

I am a 3d modeler, not a programmer, is there any way that you could fix what you think is wrong and email me or past script text here.

What you said there is Greek to me :smile:
Thanks in advance :smile:
Cheers
Cobus


#4

Here is a fixed version that should run in V4 or 5.

–Mitch

TextObjectifySelDot.rvb(1.3 KB)


#5

thank you so much fro this, how do I install this permanently as part of the software when I have it open and how do I run it, is there a specific command?


#6

Hi,

I had the old non working one added as an alias, is it possible to add this one in the same way ?

Cheers
Cobus


#7

the script runs the first time I open rhino if I added it to the scripts to initialize at the start up

Right-clicking to redo the function, does not call it again, also I can only run this on start up, it would be really cool to get the actual script so I can just copy and paste into the area where I add aliases.

Thanks
Cobus


#8

The old one simply had

! _Runscript (

script here

)

So I assumed it was from a button, as that is usually how the above is used. If it was running from an alias, I don’t know how it was set up, if you replaced the old script file with the new one (in the same location with the same filename) then if you add the two lines above it should run with the same alias, I assume…

I usually leave out the alias and drag and drop stuff because I find it leads to confusion and possible script name/alias clash. This can get people into trouble, we had a case here yesterday.

–Mitch


#9

yeah, I had a shortcut that I typed and the alias would run the script, but if I use that basic one I supplied it bomb out and does not run, Is there a way to have this run that way again, so that I would select some text, move them around after changing to curves, and then later run it again after typing the appropriate command(alias) ?


#10

so what you saying is I need to add the lines as you have indicated here ?


#11

is says line 1 character 24 something wrong ? if maybe that can assist


#12


#13

What does your alias say (both the alias itself and the path to the file)?
–Mitch


#14

that clear text that I added to the request right at the start, I used the text “dd” alias, and then command Macro

! _-Runscript (

Private dblTextHeight
If IsEmpty(dblTextHeight) Then
dblTextHeight = 1
End If

Sub TextObjectifySelDot

Dim arrDot, arrbln, strDelete

arrDots = Rhino.ObjectsByType(8192)
arrSelDot =Rhino.GetObjects(“Select dots to convert”,arrDots)
arrBln = Array(“Yes”, “No”)

If Not IsArray(arrSelDot) Then
MsgBox "No Dots are in the file"
Exit Sub

Else
Height = Rhino.GetReal(“Text height:”, dblTextHeight)
If Not IsNull(Height) Then
dblTextHeight = Height
Else Exit Sub
End If

strDelete = Rhino.GetString("Delete Dots?", "Yes", arrBln) 
If IsNull(strDelete) Then
  Exit Sub
End If

 Rhino.EnableRedraw(False) 
For Each strDot In arrSelDot
  strText= Rhino.TextDotText(strDot)
  If IsEmpty(strText) Then
     Exit For
      End If
  arrPt = Rhino.TextDotPoint(strDot)
  strPt = Rhino.Pt2str(arrpt)
  Rhino.Command "! -TextObject Output=Curves Height=" _
 & CStr(dblTextHeight) &" " &Chr(34) &strText &Chr(34)_
    &" " &strpt &" " 
  'Rhino.AddText strText,arrPt,dblHeight
  If StrDelete = "Yes" Then
    Rhino.DeleteObject(strDot)
  End If
  Next
  Rhino.EnableRedraw(True)

End If
End Sub

TextObjectifySelDot
)

That always worked when I last used the function


#15

Ahh, so the alias is the ENTIRE script ??? Not very good practice, especially if you have to edit it… So, if you want to do it like the original:

Open the script I posted in a text editor like Notepad
Add this line at the top of the script above everything else:
! _NoEcho _-Runscript (

add a close parenthesis after the entire script (last line of the file)

)

Then copy the whole shebang, go to Options>Aliases, find “dd”, in the right hand box select all, delete and paste the new script in there, then OK to close out of Options. It should then run when you type “dd”.

–Mitch


#16

I appreciate all the assistance emmencely, but I think that I am doing something wrong because it does not work.

Please could you paste here or email me the acxect body of text that should be added on the right hand column if you don’t mind.
cobus@cybersmnart.co.za


#17

OK, I see this doesn’t work with an alias - only a toolbar button. I don’t know how it was working for you previously that way. As I said it’s a pain anyway to paste all that into an alias box if you someday need to edit it.

I would just:

  1. Put the TextObjectifySelDot.rvb script file as posted (without the Runscript stuff added) somewhere known - like a scripts folder somewhere.

  2. Then in the right side of the alias, put
    ! _-Loadscript "<FullPathToFolder>\TextObjectifySelDot.rvb"
    –where the fullpath is full Windows path to the abovementioned folder
    ( "C:\....\Scripts\TextObjectifySelDot.rvb")

Then typing your alias should make it run.


#18

Hi Helvetosau,

I ran out of reply allowances yesterday.
I just wanted to come back and say thank you very mush for all the help yesterday.

You were patient and I ended up being helped.

Thanks again
Cobus


#19

No problem, glad it worked…

–Mitch