@stevefuchs wrote:
Attempting to create a demonstration of ETO Button that will execute simple recursion. Currently, this locks up my Rhino instance. I’ve searched the forums and can’t find much. Thank you.
################################################################################ # SampleEtoPushPickButtonDialog.py # Copyright (c) 2018 Robert McNeel & Associates. # See License.md in the root of this repository for details. ################################################################################ # Imports import rhinoscriptsyntax as rs import Rhino.UI import Eto.Drawing as drawing import Eto.Forms as forms class SampleEtoPushPickButtonDialog(forms.Dialog): def __init__(self): self.Title = "Point to Spheres" self.ClientSize = drawing.Size(200, 200) self.Padding = drawing.Padding(5) self.Resizable = False button = forms.Button() button.Text = "Pick Center Point" button.Click += self.OnPushPickButton self.Content = button # Define Function(s) def RecursiveSpheres(pt, r): if r == 0: # Tests value of r (counts down to 0) return 1 # Exits Recursive Conditional else: rs.AddSphere(pt, r) # Adds Sphere (from library) return RecursiveSpheres(pt, r-1) # Calls Function (again) def OnPickPoint(self, sender, e): #Rhino.Input.RhinoGet.GetPoint("Pick a point", True) pt = rs.GetPoint("Pick Center Point") # User Input (pick point on screen) RecursiveSpheres(pt, 10) # Calls Funtion def OnPushPickButton(self, sender, e): Rhino.UI.EtoExtensions.PushPickButton(self, self.OnPickPoint) ################################################################################ # Creating a dialog instance and displaying the dialog. ################################################################################ def TestSampleEtoPushPickButtonDialog(): dialog = SampleEtoPushPickButtonDialog() dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow) ################################################################################ # Check to see if this file is being executed as the "main" python # script instead of being used as a module by some other python script # This allows us to use the module which ever way we want. ################################################################################ if __name__ == "__main__": TestSampleEtoPushPickButtonDialog()
Challenge 02w - Point to Spheres.py (2.4 KB)
Posts: 5
Participants: 2