Run script with arguents

Is there any way to pass arguments to the main function when you run a script in Rhino.

Thanks Mark.

Nope, I usually have subroutines that call specific parameters. If it’s a parameter that changes every time, the first thing the script would do is somehow collect it. What sort of parameters are you trying to pass?

I’ve written a python script to produce G code for my wire erosion machines, when run it brings up a list box that lets you pick the machine and type of code.

I’d like to do away with this dialog and just have a tool bar with 4 icons instead. What I was hoping for was some way to call the script and have each icon pass a different parameter.

Thanks Mark.

Hi Mark, you might get along if you create a function which asks for the possible option using a rs.GetString() prompt. The machine type can then be the option which gets passed per runscript button as explained in this tread.

c.

Hi Mark
If I understand the problem correctly, using -RunPythonScript might be enough.
This way:

( pseudocode )

-RunPythonScript (
import myscript.py
myscriptmain( param, param, param )

when myscript is the script you have to run
ans myscriptmain() if the main function inside that script

HTH cheers

EDIT

… forgot the final parenthesys:

-RunPythonScript (
import myscript.py
myscriptmain( param, param, param )
)

Also, you will have to comment out the call to the main function in your script,
since this way it is used as a library

Does this take care of using the script as a library.

Thanks Mark.

It looks like the import should be import myScript without the extension. But I still can’t get it to work, I get this error.

Here’s what I have on the the button and in the script.

Any ideas what’s wrong.

Thanks Mark.

Ok figured it out I need to have this on the buttom

-RunPythonScript (
import HTWEDM
HTWEDM.WEDMcut(‘100 2 Axis’)
)

Now it works. Thanks for the help.

Mark

Glad you made it work, Mark…
and sorry for the confused message … I had very little time when I replied … :blush:

Cheers