Rs Rhino Version
Last changed: dale@mcneel.com-204.177.179.111

.
DeveloperRhinoScript
VersionRhino 4.0
SummaryDiscusses how to determine the version of RhinoScript from a running script.

Question

Is there a good way to distinguish between scripts written in Rhino 3.0 verses those written in Rhino 4.0?

Answer

There is really not a good way, visually, to determine what version of Rhino a script was written for. Keep in mind that all RhinoScript functions found in V3 are also found in V4.

If it is important to know what version of Rhino a script was written for, the scripter should leave some clue behind in the script file. Perhaps a comment is sufficent. They might also have a block of code that only allows the script to run in a particular version.

For example:

  . 
  . 
  .
  ' Check if the RhinoScript version is greater that 3.0 SR5b
  If CLng(Rhino.Version) > 20060519 Then
    Rhino.Print "This RhinoScript requires Rhino 3.0"
    Exit Sub
  End If
  . 
  . 
  .

RhinoScript's Version method returns the version of RhinoScript as a long integer. The version of RhinoScript generally cooresponds to the version of Rhino unless you have downloaded and installed a Labs version. The following constants define the values returned by RhinoScript over the last several releases:

  Const RH_40_SR4B = 20080827 ' Rhino 4.0 SR4b
  Const RH_40_SR4  = 20080807 ' Rhino 4.0 SR4
  Const RH_40_SR3  = 20080222 ' Rhino 4.0 SR3
  Const RH_40_SR2  = 20071017 ' Rhino 4.0 SR2
  Const RH_40_SR1  = 20070703 ' Rhino 4.0 SR1
  Const RH_40_SR0  = 20070118 ' Rhino 4.0 SR0
  Const RH_30_SR5B = 20060519 ' Rhino 3.0 SR5b
  Const RH_30_SR5  = 20060331 ' Rhino 3.0 SR5
  Const RH_30_SR4  = 20050718 ' Rhino 3.0 SR4
  Const RH_30_SR3C = 20040421 ' Rhino 3.0 SR3c
  Const RH_30_SR3B = 20031209 ' Rhino 3.0 SR3b
  Const RH_30_SR3  = 20031111 ' Rhino 3.0 SR3
  Const RH_30_SR2  = 20030606 ' Rhino 3.0 SR2
  Const RH_30_SR1  = 20030305 ' Rhino 3.0 SR1
  Const RH_30_SR0C = 20021220 ' Rhino 3.0 SR0 CD3
  Const RH_30_SR0B = 20021125 ' Rhino 3.0 SR0 CD2
  Const RH_30_SR0  = 20021120 ' Rhino 3.0 SR0 CD1

You can determine the version of RhinoScript, and Rhino, that you are running using the following subroutine:

  Sub PrintRhinoVersion()
    Select Case CLng(Rhino.Version)
      Case RH_40_SR4B Rhino.Print("Rhino 4.0 SR4b")
      Case RH_40_SR4  Rhino.Print("Rhino 4.0 SR4")
      Case RH_40_SR3  Rhino.Print("Rhino 4.0 SR3")
      Case RH_40_SR2  Rhino.Print("Rhino 4.0 SR2")
      Case RH_40_SR1  Rhino.Print("Rhino 4.0 SR1")
      Case RH_40_SR0  Rhino.Print("Rhino 4.0 SR0")
      Case RH_30_SR5B Rhino.Print("Rhino 3.0 SR5b")
      Case RH_30_SR5  Rhino.Print("Rhino 3.0 SR5")
      Case RH_30_SR4  Rhino.Print("Rhino 3.0 SR4")
      Case RH_30_SR3C Rhino.Print("Rhino 3.0 SR3c")
      Case RH_30_SR3B Rhino.Print("Rhino 3.0 SR3b")
      Case RH_30_SR3  Rhino.Print("Rhino 3.0 SR3")
      Case RH_30_SR2  Rhino.Print("Rhino 3.0 SR2")
      Case RH_30_SR1  Rhino.Print("Rhino 3.0 SR1")
      Case RH_30_SR0C Rhino.Print("Rhino 3.0 SR0 CD3")
      Case RH_30_SR0B Rhino.Print("Rhino 3.0 SR0 CD2")
      Case RH_30_SR0  Rhino.Print("Rhino 3.0 SR0 CD1")
      Case Else Rhino.Print("Unknown Rhino version")
    End Select
  End Sub