Macro Buttons

Course or Collection: 
Video Duration: 
5 minutes
Zach Downey

This quick tutorial shows how to create a macro button on a toolbar. This illustrates a quick way to Unload/Reload Grasshopper for development purposes. I use it in the course Developing Your Own Grasshopper Plugin. I also show a quick python script that I apply to a button as well. The python script is a simple mitre tool, nothing fancy. The code for both of these are below.

!-_RunPythonScript (
#AutoMitre Script
import rhinoscriptsyntax as rs
#Select Objects to Mitre
objects = rs.GetObjects("Select Polysurfaces to Mitre", 16)
#Boolean them together
booleanGeo = rs.BooleanUnion(objects,True)
#Ask the used to pick start and end points for the mitre plane
cutplaneStartPt = rs.GetPoint("Select Mitre Start Point")
cutplaneEndPt = rs.GetPoint("Select Mitre End Point")
#Create the mitre plane
cutPlane = rs.AddCutPlane(booleanGeo,cutplaneStartPt,cutplaneEndPt)
#Split the booleanGeo with the cutPlane
newMitredPieces = rs.SplitBrep(booleanGeo,cutPlane,True)
#Cap Planar holes in each mitred object and MergeAllFaces
for brep in newMitredPieces:
#Add objects to be deleted to the removeObjects List
removeObjects = [cutPlane] 
#Delete the objects


Please rate this tutorial below. Thanks.

Average: 3.5 (4 votes)

Want to Contribute?

Want to be an author? Drop us a line here we'd love to have you.

Already have a video you'd like to post? Send us a link and we'll get you going.