Is is possible to run Grasshopper in other IDEs like PyCharm?

Hello developers @piac,

I am not a big fan of the RhinoPythonEditor, so I am wondering if it is possible to let PyChamr do the same job? I followed the directions outlined in the following post:

However, when I run:

from Rhino import RhinoApp, RhinoDoc
gh = RhinoApp.GetPlugInObject("Grasshopper")

I get:

    "C:\Program Files\IronPython 2.7\ipy.exe" E:/TEST_PROJECT_PYCHARM/TEST
    Traceback (most recent call last):
      File "E:/TEST_PROJECT_PYCHARM/TEST", line 6, in <module>
    SystemError: Unable to load DLL 'rhcommon_c': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

    Process finished with exit code 1

May I know if this error is solvable?

Thanks

Hi you cannot directly load Rhinocommon.dll outside of a Rhino instance. This is what the error indirectly says. You can write the code in any editor, but it has to be executed within a Rhino instance. So you can run it from Rhino cmdline. I‘m not sure about the cmd. Must be something like: run python xyz.py .

Yes, you need to execute the script in Rhino in any case, in order for Rhino to load RhinoCommon.

Maybe for future versions, @stevebaer could investigate if the ExecuteFile-based method that is employed in the new GhPython is also applicable to the EditPythonScript editor.

Hello @piac,

Thank you very much for the reply.

For now, I am wondering if it is possible to just use external IDE to open Rhino and send command to execute .py file?

Thanks

Yes, you can run the _RunPythonScript command. A simple way is set that as a startup command (in Rhino Options).

Another is through command line.

https://developer.rhino3d.com/guides/cpp/running-rhino-from-command-line/

From time to time I like come back in this forum to help out, because the forum helped me a lot in return… but sometimes, especially if people ignoring messages, I ask myself: What am I doing here? And I begin to wonder, why so many people have such a deficit in basic communication. „Thank you, Tom“ (no matter if this answer was helpful enough) is really the minimum you could give in return. But even worse, saying thank you to another person which is saying the same as I said, tells me: I respect him, but not you!

2 Likes

@TomTom, you’ve always been very precise, I think @eduszh just didn’t remember to thank you as well. Hope your summer is going well!

1 Like