@eric.bunn wrote:
I pulled the vba script below from another posts. I’m new to Rhinoscript and can not determine why Rhino opens but then terminates when the script ends. (@ the End Sub). I also had to add a visible true command in there to see rhino but it terminates at the end of the sub. Here is the code:
' Main subroutine Sub Main() Dim RhinoApp As Object Dim Rhino As Object ' e.g. RhinoScript Dim strFile As Variant Set RhinoApp = ConnectToRunningRhino() If (RhinoApp Is Nothing) Then MsgBox "Failed to get Rhino interface object" Exit Sub End If Set Rhino = RhinoApp.GetScriptObject() If (Rhino Is Nothing) Then MsgBox "Failed to get RhinoScript object" Exit Sub End If strFile = Rhino.OpenFileName("Open", "RhinoApp 3D Models (*.3dm)|*.3dm|") If Not IsNull(strFile) Then Rhino.PrintEx strFile End If End Sub ' Helper function Function ConnectToRunningRhino() Dim RhinoApp As Object On Error Resume Next Set RhinoApp = CreateObject("Rhino5x64.Interface") If (Err.Number <> 0) Then 'MsgBox "Unable to create Rhino5x64.Interface object" Exit Function End If Set ConnectToRunningRhino = RhinoApp End Function
Posts: 1
Participants: 1