Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Connections array for opLoft not being applied

lucas_o_connor386lucas_o_connor386 Member Posts: 4

Hello! I have been working on creating a featurescript to loft together two identical spur gear profiles at a vertical and rotational (around Z) offset, creating a hyperboloidal profile. the gear profiles generate without issue, and there are no errors in the featurescript, in the code or generation, that are reported. The loft also works, successfully connecting the two profiles. However, it connects the two closest teeth (as opLoft defaults to). This nullifies the rotational offset, which defeats the purpose of the loft. I have created a connections array, which should pair the teeth correctly (by pairing the involute splines based on order, since rotation happens after sketch generation). The connections array is populated, and a debug highlight shows that the correct edges are paired. However, the connections array is not being applied, and instead the loft continues pairing by proximity. There is no difference in execution between commenting out the connections array in the loft and leaving it in.

The loft is possible, as I can achieve it manually; the part studio in the attached document has both the loft generated by the featurescript and the intended loft, created by manually selecting two edges on the sketches generated by the featurescript (the same first two splines in the connections array). Only using these two edges in the loft instead of the entire array also has no effect. I have tried pairing the addendum arcs, dedendum arcs, and also various sets of points instead of the spline curves, but none have had any effect.

I am new to featurescript, so I may have left out something basic; my knowledge of opLoft is just what I could find in the standard library and what worked in other featurescripts I looked at. Any help or potential fixes would be appreciated, as I am fine spending time to reach a solution, but don't currently know where to start. Thanks!'

https://cad.onshape.com/documents/73e5b2313b72b2da9038a95c/w/d38a726166e9ab1399a6e4ef/e/bf355c36e29c0decfdbc7a47

Answers

  • jelte_steur814jelte_steur814 Member Posts: 445 PRO

    I think you're connection definition doesn't satisfy the input opLoft is requiring.
    look at the documentation and especially the Example:

    your code generates maps with "startSubEntity" and "endSubentitity" instead which doesn't satisfy the required "connectionEntities", "connectionEdges", and "connectionEdgeParameters" maps required.

    from the documentation:

    connections (array):

    An array of maps to define multiple profile alignments. Each connection map should contain:

    (1) connectionEntities query describing an array of vertices or edges (one per profile),

    (2) connectionEdges an array of individual queries for edges in connectionEntities. The order of individual edge queries should be synchronized with connectionEdgeParameters.

    (3) connectionEdgeParameters array - an ordered and synchronized array of parameters on edges in connectionEdgeQueries

    EXAMPLE

    [ {"connectionEntities" : qVertexAndEdge1, "connectionEdges" : [qEdge1], "connectionEdgeParameters" : [0.25]} {"connectionEntities" : qVertexAndEdge2, "connectionEdges" : [qEdge2], "connectionEdgeParameters" : [0.75]}]

  • lucas_o_connor386lucas_o_connor386 Member Posts: 4

    Thanks, this likely was causing a problem, though what I instituted doesn't appear to have resolved the issue. I reformatted my connections array to look like this: (I removed the left side for simplicity since the effect should be the same)

    for (var i = 0; i < size(bottomResult.splineRightNames); i += 1)
    {

    connectors = append(connectors, [
    {
    "connectionEntities" : bottomResult.splineRightNames,
    "connectionEdges" : sketchEntityQuery(bottomResult.Id, EntityType.EDGE, bottomResult.splineRightNames[i]),
    "connectionEdgeParameters" : .5
    },

    {
    "connectionEntities" : topResult.splineRightNames,
    "connectionEdges" : sketchEntityQuery(topResult.Id, EntityType.EDGE, topResult.splineRightNames[i]),
    "connectionEdgeParameters" : .5
    }

    ]);

    }

    I would have assumed this would have resulted in the intended loft, but there is no visible effect from this either. Am I misunderstanding these parameters? I assume my problem has something to do with the connectionEntities section, where I am currently giving it the array of edges I am pairing in the connections array; this might refer to something else, but since it only takes edges or vertices I don't know what else it could want. I am giving the connectionEdges section the edges I wish to pair, same as before, and the connectionEdgeParameters should just mean they are paired at the midpoints, if I am correct. The result does not change if this is 1 or 0 either, so I doubt that is the problem.

    Thanks for the reply!

    PS: I'm new to these forums. Should I reflect these changes in the document I shared, share a copy with the changes, or just copy-paste code as above?

  • jelte_steur814jelte_steur814 Member Posts: 445 PRO

    one way of troubleshooting this I can think of is to create a second custom feature, copy-paste the native Loft feature in there, replace the native loft as intended in the part studio with the copied loft FS, and then add debug lines in it to check the difference between the syntax/result of the manually created loft connections from the copied FS, and your ows FS' loft connections.

Sign In or Register to comment.