Grasshopper

algorithmic modeling for Rhino

I am just a beginner and GH seems like a really cool tool.

I want to use GH from with my own (C#) application. I can interact with Rhino via their interfaces and can instantiate GH this way. But how can I tell GH to simply "load a ghx file" without using the GH GUI? My hope is that after loading the ghx, the rest of the interaction can be done via input text files.

Its almost unbelivable that a software of this scale has no api/command line/COM/something to allow such an operation.

Did I miss something?

(I even tried looking for the GH window and "pressing CTRL-O" via the SendKey command but events seem to get to the Rhino window after all.

Tanir

Views: 3665

Replies to This Discussion

Giulio Ok, I take care of it ASAP.

How do you find the GUID for a parameter.  I have a very similar use case but it not clear where to access the data outside of the SDK.

Update: Looks like it's all there when you save as .ghx

You can also Copy it and examine the xml in the clipboard.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

So I have added a Python Component to canvas with a custom name that I have given it: 

ghenv.Component.Name = "MantisShrimpBake"

Then i try using the BakeDataInObject("MantisShrimpBake") but it returns null even when I am passing a list of Points to that Python Component. 

rhFilePath = str(IN[0])
ghFilePath = str(IN[1])

rhinoId = "Rhino5x64.Application"
type = System.Type.GetTypeFromProgID(rhinoId)
rhinoApp = System.Activator.CreateInstance(type)
rhinoApp.Visible = False

rhinoApp.RunScript("-Open \"" + rhFilePath + "\""0)

rhinoApp.RunScript("_Grasshopper"0)
gh = rhinoApp.GetPlugInObject("b45a29b1-4343-4035-989e-044e8580d9cf""00000000-0000-0000-0000-000000000000")
gh.OpenDocument(ghFilePath)

gh.EnableSolver()
gh.RunSolver(True)
bake = gh.BakeDataInObject("MantisShrimpBake")

strDesktop = r'C:\Users\ksobon\Desktop'
rhSavePath = strDesktop + "\TestMantisShrimp.3dm"
rhinoApp.RunScript("_-Save " + rhSavePath, 0)

rhinoApp.RunScript("_Exit"0)

OUT = bake

Thank you, Giulio Piacentino, very useful example. But I have stil problem to assign data to a panel and a value list. How are those possible?

Giulio,

Is there a way to dismiss any loading errors? This script gets hung up on a loading errors window that pops up when Grasshopper has issues finding some dlls etc. I can manually click OK but that's annoying. 

Thanks! 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service