Grasshopper

algorithmic modeling for Rhino

Recompute Grasshopper Via Rhino Command Line Alias?

Unfamiliar with Rhinoscript enough to set a command alias in Rhino so I can type a custom command name and then have a Rhinoscript issue a Solution>Recompute command in Grasshopper when the solver is left disabled to free up Rhino use. This works fine via the Grasshopper menu. I don't know the appropriate Rhinoscript, nor how to save the script in my Rhino file and then link it to a run script command alias. Lots of homework for such a simple task. Ought to be in the manual, if there was one, thanks!

Views: 1372

Replies to This Discussion

This little python script does the trick:

import Rhino
gh = Rhino.RhinoApp.GetPlugInObject("Grasshopper")
gh.RunSolver(True)

Great tip. Now I need to learn how to install that script in my Rhino document as a command line alias, say "Nik" as my new command.

Where do I look this sort of thing up on my own, minus any real manual? In the Grasshopper.chm help file, nowhere does the RunSolver command tell to use:

Rhino.RhinoApp.GetPlugInObject("Grasshopper")

Instead it uselessly and frustratingly says:

Grasshopper SDK
GH_RhinoScriptInterface.RunSolver Method
GH_RhinoScriptInterface Class See Also Send Feedback
Runs the solver once, even if the global solver lock is on.
Namespace: Grasshopper.Plugin
Assembly: Grasshopper (in Grasshopper.dll) Version: 1.0.0.20 (0.9.52.0)
Collapse imageSyntax

C#
public void RunSolver(
bool expireAllObjects
)
Visual Basic
Public Sub RunSolver ( _
expireAllObjects As Boolean _
)
Parameters
expireAllObjects
Type: System.Boolean
If true, will expire all objects in the current document.
Collapse imageSee Also

GH_RhinoScriptInterface Class
Grasshopper.Plugin Namespace

Hi Nik,

Save the upper Andrew's code as a .py file (for example: runSolver.py)

If you save it to one of RhinoPython's "Module search paths" (RhinoPython's application menu: Tools->Options), you can define an alias like so:

import rhinoscriptsyntax as rs

rs.AddAlias("runSolver", "! _-RunPythonScript runSolver.py")

If you do not save the .py file to one of RhinoPython's "Module search paths", you need to define the path too:

import rhinoscriptsyntax as rs

rs.AddAlias("runSolver", "! _-RunPythonScript C:/runSolver.py")

Of course all of this can be done manually in Rhino (Rhino's application menu:Tools->Options->Aliases->New).

GrasshopperSDK help file generally lacks python related data.

Grrrr...this all requires an external file that other users on their own computers won't have. I'd like to include it as part of my Rhino document somehow.

Yep, that's an annoyance.  The solution we use is to build installers that copy and deploy all scripts and uses a launcher button that adds the shortcut if it doesn't already exist on load.

It's a lot of work and not foolproof... but it works.

Marc

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service