Issues with the Follow Me Tool and API

I’m sure others have run into this as well so I want to put the question out there to see if anyone has found a solution to the issue.

I’m trying to use the follow me tool within the API to draw a quarter turn with the face being either round or rectangular however the arc does not terminate with orthogonal ends so the resulting solid or revolution is never 90 degrees as one would expect:

I’m just wondering if anyone else has found an easy solution in dealing with this.

There is a little hack you can do when drawing this manually by rotating the circle by half a segment but that doesn’t help much when drawing this via the API.

For the rectangular case I can simply draw the two arcs and lines and push push pull in the Z direction but for the oval or round case I am forced to used the follow me tool, or attempt some sort of edge algorithm that draws the entire thing manually.

Here is my method how to create the path, used long time ago one of my old plugin, I copy pasted here with my original comments, without modification, hope you will understand…

segment: the number of segments in the arc (Integer)
angle: the angle of the arc (radians)
radius: the radius of the arc (Length)

  # Get the vertices of curve of bend. If we are using 'arc', the start and end edge is not perpendicular to radius...
  # so the "extruded" bend looks ugly... Here we will modify the 'arc' start and end edges
  # I like this more than other method... :-)
  # The bend will be created in the origin of model (0,0,0), 
  # then later on will be transformed to desired place.
c = []
0.upto(segment) do |i| # according to bend segments we are doing something on each vertex
# Normally the vertices coordinates calculated by simple sin/cos rule  
  c[i] = Geom::Point3d.new 0,radius-radius*Math.cos((i*angle/segment)),radius*Math.sin((i*angle/segment))

  # the second point y-cord will be same as first point y-cord, 
  # so the first edge will be perpendicular to base circle (parallel to z axis)
  if i == 1 
    c[i] = Geom::Point3d.new 0,radius-radius*Math.cos(((i-1)*angle/segment)),radius*Math.sin((i*angle/segment))
  end #if
  
  # The vertex before last must be moved too:
  if i == (segment-1)
     c[i+1] = Geom::Point3d.new 0,radius-radius*Math.cos(((i+1)*angle/segment)),radius*Math.sin(((i+1)*angle/segment)) # we need the last point
    # get a vector what is perpendicular to last radius edge:
     v2 = Geom::Vector3d.new 0,Math.sin(((i+1)*angle/segment)),Math.cos(((i+1)*angle/segment))
    # this vector is perpendicular to v2
     v1 = Geom::Vector3d.new 0,-Math.cos(((i+1)*angle/segment)),Math.sin(((i+1)*angle/segment))
    # if only two segments this vector is perpendicular to first radius edge
     v1 = Geom::Vector3d.new 0,Math.sin(((i-1)*angle/segment)),Math.cos(((i-1)*angle/segment)) if segment == 2
    # line from before last vertex
     line1 = [c[i],v1]
    # line from first vertex if only two segments
     line1 = [c[i-1],v1] if segment == 2
    # line from end vertex
     line2 = [c[i+1],v2]
    # intersect the two line will give the right vertex
     c[i] = Geom.intersect_line_line(line1, line2)
  end #if
end #upto


path = Sketchup.active_model.entities.add_curve(c)
#or 
#path = Sketchup.active_model.entities.add_edges(c)

Follow Me can’t draw arcs. Only full circles or straight edges produce correct geometry.

I made my own custom code that calculates the vertex positions along the extrusion and draws in the faces.

That is what I was afraid of. I do like the idea of creating the face then rotating/copying it multiple times and then connecting the appropriate edges to create the face, however this seems like so much more effort than to just use the built-in follow me method/tool.

After some more fiddling with the follow me tool, one can generate the quarter turn but the path needs to be adjusted as shown:

1 Like

There are many, many posts by Dave and others that tell the forum that the followme face must be perpendicular to the path. So, yes adjusting your path so that it starts and ends perpendicular to the face’s plane is the right way.


Why are your solids inside-out ?

1 Like

That start face needed to be reversed, I’ll fix that when I implement my solution. I’m just trying to figure out the easiest and most practical way to address this topological problem caused by the Follow Me tool.

P.S.
I’ve posted a new post but it says waiting approval. I’ve never seen this before in the forum. Is it because I posted code?

1 Like

did you use a word starting with cra and ending with ck in it ? like “I craked it” or something ?
they are trying an antispam that would send messages with specific words to moderation.

I’ve dropped the middle c to avoid it.

1 Like

Okay, let’s try this again. I did not know that certain commonly used words were banned. Here is my first attempt at this, maybe a little clunky and not 100% robust yet but it does seem to work:

entities = Sketchup.active_model.active_entities
start_angle = 0
end_angle = 90.degrees
xaxis = Geom::Vector3d.new(1, 0, 0)
normal = Geom::Vector3d.new(0, 0, 1)
center = Geom::Point3d.new(0, 0, 0)
segments = 5
radius = 12.0

def add_arc_with_tangents (center, xaxis, normal, radius, start_angle, end_angle, segments, entities)

	theta = (end_angle - start_angle).abs
	phi = theta/(segments * 2.0 + 2.0)

	start_angle0 = start_angle + phi
	end_angle0 = end_angle - phi

	radius0 = radius/(cos(phi))
	ext = radius0 * sin(phi)
	
	arc = entities.add_arc(center, xaxis, normal, radius0, start_angle0, end_angle0, segments)

  	arc_points = arc.map { |edge| edge.start.position }
  	arc_points << arc.last.end.position

	xaxis_radius = xaxis.clone
	xaxis_radius.length = radius

	pt_xaxis = center.offset(xaxis_radius)

	trot0 = Geom::Transformation.rotation(center, normal, start_angle)
	pt0 = pt_xaxis.transform(trot0)

	trot1 = Geom::Transformation.rotation(center, normal, end_angle)
	pt1 = pt_xaxis.transform(trot1)

    	# start_edge = entities.add_line(arc_points[0], pt0)
    	# end_edge = entities.add_line(arc_points[-1], pt1)
	# curve_array = [start_edge, arc, end_edge].compact.flatten

	entities.erase_entities(arc)

	pt_curve_array = [pt0, arc_points, pt1].compact.flatten

	path = entities.add_curve(pt_curve_array)

	return path

  
end

add_arc_with_tangents center, xaxis, normal, radius, start_angle, end_angle, segments, entities