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.

Featurescript – Fillet a sheet metal part using edges attribute

guillauem_dguillauem_d Member Posts: 16

Hello there !

I’d like to be able to fillet sheet metal parts corners through Featurescript, using the attribute of edges.

For the moment, I managed to create fillets like so :

  • Select the edge using annotation { "Name" : "My Query", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 } definition.entitiesHomemade is Query;
  • Create the fillet using available public code such as sheetMetalCornerBreak or C2CfullRoundFillet (because opFillet doesn't work on sheet metal parts)

This method works great, but these public functions need as input the edge Query from annotation. Now i’d like to do the same thing but using the attribute ("JMN") of my edge.

To do this I tried transforming my attribute into a query using qHasAttribute("JMN") or qOwnedByBody(qHasAttribute("JMN"), EntityType.EDGE)) but it doesn’t work.

Any tips ?

Thank you 😊

Best Answer

  • MichaelPascoeMichaelPascoe Member Posts: 1,989 PRO
    edited October 9 Answer ✓

    Gotcha. Here is how you can convert the transient id array back into a query of edges:
    https://cad.onshape.com/documents/28b6b8878dbecd49e8c8d643/w/db4da420a14d…

    /**
     * Example function to convert the transient id's to a query.
     */
    function GetQueryFromTransientIdList(context is Context, transientIdList is array) returns Query
    {
        const allBodyEdgesQuery = qOwnedByBody(qAllSolidBodies(), EntityType.EDGE);
        var evaluatedAllBodyEdges = evaluateQuery(context, allBodyEdgesQuery);
        var output_edges_query = qNothing();
    
        for (var edge in evaluatedAllBodyEdges)
        {
            for (var transientId in transientIdList)
            {
                if (transientId == edge.transientId)
                {
                    output_edges_query = qUnion([output_edges_query, edge]);
                }
            }
        }
    
        return output_edges_query;
    }
    


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴

Answers

  • MichaelPascoeMichaelPascoe Member Posts: 1,989 PRO

    Please share a link to your document so we can help you better.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • guillauem_dguillauem_d Member Posts: 16

    Thank you for helping out MichealPascoe ! 😁

    Here is the link to a minimal reproducible example :

    • fillet_from_user_selection() works great and create a fillet according to user’s edge selection
    • print_transient_id_of_edges_on_z_axis() allows me to find the transient id of some edges, then I try to use fillet_from_edge_attribute() which is the same code as fillet_from_user_selection() except that it takes as input the transient id of the edge, but runing this function doesn’t work

  • MichaelPascoeMichaelPascoe Member Posts: 1,989 PRO
    edited October 9

    What is your end goal?
    I'm confused why you are trying to use attributes if your goal is to simply fillet all edges parallel to the Z_Axis.


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • guillauem_dguillauem_d Member Posts: 16
    edited October 9

    Sure! Let me clarify what I’m trying to do 🙂:

    1. I created a Python interface that communicates with the Onshape REST API to build very basic parts.
    2. For example, I tell the Python code to create a square sheet metal part.
    3. The code then triggers a FeatureScript function via the API that generates that square sheet metal part.
    4. Afterward, the API returns attributes for all the edges and surfaces of the part.
    5. If I want to create a hole on the top surface (let’s say the surface with the attribute ‘JDP’), I instruct the Python code to create a hole on 'JDP,' and it executes the appropriate FeatureScript (this part works perfectly). From step 1 to 5, everything works.
    6. Now, I’d like to create a fillet on specific edges, such as ‘JMN’ . However, since a sheet metal is a special object, I can't use the standard opFillet(). I’ve worked around this by using sheetMetalCornerBreak(), but it only works when I use a user annotation query as input (i.e by selecting the edge directly on the onshape interface, not something i can do from python code). Now i'd like to use the attribute as input.

    So to sum it up, in the python interface, i give the user attribute of all important elements, so that if i want to modify them or interact with them, i can do it.

    I hope this explanation clears things up!

  • MichaelPascoeMichaelPascoe Member Posts: 1,989 PRO
    edited October 9 Answer ✓

    Gotcha. Here is how you can convert the transient id array back into a query of edges:
    https://cad.onshape.com/documents/28b6b8878dbecd49e8c8d643/w/db4da420a14d…

    /**
     * Example function to convert the transient id's to a query.
     */
    function GetQueryFromTransientIdList(context is Context, transientIdList is array) returns Query
    {
        const allBodyEdgesQuery = qOwnedByBody(qAllSolidBodies(), EntityType.EDGE);
        var evaluatedAllBodyEdges = evaluateQuery(context, allBodyEdgesQuery);
        var output_edges_query = qNothing();
    
        for (var edge in evaluatedAllBodyEdges)
        {
            for (var transientId in transientIdList)
            {
                if (transientId == edge.transientId)
                {
                    output_edges_query = qUnion([output_edges_query, edge]);
                }
            }
        }
    
        return output_edges_query;
    }
    


    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • guillauem_dguillauem_d Member Posts: 16

    Wow, that’s brilliant!

    Thank you so much @MichaelPascoe, You saved me from going insane after struggling with this for three days! ! 😅

Sign In or Register to comment.