@kasper_steenstrup wrote:
Hello I am trying to creat a grid of points, where only the point inside a surface should be set.
To do this I use IsPointInSurface
The problem is that I get a huge time difference depending on the setup.Depending on the point setup I get a huge diffrence in time as show below.
point1 = [b0+x*d_x, b1+y*d_y, b2+z*d_z] 17 sec point2 = [b0+x*d_x, b1+y*d_y, b2+z] 2 secIs this because point1 is more inside the surface? se the code below
Are there any way of profiling the code more in deapth? python have the profiling tool cProfile which do not work native in the rhino python
best kasper
import rhinoscriptsyntax as rs import random import timeit rs.EnableRedraw(False) surface = rs.GetObject("pick a surface") bounding_box = rs.BoundingBox(surface) shape = [25,25,25] d_x = (bounding_box[1][0] - bounding_box[0][0])/float(shape[0]-1) d_y = (bounding_box[2][1] - bounding_box[0][1])/float(shape[1]-1) d_z = (bounding_box[4][2] - bounding_box[0][2])/float(shape[2]-1) b0 = bounding_box[0][0] b1 = bounding_box[0][1] b2 = bounding_box[0][2] a = 0 start = timeit.default_timer() for x in range(shape[0]): for y in range(shape[1]): for z in range(shape[2]): point = [b0+x*d_x, b1+y*d_y, b2+z*d_z] if rs.IsPointInSurface(surface, point, False, 0.01): a += 1 print str(timeit.default_timer() - start) + " sec" start = timeit.default_timer() for x in range(shape[0]): for y in range(shape[1]): for z in range(shape[2]): point = [b0+x*d_x, b1+y*d_y, b2+z] if rs.IsPointInSurface(surface, point, False, 0.01): a += 1 print str(timeit.default_timer() - start) + " sec" rs.EnableRedraw(True)
Posts: 1
Participants: 1