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.
edge query to map
nathan_shaffer
Member Posts: 11 ✭✭
How do I get all of the lines for edges in a query?
evLine wants an edge, how do I unpack the query to feed into evLine?
annotation {"Name": "Edges","Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 2 }
definition.edges is Query;
var lines = evLine(context, qEntityFilter (definition.edges, EntityType.EDGE));
0
Comments
-
You need to evaluate the query to make it into an array of queries with one edge each, then loop over the array and evLine each one. Here's an example.
// Gets the edges of the selected face const edgesOfFace = qLoopEdges(definition.face); // Makes the one big query into an array of individual queries for just one edge each const edgesAsArray = evaluateQuery(context, edgesOfFace); // make an empty array to collect the lines from the loop var linesArray = []; // iterate over each edge for (var edge in edgesAsArray) { try { // evLine on only one entity const edgeLine = evLine(context, { "edge" : edge }); // Display the line and print it's contents to the FS notices panel debug(context, edgeLine, DebugColor.RED); // add this line to the array, so we have them all together once the loop is done. linesArray = append(linesArray, edgeLine); } // if the edge isn't a straight line, evLine fails and we run the catch statement. catch (error) { reportFeatureInfo(context, id, "Non-line edges ignored."); } }1
