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.

How to determine if an edge is a line or an arc

gaetan_vincentgaetan_vincent Member Posts: 2

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

Answers

Sign In or Register to comment.