Using an .rvb for two Rhino versions install method?

Hi,
Hi,
I am now win10 64bit (at last !) and so far have installed Rhino 5 with Rhino 7 later tonight.
I see I have on my usb HDD of progs and goodies for the rebuild a folder called other scripts etc.
In it is ToggleSelectionHighlight.rvb

I dont have a button made and recall when trying it that its a type that command and it runs .

How do I get it there ?

and I would want in both V5 and V7, so how is that done ?

Is it open V5 and drag drop onto the grid ?

then ditto V7

else if its d/click it how does it know to go to V5 or V7 etc ?

Cheers
Steve

does this thread help?

Hi, ā€¦um no, tried to understand that, but it requires me to understand the way the script is written.

I also have DivideSubCrv.rvb by Mitch

How are .rvb normally introduced, is it open rhino and drag drop to the interface, as I never did anything beyond such simple acts !

Steve

it seems to work here, for example the ToggleSelectionHighlight: make a button and add it like this:


-_Runscript (
Option Explicit
'Script written by Jarek Bieda | DIG

Call Main()
Sub Main()

	Dim filesys : Set filesys = CreateObject("Scripting.FileSystemObject") 
	Dim t, strCDMini
	
	'get ghosted mode ID
	Dim strCDMID : strCDMID = Rhino.ViewDisplayModeEx(,, False)
			
	'save current display mode in application data folder location
	strCDMini = GetApplicationDataFolder() & "cdm.ini"
	Call Rhino.ExportViewDisplayMode(strCDMID, strCDMini)
	'toggle highlight
	t = Rhino.GetSettings(strCDMini, "DisplayMode\" & strCDMID, "IgnoreHighlights")
	If t = "y" Then t = "n" Else t = "y"
	Call Rhino.SaveSettings(strCDMini, "DisplayMode\" & strCDMID, "IgnoreHighlights", t)
	'import changed display mode
	Call Rhino.ImportViewDisplayMode(strCDMini, True)
	'force redraw new displaymode
	Dim vName : vName = Rhino.CurrentView(): Call Rhino.AddNamedView("TMP") : Call Rhino.RestoreNamedView("TMP") : Call Rhino.DeleteNamedView("TMP")
	Call Rhino.Command("_-ViewportProperties _Title " & chr(34) & vName & chr(34) & " _Enter", False)
	'delete temp displaymode file
	If filesys.FileExists(strCDMini) Then Call filesys.DeleteFile(strCDMini, True)
End Sub

Private Function GetApplicationDataFolder()
	Const APPLICATION_DATA = &H1a&
		Dim objShell, objFolder, objFolderItem
	Set objShell = CreateObject("Shell.Application")
	Set objFolder = objShell.Namespace(APPLICATION_DATA)
	Set objFolderItem = objFolder.Self
	GetApplicationDataFolder = objFolderItem.Path & "\"
End Function
)

Hi,
V5 win10.
Worth knowing, but can this script be just added without having to make a button as I had done so on win7 ?

how is that done for both v5 and v7 ?

Steve

the only way is to rewrite the script a bit as in that thread I linked to. So for example, the attached should give you a new command after you drag and drop it into rhino:

ToggleSelectionHighlight.rvb (1.6 KB)

Hi,
so the scripts I have are for buttons then ?
I thought as I hadnt made buttons that they were drag n drop.
Not sure how I ever ran them in that case !

Steve

I donā€™t know, since I do not have your scripts. But the example I gave I found by searching the forum by @Jarek was not made to be drag and dropped. It only requires a few adjustments to the code though, as explained in the linked thread above.

VB based Rhinoscripts (.rvb) can always be dragged and dropped. However, if nothing special is done, the script will simply run immediately (once) when it is dropped into the Rhino window.

In order to ā€œinstallā€ a .rvb script more permanently, a couple of lines of code can be added to a) not run immediately when dropped into the Rhino window and b) create an alias for the script so that when the alias is called, the script then runs.

Python scripts (.py) on the other hand cannot be dragged and dropped into Rhino to install/run no matter what.

I always recommend against d-'n-d installation/use of scripts for several reasons:

  1. The user never knows how the .rvb script has been set up to run as above, so this is confusing.
  2. The difference between .rvb (d-'n-d possible) and .py (d-'n-d not possible) behavior as outlined above.
  3. The fact that d-'n-d + alias only tells Rhino the path to the script from where you dragged it. So the script has to stay where you dragged it from. Installing it from by dragging it from the desktop and then forgetting and moving it somewhere else or deleting it will cause it to fail.

For all of these reasons, I recommend manual installation of scripts as outlined on this wiki page:
https://wiki.mcneel.com/rhino/macroscriptsetup

However, if the script has indeed been set up for drag and drop+alias creation, then you will probably still need to edit the code if you manually install them.

@Steve1 Note that the script you mentioned above - DivideSubCrv.rvb (2010!) was NOT set up for drag and drop installation. Virtually none of my old .rvb scripts ever were for the reasons I outlined above. I might have made some ā€˜specialsā€™ on request for people that did work that way, but thatā€™s far too long ago to remember.

1 Like

Hi,
V5 win10
I will study the responses and altered codes and get my head around how to make sure my .rvb files can be added to buttons. That way they live in the button.
The .rui file has brought in my buttons along with scripts and codes and so is source independent.
I see in properties the scripts and location on D drive so as said, if I were to move them, or as in last few months D drive was disconnected to save it failing, the scripts would not have worked.

Lets see how I manage, coding not my strong point.

Steve

Hi,
V7
@Helvetosaur
@Gijs
I wish to open the .rvb script and place the entire script into a button as per wiki article,
I cannot see anywhere how to open the .rvb fle and copy paste the code.
All I see on internet is open into Rhino but I dont want to do so with talk of some .rvb are not intended for drag and drop. I dont want to run it. I want to button run it.

No one says how to get at the script as such.

I wish to start by using the ToggleSelectionHighlight.rvb

Cheers

Steve

you can open it in a text editor like Notepad++, then copy and paste it to the button, or in Rhino: EditScript and load it in there, then copy and paste it to your button