How to do range(start,stop,number of steps) in Python Script?

Always get this done by code block, but problems when try to get these numbers within Python Script. Anyone can help? Thank you!
PythonRange

The range() function only accepts integers. You can write a custom function like this:


custom range.dyn (10.4 KB)

def range_plus(start, stop, num_steps):
	range_size = stop-start
	step_size = float(range_size)/(num_steps-1)
	for step in range(num_steps):
		yield start + step*step_size

a = int(IN[0])
b = int(IN[1])
c = int(IN[2])
OUT = range_plus(a, b, c)
4 Likes

cgartland is right - the range() function works with integers…but you can use one of these options:


Stackoverflow is better for python questions.
Dynamo uses python 2.7…so you can’t use Numpy.

Use one of these for float values:

1 Like