Rhino Python on mac console question

Hi all,

Rhino Python 101 question as I’m new to both and haven’t used Rhino / Python PC version. Following along with the chapters in RhinoPythonPrimerRev3.pdf on p.34, there is a small program that uses both “prompt” and “print” in the following lines:

prompt = “What is your {0}th most favorite thing?”.format(count+1)

print “Your”, len(things)+1, “favorite things are:”

I don’t get any errors when running this file in Rhino, but I never see any print or prompt text anywhere. No dialog box and nothing in the bottom left corner of the window. Is this because the built-in console window isn’t up and running for the mac version yet, or am I doing something wrong?

I’ve tried toggling the preference > legacy > Use text field for command line and command options but neither reveals the prompt or print results.

Thanks,

Sarah

rather, when the program uses the prompt variable here:

answer = rs.GetString(prompt)

a dialog box should be popping up, but it doesn’t seem to.

Here’s the whole script:

import rhinoscriptsyntax as rs defmyfavoritethings():
things = []
while True:
    count = len(things)
    prompt = "What is your {0}th most favorite thing?".format(count+1)
    if len(things)==0:
        prompt = "What is your most favorite thing?"
    elif count==1:
        prompt = "What is your second most favorite thing?"
    elif count==2:
        prompt = "What is your third most favourite thing?"
    answer = rs.GetString(prompt)
    if answer is None: break
    things.append(answer)
if len(things)==0: return
print "Your", len(things)+1, "favorite things are:"
for i,thing in enumerate(things): print i+1, ".", thing

Thanks,

Sarah

@marlin the print statement in python calls RhinoApp().Print(…) under the hood. Where does the printed output show up now on Mac Rhino?

Sarah,

Your script needs a little bit of formatting to work correctly. Here’s a version that works for me:

import rhinoscriptsyntax as rs
def myfavoritethings():
  things = []
  while True:
      count = len(things)
      prompt = "What is your {0}th most favorite thing?".format(count+1)
      if len(things)==0:
          prompt = "What is your most favorite thing?"
      elif count==1:
          prompt = "What is your second most favorite thing?"
      elif count==2:
          prompt = "What is your third most favourite thing?"
      answer = rs.GetString(prompt)
      if answer is None: break
      things.append(answer)
  if len(things)==0: return
  print "Your", len(things)+1, "favorite things are:"
  for i,thing in enumerate(things): print i+1, ".", thing

myfavoritethings()

Also note that I added a call to myfavoritethings() at the end of the script.

When I run this script, I get this dialog:

At the end, the output goes to the status line at the lower left corner. Since there are multiple lines of output, use Window > Show Command History in the Rhino menu to see all the output.

Hi Steve,
That worked. I wouldn’t have guessed I needed that function call at the end so you’ve saved me a lot of time.
Many thanks!
Sarah