Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Creating consistent lines in a path
eric_ma454
Member Posts: 14 ✭
Currently, I have a query of lines from input, and I wish to create a path, and then analyze them as lines in order. Currently, I have:
var path = constructPath(context, definition.edges);
var nLines = size(path.edges);
var tangentLines = evPathTangentLines(context, path, range(0,1,nLines));
I am accessing the lines through tangentLines.tangentLines[index]. However, when debugging the lines in a part studio with a basic sketch, upon adding more lines (starting around 4-5 lines), some lines seem to get skipped over, while others have multiple debug vectors. Is there a consistent way to get an array/map of all distinct lines in order of a path, from one end to another?
Best,
Eric Ma
I am accessing the lines through tangentLines.tangentLines[index]. However, when debugging the lines in a part studio with a basic sketch, upon adding more lines (starting around 4-5 lines), some lines seem to get skipped over, while others have multiple debug vectors. Is there a consistent way to get an array/map of all distinct lines in order of a path, from one end to another?
Best,
Eric Ma
0
Best Answers
-
konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭if your path consists of linear edges only, and you need a line of each edge in the path order then you need to iterate through the edges and evaluate the line of eachfor (edge in path.edges){var L = evLine(... edge);}1
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@eric_ma454
For some context on why this is happening, evPathTangentLines divides up the path by the total length. So if some of the lines are long and some are short, you can imagine that an equal division based on length may not actually hit all of the lines. @konstantin_shiriazdanov 's solution will provide you with what you need, but you may also have to flip the direction if you need the edge directions to be constantly "forward" in the path:for (var i = 0; i < size(path.edges); i += 1) { var edgeLine = evLine(context, { "edge" : path.edges[i] }); if (path.flipped[i]) { edgeLine.direction *= -1; } }
If your edges are not guaranteed to be linear, you may want to replace evLine withevEdgeTangentLine(context, { "edge" : path.edges[i], "parameter" : 0.5 });
to get the tangent line at the middle of the edge.Jake Rosenfeld - Modeling Team1 -
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@eric_ma454
Since tangentLines is an array of all the lines you've processed so far, you need:tangentLines[i].direction *= -1;
nottangentLines.direction *= -1;
Jake Rosenfeld - Modeling Team1
Answers
IR for AS/NZS 1100
For some context on why this is happening, evPathTangentLines divides up the path by the total length. So if some of the lines are long and some are short, you can imagine that an equal division based on length may not actually hit all of the lines. @konstantin_shiriazdanov 's solution will provide you with what you need, but you may also have to flip the direction if you need the edge directions to be constantly "forward" in the path:
If your edges are not guaranteed to be linear, you may want to replace evLine with
evEdgeTangentLine(context, { "edge" : path.edges[i], "parameter" : 0.5 });
to get the tangent line at the middle of the edge.Thank you for the answer, this method worked very well. However, it seems that if I select lines in the precondition out of order of a path, it throws an error. Is there any way to fix this?
https://cad.onshape.com/documents/b3341e1949df657d55730d83/w/10c62cb1d20fa73f85db9b2f/e/39b17b46a08eb0173e635858
Since tangentLines is an array of all the lines you've processed so far, you need:
not