Can we convert a Python script to a Popup button?

Hi all,

Just wondering if it is possible to convert an entire python script(a simple and short one) into a button and put it onto the Popup toolbar?
Just like creating my own command button.

Thank you in advance :smile:

Jack

http://bbs.shaper3d.com/thread-23129-1-4.html

The simple way is to create a new button, then open the button editor and in the text box, type the following:

! -_RunPythonScript (

paste your entire script in here

)

Then OK to accept the button (edit the image as well if you wish).

If you created the new button directly in your popup toolbar, it will be there already, otherwise, if you have created it in another toolbar, you can copy the new button over to the popup toolbar.

–Mitch

Hi Jack,

You can create your own toolbar buttons:
http://docs.mcneel.com/rhino/5/help/en-us/index.htm#toolbarsandmenus/toolbar_button_editor.htm

On that button you can set a macro for the command RunPythonScript like so:

_-RunPythonScript
(
your python script here
)

for example:

_-RunPythonScript
(

import rhinoscriptsyntax as rs

def MakeAPoint():
   rs.AddPoint(0.5,0.5,0.5)

MakeAPoint()

)

In the button editor it looks like this:

HTH
-Willem

1 Like

Cool!
That is exactly what I am looking for~
Big thanks to all you guys!!

:smiley:

Jack

2 Likes