Rhino python help!

Hi, I was trying one code from rhino python primer, I wrote the exact definition, but it shows an error(Message: range() integer end argument expected, got float)
srf peel.py (721 Bytes)

PFA a screenshot, and code for reference,Capture

uDomain and vDomain are intervals of two floats, so you are feeding floats to the range() function which wants integers.

range ( start , stop [, step ])

This is a versatile function to create lists containing arithmetic progressions. It is most often used in for loops. The arguments must be plain integers.

Maybe try something like this instead:

#calculate uStep and vStep as you did originally
for i in range(intCount):
    for j in range(intCount):

Hey, I tried your option/suggestion, but now it shows some other errors. I checked rhino python primer and my code is an exact copy of that code. why its showing error? it should be working, isn’t it?

Sorry, I typed that a bit too quickly without checking, there are a couple of parentheses too many…

Should read:

#calculate uStep and vStep as you did originally
for i in range(intCount):
    for j in range(intCount):

Hey Helvetosaur,

Sorry to say but it still has no improvements, shows the same error :frowning:

Below is some working code…

import rhinoscriptsyntax as rs

idSurface=rs.GetObject("Surface to frame",8,True,True)
intCount=rs.GetInteger("Number of iterations per direction",20,2)

for i in range(intCount+1):
    for j in range(intCount+1):
        if rs.Distance(pt,rs.BrepClosestPoint(idSurface,pt)[0])<0.1:

I added the +1 in range(intCount+1) so that you go all the way to the far edges of the surface in both directions.

are you sure you typed everything correctly from the primer? as far as the range problem and floats VS integer, use rs.frange
Edit: I wonder if some functionality changed between versions…or it was a typo. That script does work… with two edits:
use rs.frange in place of range
and change
pt = rs.EvaluateSurface(idSurface, [u, v])
pt = rs.EvaluateSurface(idSurface, u, v)

thankyou, it worked!

I typed code correctly, later when it wasn’t working I copy pasted it. still it did not worked. I’ll check rs,frange.