RunCommand() explanation

Hello,

can anybody explain me the RunCommand() action in rhino.python? I searched all over the web to find an working example, but most install explanations linked to the old rhino.pythonforum (like this).

Sven

What are you trying to do? To run a Rhino command you would either use rhinoscriptsyntax rs.Command, or RhinoCommon Rhino.RhinoApp.RunScript(commandString, echo)…

–Mitch

Hi Mitch,

this RunCommand() think should register a command for my written script to Rhino. So i can use the script like an regular Rhino command.

there some special thinks i found out so far:

  • the *.py file have to end with *_cmd.py
  • u need a __commandname__ = ["your command"] variable in your code (name of py file without _cmd.py)
  • then there is this RunCommand(is_interactive) function

OK, I wasn’t sure what you wanted - unfortunately I can’t help you because I don’t know much about how that stuff works, I probably should… :confounded:

–Mitch

Hi Sven - what I do is make my script in the normal way, without making it a command and sort the script out, get it working, then I start a new script as a command- I enter the relevant info to set it up, then, transfer the code into this new script, with some minor change that the base function that runs the script, typically

def test():
blah blah

test()

the ‘blah blah’ you copy and paste into the command script:

def RunCommand( is_interactive ):
blah blah

Other functions in the test script can be moved over above the def RunCommand( is_interactive ): part.

Steve or others probably has more info or better processes, but that has been working for me.

-Pascal

When you get the little dialog to enter the command name, what do you give it as a plug-in?

Thx, --Mitch

Hi Mitch- you can put whatever name for the plug-in that makes sense. Once you add one, or more, these show up in the drop down- so in other words you can use this to add commands to existing plug-ins. But you can over-type if you want to make a new command and plug-in.

-Pascal

Yep, this is all correct information that Pascal is presenting. We never really got the python “plug-in” concept to full maturity which is why things seems a bit vague and very little documentation exists.

Hi,
thanks that helped me a lot :slight_smile:

-Sven

So, if I got this straight, I create some sort of plug-in name like MyMostExcellentPythonCommands and then I can add as many command scripts as I want to that plug-in?

Thx,
–Mitch

That’s the goal. Again, this hasn’t really gotten as mature as it needs to in order to be really useful.