Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Cannot escape from a Rhino Python script

$
0
0

Hello,
I am trying to have a function that allows the user to pick some points. Maybe one point, maybe dozens. I used the example located here as a starting point:

Rhino Guide Canceling a Python script in Rhino

Here is the minimal example that shows the problem:

import scriptcontext as sc
import rhinoscriptsyntax as rs

# Example: https://developer.rhino3d.com/guides/rhinopython/python-canceling-scripts/

def DotAtPickedPoints(Text, Layer):

	print('Press the ESC key when finished')

	for i in range(10):
		print(i)
		if (sc.escape_test(False)):
			print('Time to return')
			return

		Clicked = rs.GetPoint('Select a point to mark...')
		if Clicked != None:
			print( type(Clicked) )

DotAtPickedPoints('x', 'Default'

But I am obviously doing something wrong because pressing the escape key will never exit the function. Limiting the loop number to ten was easier than killing Rhino with the task manager but will not be useful in the final script.

Bonus points: where do I find the documentation page on scriptcontext.escape_test() ?

Thank you for your help!
Minimum Example.py (479 Bytes)

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles