Followme at midpoint of line

Has anyone ever tried doing a followme starting at the midpoint of a line. Or a C-shaped path with the face in the center of the C. I can only seem to get it to extrude along one leg of the C.

Care to share your code? I’ve never tried it no, though sometimes all it takes to fix an issue is another set of eyes.

This is the gist of it:

> new_face552 = entities552.add_face pt1, pt2, pt3, pt4, pt5, pt6, pt7
> 	
> path1 = [0,@gutter_start,0]
> path2 = [0,@gutter_end,0]
> path12 = [0,yvalue,0]
> 
> path1b = [@Returnext,@gutter_start,0]
> path2b = [@Returnext,@gutter_end,0]
> 	
> 
> line1a = entities552.add_line path1, path12
> line1b = entities552.add_line path12, path2
> line2 = entities552.add_line path1, path1b
> line3 = entities552.add_line path2, path2b
> 	
> 
> pathedges = line1a.all_connected
> 
> status_followme = new_face552.followme(pathedges)
> 
> entities552.erase_entities(pathedges)

always go back to basics when stuck…

model = Sketchup.active_model
ents  = model.active_entities
pts = []
pts[0] = [  0,   0, 0]
pts[1] = [100,   0, 0]
pts[2] = [100, 100, 0]
pts[3] = [  0, 100, 0]
# Add the path
path = ents.add_edges(pts)
pts = []
pts[0] = [ 0,  5, -5]
pts[1] = [ 0,  5,  5]
pts[2] = [ 0, -5,  5]
pts[3] = [ 0, -5, -5]
# Add the face NB: pts order flips the face
face = ents.add_face(pts.reverse)
# follow the path
face.followme(path)

edit: fixed typo…
john

This is what I’m trying to do:

model = Sketchup.active_model
ents  = model.active_entities
pts = []
pts[0] = [  0,   0, 0]
pts[1] = [100,   0, 0]
pts[2] = [100, 100, 0]
pts[3] = [  0, 100, 0]
# Add the path
path = ents.add_edges(pts)
pts = []
pts[0] = [ 105,  50, -5]
pts[1] = [ 105,  50,  5]
pts[2] = [ 95, 50,  5]
pts[3] = [ 95, 50, -5]
# Add the face NB: pts order flips the face
face = ents.add_face(pts.reverse)
# follow the path
face.followme(path)

Is this the basic shape you’re looking to achieve?

image

Here’s what happens when I try to do the follow me manually.

What’s preventing you from drawing the square on either end of the path? Like so:
image

That’d surely solve your problem although I don’t know the use case. I don’t have any experience with using follow me with the face not located at the beginning of the path.

If the above option isn’t going to work you could try creating 2 paths and do 2 follow me operations.

EDIT: I didn’t see john’s post when I wrote this out. So I take it his approach won’t work?

I guess the correct solution is to put the face at the end of the path.

The reason for having it at the middle (or any point along the path for that matter) is because of the way I am creating the face geometry for other path geometries.

Some paths will be a simple straight line, some will be all over the place but the one thing they have in common is the location of the middle path. So it would be easier for me to draw the face always in the same location.

this nearly does it…

need to sort out winding order to avoid reversed faces…

model = Sketchup.active_model
ents  = model.active_entities
pts = []
pts[0] = [  0,   0, 0]
pts[1] = [100,   0, 0]
pts[2] = [100,  50, 0]
pts[3] = [100, 100, 0]
pts[4] = [  0, 100, 0]
# Add the paths
path1 = ents.add_edges(pts[0..2])
path2 = ents.add_edges(pts[2..-1])
pts = []
pts[0] = [ 105,  50, -5]
pts[1] = [ 105,  50,  5]
pts[2] = [ 95, 50,  5]
pts[3] = [ 95, 50, -5]
pts[4] = [ 105,  50, -5]
# Add the face NB: pts order flips the face
face1 = ents.add_face(pts.reverse)

# follow path1
face1.followme(path1)

face2 = ents.add_face(pts)
# follow path2
face2.followme(path2)

# erase the edges by re adding them
fedges = ents.add_edges(pts)
ents.erase_entities(edges)

john

I suppose one solution would be to create two different extrusions in separate groups and then outer shell them into a single solid, seems a lot of work but I don’t see an easier way to do it.

Could you transform the points of the face-to-be from the middle, to the end of the supplied path?

You could also outer shell them to avoid the intersection line like you were saying.

EDIT: The more I think about it the more the transformation idea seems less feasible.

You could set the face’s normal equal to the direction of the last edge… but I imagine there are quite a bit of obstacles I’m not taking into account.

What would be the best way to transform the face? I’ve only been able to transform groups and components.

Depends on what constraints you have I suppose. I don’t think I’m the person to ask for the best way to do anything but I was thinking more transforming the points before the face was created. I wasn’t very clear.

You could create the face in a group or add the face to a group and transform it that way if that’s the way you’re comfortable with.

As you say it just might be easiest to build the geometry where you need it and copy and paste it to the end of the path. Grouping it with an additional line in it to align it to the same position on the path would keep it accurate.

@whiterabbitdesigncompany, how do you do that in the Ruby API?

john

model = Sketchup.active_model
ents  = model.active_entities
pts = []
pts[0] = [  0,   0, 0]
pts[1] = [100,   0, 0]
pts[2] = [100, 100, 0]
pts[3] = [  0, 100, 0]
# Add the paths
path1 = ents.add_edges(pts)
pts = []
pts[0] = [ 105,  50, -5]
pts[1] = [ 105,  50,  5]
pts[2] = [ 95, 50,  5]
pts[3] = [ 95, 50, -5]
pts[4] = [ 105,  50, -5]
# Add the face NB: pts order flips the face
face1 = ents.add_face(pts.reverse)

point  = face1.bounds.center
vector = Z_AXIS
angle  = 90.degrees 
t1 = Geom::Transformation.new(point).inverse
t2 = Geom::Transformation.rotation(point, vector, angle)

ents.transform_entities(  t2  , face1.all_connected  ) 
ents.transform_entities(  t1  , face1.all_connected  )
# follow path1
face1.followme(path1)

john

2 Likes

I decided to go the route of creating two groups and then outer shelling them into on group at the end.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.