@ Liero: What do think about this slight modification to the script?
Basically instead of one long cast till we hit a wall do a bunch of short jumps. If the ray_cast fails then the previous end point becomes the new start. I think this might help when it comes time to animate the growth of the line. Currently if the script encounters a long open path way you only get a single point along that section which causes a big jump in the line growth for animation.
def bounce(obj, number):
dist = 10 # Make smaller jumps.
points = 
data = obj.data.polygons
n = r.randint(0, len(data)-1)
end = data[n].normal.copy() * -1
start = data[n].center
last_nor = [0.0,0.0,0.0]
for i in range(number):
end += noise(.25)
hit, nor, index = obj.ray_cast(start, end * dist)
if index == -1:
# Instead of just giving up set the new start to our last end.
hit = end
start = end
start = hit - nor / 10000
end = end.reflect(nor).normalized()
Just trying to balance the distance betweens points for smoothing growth animation.