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.
How to determine if an edge is a line or an arc

Ok, so I am new to FS, but not new to programming. So far I am really loving and praising onShape and even praising it, but I have now been struggling with this for days, searching the forums and searching google for examples on how to do this. I have tried many different ways to accomplish this from the few similar examples I have been able to find, and have not yet been able to figure out what I assumed to be a simple task.
All I am trying to do is to let the user select a face ( either from a sketch or an extrusion), retrieve all the edges that make up this face, and determine if each edge is a line or an arc. Once I have accomplished that, I will try to extract the start and end points of those edged and the center point if it is an arc, from there try to do things like offsets and more. But one step at a time.
With the following code I know that I am retrieving the edges using qLoopEdges because the for-loop does loop through the number of items that make up the face I have selected. However, I cannot find how to manipulate those edges once I do have them. Using canBeCircle and canBeLine was my last attempt out of 20-30 other trials to get this to work.
FeatureScript 2656;
import(path : "onshape/std/common.fs", version : "2656.0");
annotation { "Feature Type Name" : "Looper", "Feature Type Description" : "" }
export const looper = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
definition.face is Query;
} { var edges = qLoopEdges(definition.face); var queryArray = evaluateQuery(context, edges); for ( var i = 0 ; i < size(queryArray); i+=1 ) { if (canBeLine( queryArray[i])) { println("Edge " ~ toString(i+1) ~ " is a line."); } else if(canBeCircle(queryArray[i])) { println("Edge " ~ toString(i+1) ~ " is an arc."); } else { println("Edge " ~ toString(i+1) ~ ": is unknown."); } } });
Any input is greatly appreciated
Gaetan
Best Answer
-
MichaelPascoe Member Posts: 2,315 PRO
.
qGeometry should do it.
https://cad.onshape.com/FsDoc/library.html#qGeometry-Query-GeometryType...
Also, here is another way to check if its an arc:
var diameter = undefined; try silent { diameter = evCurveDefinition(context, { "edge" : queryArray[i] }).radius; } var isArc = diameter! = undefined;
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴0
Answers
.
qGeometry should do it.
https://cad.onshape.com/FsDoc/library.html#qGeometry-Query-GeometryType...
Also, here is another way to check if its an arc:
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
unless you're trying to do something specific with the offsets, there may be a quicker solution.
import topologyUtils.fs and use getThinWallRegions function.
it's how onshape's 'thin' tabs operate in e.g. extrude and revolve.
If you 'go to definition' or look at onshapes native features, you'll be able to figure out what keys in the definition map to use.
good luck!
Thank you @MichealPascoe!
qGeometry does not really work as I need all edges of the face. As of now I was only using lines and circles/arcs to create my faces, but eventually I could see those faces becoming more complex. evCurveDefinition, however, definitely does the trick along with canBeLine and canBeCircle to do the identification.
@jelte_steur814
Thanks for that info, sounds interesting , but also a little too advance for me for now, but I will definitely be looking into it further down the line. I have realized that I didn't really understand how maps worked in FS and which was also causing my confusion in the use most of the functions.
Since I work better with examples