External Access

Although the RhinoScript Automation object resides in a Rhino plug-in, external access to this object is available outside of Rhino.  External access to the RhinoScript object is available through Rhino's automation, or COM, interface.  Thus, it is possible to access all of the methods provided by the RhinoScript object from other automation aware products and development environments, such as Microsoft Visual Basic Script, or C#.

Rhino Objects

There are several different Rhino objects that you can create:

Object

Comments

Rhino.Application

Version independent identifier

Rhino.Application.6

Version dependent identifier

Rhino.Interface

Version independent identifier

Rhino.Interface.6

Version dependent identifier

More Information

For details on the methods and properties available to these objects, see Rhino Methods and Properties.

Application verses Interface Object

Creating a Rhino Application object will always result in a new running instance of Rhino.

When you create a Rhino Interface object, if an instance of Rhino is already running, you will be given a reference to this existing Interface object. If Rhino is not running, it will be launched and you be given a reference to this newly created object. Note, if more than one instance of Rhino is already running, there is no way to determine in advance which running instance to which you will be given reference.

What To Use?

If you are planning on writing an application that will automate Rhino, you will have to decide which automation object to use.

Connecting to Rhino

The following example demonstrates how to connect to Rhino from an external script written in VBScript. Note, it is possible to connect to any language that supports ActiveX automation, such as C#, Visual Basic, and C++.

 

' Try creating a Rhino Application object

Dim objRhino

On Error Resume Next

Set objRhino = CreateObject("Rhino.Application")

If Err.Number <> 0 Then

  Call WScript.Echo("Failed to create Rhino object.")

  Exit Sub

End If

Call WScript.Echo("Rhino object created.")

 

Note to developers: Rhino includes a type library (Rhino.tlb), which contains information about both the Rhino.Application and Rhino.Interface objects. Rhino's type library file can be found in Rhino's "System" folder.

Connecting to Rhino

 

' Try creating a Rhino Application object

Dim objRhino, objRhinoScript, nRetries

On Error Resume Next

Set objRhino = CreateObject("Rhino.Application")

If Err.Number <> 0 Then

  Call WScript.Echo("Failed to create Rhino object.")

  Exit Sub

End If

' Wait for Rhino to finish initializing

nRetries = 0

Do While (nRetries < 10)

    If objRhino.IsInitialized = 0 Then

    Call WScript.Sleep(500)

    nRetries = nRetries + 1

  Else

    Call WScript.Echo("Rhino initialization failed")

    Exit Sub     

  End If

Loop

' Try getting RhinoScript object

Set objRhinoScript = objRhino.GetScriptObject

 

Note to developers: RhinoScript includes a type library (RhinoScript.tlb), which contains information about both the RhinoScript object. RhinoScript's type library file can be found in Rhino's "Plug-ins" folder.

Schemes

Rhino Schemes are different sets of Rhino Options that are stored in the Windows Registry. Everything in the Options section of Rhino can be stored in a scheme. In this way, Rhino can be started with different combinations of workspaces, languages, colors, etc. depending on the need or the user, just by starting Rhino from the appropriate desktop shortcut. The schemes exist independently of each other, and can be modified as desired.

If Rhino is launched via ActiveX automation, there is no way to specify an alternate scheme (being that you cannot pass command line arguments when creating COM objects). But, we have provided a hidden registry key that you can use to specify an alternate scheme. Note, this registry key only works if Rhino is launched via ActiveX automation. The registry key is:

HKEY_CURRENT_USER\Software\McNeel\Rhinoceros\6.0\Global Options\Automation

Name: Scheme

Type: REG_SZ

Value: <scheme_name>