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
)
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.
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?
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.
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.
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) ?
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)
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”.
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
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:
Put the TextObjectifySelDot.rvb script file as posted (without the Runscript stuff added) somewhere known - like a scripts folder somewhere.
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")