Grasshopper

algorithmic modeling for Rhino

Fellow GH Users,

For automation purposes, I would like to start Rhino and Grasshopper from another custom made piece of script and perform some calculations inside GH. I read thoroughly all what has been  written about it and I manage to get both of them started with this:

(VB.NET)

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim doc1 As String = "C:\Users\Xavier\Desktop\Test_GH\Test à changer.gh"
Dim type As Type = Type.GetTypeFromProgID("Rhino5x64.Application", True)

'Start Rhino

Dim rhinocomobj As Object = Activator.CreateInstance(type)
rhinocomobj.visible = True
While rhinocomobj.IsInitialized() = 0
Threading.Thread.Sleep(100)
End While

'Start GH and open a file

rhinocomobj.RunScript("_Grasshopper", 0)
Dim gh As Object = rhinocomobj.GetPlugInObject("b45a29b1-4343-4035-989e-044e8580d9cf", "00000000-0000-0000-0000-000000000000")
gh.OpenDocument(doc1)

From what I understood, this creates a separated COM object, but I don't know how I can manipulate it. For example, how can I get the RhinoDoc, the GH Document and so on? 

I tried :

Dim RhinoDocument as RhinoDoc = RhinoDoc.ActiveDoc

but this throws an exception "System.dllNotFoundException" about RhinoCommon.dll, despite RhinoCommon.dll has been set as a Reference of the Project.

I tried as well to build a new class which sits inside GH (DLL as a reference + GHA inside GH library) as per David's suggestion: http://www.grasshopper3d.com/forum/topics/call-gh-from-c-code, and to access properties but I still get the same "DLL Not Found" exception whenever I use GH commands through this tailor made class.

At last, I tried using RhinoScript Interface through commands like :

gh.AssignDataToParameter, but this doesn't change the value, this doesn't throw any exception neither.

I would like to get full access in order to change parameters from a GH document, output geometries and DWG files, and so on. 

I don't know if I am being really clear but any help would be really appreciated.

Thanks!

Views: 296

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service