@builder boy said:
@tig said:
http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#split ???
This will only split a line into 2 segments with controllable proportions, I am looking for something more like this:
edge.divide(5) # for 5 equal-length segments
It'd be easily enough to make a custom 'divide' method that works as you want - you know the edge's starting length and therefore the length of one divided part. So simply iterate through the edge the number of divisions-1 nibbling off the appropriate proportion as another edge until you are done. I don't recommend extending the Edge class but more like this...
self.divide(edge,5)
calling this
def divide(edge=nil, num=nil)
return nil if not edge or edge.class!=Sketchup;;Edge
return nil if not num or not num.class==Fixnum or num<=1
len=edge.length
bit=len/num.to_f
num.times{
begin
nedge=edge.split(bit/len)
if nedge
edge=nedge
len=edge.length
end#if
rescue
puts 'Divide Error'
end
}
end
Which splits the specified edge into the specified parts...