Rhinocode command "_circle 0 0 0 20"

I’m expecting to be able to pass argument to my custom python commands and my gh scripts with GetContext in the terminal on macos with named variables; something like rhinocode command "_hello_world_python 0 0 0 20" or rhinocode command "_hello_world_gh MyContextVariable=55"

Is that the intention? Can you please provide a full end to end. example

@eirannejad Are you able to help here?

is anyone able to help?

Hi @Sholto_Maud,

Maybe you should share some code that isn’t working for you?

– Dale

1 Like

@Sholto_Maud
Where is _hello_world_python? Is that a plugin command or a python script?

1 Like

Thank you very much for your responses! :smile:

The first example I gave was a python script installed it as a new plug in which has therefore become available as a new command that can be run with rhinocode command "_some_new_command".

I have tested this and it works, which is great!

However the question is how to pass variables to the command (which as I’ve said is a python script in this case). Since you document rhinocode command “_circle 0 0 0 20” as an example I was expecting to be able to do the same type of thing with my own custom plug in command written in python, and then iterate over this command with many different params like:

rhinocode command "_hello_world_python 0 0 0 10"
rhinocode command "_hello_world_python 0 0 0 20"
rhinocode command "_hello_world_python 0 0 0 30"

etc.

The second case is a grasshopper script which has been installed as a new plug in and become available as a command and would be used in a similar way.

Thanks Dale, you can use any basic hello world python script installed as a plug in, but the question is how to pass variables/params to the script.

@Sholto_Maud In scripting languages you would need to use RhinoCommon Get methods (example from python) and in Grasshopper you would use the Context input and output components.

Here is an example script editor project with a simple python and grasshopper command. You can use rhinocode command line utility to run these commands in Rhino

TestScriptsWithInputs.zip (19.7 KB)

That’s awesome! :smile:

I’ll try it out and get back to you.

1 Like

Right, so your scripts only works in RhinoWIP, NOT Rhino8

I’m not sure you made that evident in the documentation you posted.

For your Python script, after I build it and drag and drop the .yak file on the Rhino instance and then restart RhinoWIP, when I run /rhinocode command "hello_world hithere2" in a macos Terminal window the RhinoWIP Command history shows the following, is that expected?

Command: hello_world
Texthithere2
hithere2

I’ve tried to build with the rhinocode for RhinoWIP and got the following error:

/Applications/RhinoWIP.app/Contents/Resources/bin/rhinocode project build ./hello_world.rhproj
  0% - Preparing project
 10% - Preparing build path
 20% - Preparing plugin assembly
Build Error: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find the specified DllImport Dll.

however when I build with the ScriptEditor it builds ok, and I can then use yak to install the plugin in an automated way.

I seem to be doing something wrong. I have adjusted your script so that it reads as below. Now after a build and yak install from the command line I get Unknown command when running /Applications/RhinoWIP.app/Contents/Resources/bin/rhinocode command hello_world hithere23 and if I run /Applications/RhinoWIP.app/Contents/Resources/bin/rhinocode command "hello_world hithere23" then the command runs but I don’t see the output of the latest version of the python script.

#! python 3
import Rhino
from Rhino.Input import GetResult
from Rhino.Input.Custom import GetString


g = GetString()

res = g.Get()
if res  == GetResult.String:
    print(f'Hello hello {g.StringResult()}')
    print(f'Hello2 {g.StringResult()}')

However; if I drag and drop the .yak file onto the open RhinoWIP editor then restart RhinoWIP and then run the /Applications/RhinoWIP.app/Contents/Resources/bin/rhinocode command "hello_world hithere23" command then it picks up the latest change.

This development process is pretty brittle on mac.

I notice that you’re bulding on Windows. Can I suggest that you move over to your Macbook Pro and replicate your build and testing steps on the Mac, and let me know what the reliable workflow is?