I have possibly the same problem as this question: Why does face.followme crash Sketchup?
I have created a nice tapering spiral with this script. At the end I want to make the spiral thicker by using followme along the edges of the spiral.
Here is the script:
module Spiral
def self.make_circle_face(entities, circle_edges)
pts = []
circle_edges.each { |e|
pts << e.vertices[0]
}
face = entities.add_face(pts)
return face
end
def self.make_circle(entities, point, radius, normal)
# make a circle face at the point with the given radius
circ = entities.add_circle(point, normal, radius)
circ_face = self.make_circle_face(entities, circ)
return circ_face
end
def self.draw_turn(entities, segments, radius, taper_amount,
z, z_increment, facet_size, last_point)
(0..360).step(facet_size).each do |angle|
theta = angle.degrees
radius -= taper_amount
x = radius * Math.cos(theta)
y = radius * Math.sin(theta)
z += z_increment
point = Geom::Point3d.new(x, y, z)
line = entities.add_line(last_point, point)
segments << line
last_point = point
end
return [last_point, z, radius]
end
def self.draw(radius, taper_amount, z_increment, num_turns, facet_size, segments)
model = Sketchup.active_model
entities = model.active_entities
z = 0
y = 0
orig = Geom::Point3d.new(0,y,z)
endpoint = Geom::Point3d.new(radius, y, z)
spiral_group = entities.add_group
spiral_entities = spiral_group.entities
(0..num_turns).each do |turn|
endpoint, z, radius = self.draw_turn(spiral_entities, segments, radius,
taper_amount, z, z_increment, facet_size, endpoint)
end
return spiral_group
end # method draw
end # module Spiral
radius = 100
taper_amount = 0.1
z_increment = 0.5
num_turns = 4
facet_size = 2
segments = []
spiral_group = Spiral.draw(radius, taper_amount, z_increment, num_turns, facet_size, segments)
entities = spiral_group.entities
# create a small circle at the starting point
start_point = Geom::Point3d.new(radius, 0, 0)
normal = [0,1,0]
face = Spiral.make_circle(entities, start_point, 10, normal)
# uncomment this and crash happens
#face.followme(segments)
without the followme, it generates the spiral I want.
As soon as I add the followme at the end, sketchup crashes.
How can I do this correctly?
Thank you for any clues
-j_jones