I'm creating a macro that will create a pattern that is driven by two bounding features. The part would have an extrusion feature with its direction Up To Vertex.
1) Select a control path. This path is the upper bound of the feature direction axis.
2) Select number of instances that you want total.
3) Select the feature that you want to replicate. Upon selecting the feature, the macro will retrieve the line segment for the direction and the line segment for the normal on the surface. These will be used for creating the library feature and for inserting the library feature. Also, the lower bounding feature (terminating feature) is found from the selected feature to replicate.
4) *PROBLEMS*
After clicking the check mark, the macro generates the direction and normal line segments for use for the library feature placement (which I have deactivated for now). For each direction line segment, the macro places one of the endpoints correctly on the upper curve. However, for the other endpoint the macro will
1. not place the endpoint on the terminating feature if the terminating feature is a face of a feature or a surface
Run macro on parts "term surface.SLDPRT" and "term partface.SLDPRT". Run with pattern instances = 7
2. place the endpoint on the terminating feature if the terminating feature is an edge or sketch but the sketch is over defined because there is a conflict between the perpendicular constraint of the direction line and the coincident constraint of the endpoint on the terminating feature.
Run macro on parts "term edge.SLDPRT" and "term sketch.SLDPRT". Run with pattern instances = 7
To get an idea of what the end result should look like, run "term plane.SLDPRT"
You can run the macro called "main". This will bring up the userform so you can make selections.

That's what I have been using to create the spline. The thing I don't understand is that I'm able to make a coincident relation as well as a perpendicular relation for the features driving sketch for the direction.
I haven't looked into this, but you have the ability to create a "Spline On Surface" where the entire curve lies on the surface, rather than just the control points. You could have a look at creating one of those and then you wouldn't have to worry about the "ribbon" surface.
I had my suspicions about the curve on the surface too. I hoped to avoid creating any more geometry but I guess this would be the only solution to solving this issue. Would the endpoints end "on" that curve if I end them on the ribbon? Thanks for the help.
I don't think the curve in 3DSketch52 lies completely on the surface. The control points do, but not necessarily the segments of curve between them.
I think you may need to create a ribbon surface along that curve and make an On Surface relation to that.
Example attached.
I have fixed all the surface/face problems and used the face of the edge instead of the edge if the terminating feature is an edge. I still can't wrap my head around why the constraints for the 3D sketch doesn't work. If anyone else wants to rack their brain on this issue, the problem arises when running the macro on "term sketch.SLDPRT". Just follow the procedure laid out in the first post.
Updated macro
Hi Harold
I took a quick look before but unfortunately you are a future version to me so I couldn't really do anything.
One thing I noticed is that you are missing a call to
2018 SOLIDWORKS API Help - AddToDB Property (ISketchManager)
Here's the remark from the help
One of the benefits of adding sketch entities directly to the database is that you can avoid grid and entity snapping. For example, if you create a sketch line whose endpoint is near another entity or near a grid point, the new line endpoint snaps to the other item or grid point. Setting ISketchManager::AddToDB to true avoids this behavior during sketch entity creation.
That solved the problem for faces. Now I just need to figure out what is going on with the sketch contraints. Thanks.
For the term surface.sldprt model, I think you need to be selecting the face of the termFeat rather than the feature itself.
So, call termFeat.GetFaces. Get the first face in the array. Cast it to an IEntity and then select it.
Something like:
Dim swFaces as Variant
swFaces = termFeat.GetFaces
If Not IsEmpty(swFaces) Then
Dim swEntity as Entity
Set swEntity = swFaces(0)
swEntity.Select4 True, Nothing
End If