Need advice! combining Grasshopper/Rhino with a standalone Python-Tool

hi all!

We are currently in a research phase and propably need some advice…
We want to use a standalone Python program in conjunction with Grasshopper, but we don’t know how best to go about it.
We have a lot of experience in Python and Java, but little in GHPython and nothing at all in RhinoScripting, VB or C#…

We initially had a grasshopper prototype, which is now being programmed in its core function in python. We use GIT in pycharm and would like to keep this workflow for maintenance reasons and because were not the 90s anymore. :stuck_out_tongue_winking_eye:

Rhino should take over the data input for geometries until we develop our own front end.

The workflow (or our plan, partially done) is as follows:

  • User opens GH script, maybe also with .3dm file
    → layers are created to retrieve the geometries via the layer to GH

  • Basic geometries are created in Rhino by hand, then converted into a .json by Grasshopper using a GHPython Node (this does not need to be like that, that was the quickest approach for now - might be better directly from rhino with RhinoScript if possible?..)

  • User presses “optimize geometry” somewhere
    → PythonScript then opens the json file and does its own thing (little frontend, matplotlib window, etc)

So far we have found out that there are a few ways that would be a viable option.
Therefore, we would be very happy to get some tips in the right direction on how we could best approach this.

can we somehow retrieve the relative path of the .3dm file to save that to a config file for our python?
should we PyInstall an .exe file and can we just run that from rhino?
Or is it the most easiest way, if we “just” look deeper into how to set up a Rhino or Grasshopper Application?

We have already looked at the following things so far:
Publishing Your Scripts as Rhino/GH Plugins
What is a Rhino Plugin?
GH Python Remote
GH Plugin Hops (not sure exactly if that is what we could need)

Would love to get a pointer into the right direction :slight_smile:

Thanks and best regards,
Max

External Pythons and any other executabe can be run no problem from Grasshopper, using subprocess.

The absolute paths of .3dm files are certainly accessible from Grasshopper, and can easily be saved to a json file or toml file using the normal libraries, or wherever you like.

Hello,

if you have experience in Java, I would go for a C# Grasshopper plugin. Old C# is quite similar to Java. Whatever needs to be done in the Rhino environment gets called from a C# plugin. In Rhino8 there is currently a problem with switching from either NET Framework 4.8 to Net Core 7, but apart from this, its quite straight forward
For your application you choose any form of Interprocess communication (Local TCP/ Pipes / Shared Memory) . There are even technologies which helps you with that, e.g. ZeroMQ or gRPC, which are both available for Python3 and C#. With this approach you could provide your python application as an executable and even build an msi installer for Windows (CxFreeze). Users needs then only install Rhino and your application and start both. Of course you could start your application from Rhino (do a simple system call), but if you thread both as dedicated applications, its okay if user just start both manually.