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.

Best way to query threaded faces (tapped Hole and External Thread)

EvanReese
EvanReese Member, Mentor Posts: 3,059 PRO

I'm working on a feature that needs to find faces with hole attributes or external thread attributes. Can this be done with qHasAttribute()? I'm not sure where to find the "name" to filter for.

Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com

Best Answer

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 462 PRO
    Answer ✓

    I think holes were made before named attributes were a thing, so they are found based on the value pattern.
    You have to take a query of seed faces and check which faces have the attribute pattern:

        var seedFaces = qEverything(EntityType.FACE);
    
    
        for (var f in evaluateQuery(context, seedFaces))
        {
            var attributes = getAttributes(context, {
                    "entities" : f,
                    "attributePattern" : {} as HoleAttribute }
            );
            if(size(attributes) > 0)
            {
                println(attributes);   
            }
        }
    
    
    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications

Answers

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 462 PRO
    Answer ✓

    I think holes were made before named attributes were a thing, so they are found based on the value pattern.
    You have to take a query of seed faces and check which faces have the attribute pattern:

        var seedFaces = qEverything(EntityType.FACE);
    
    
        for (var f in evaluateQuery(context, seedFaces))
        {
            var attributes = getAttributes(context, {
                    "entities" : f,
                    "attributePattern" : {} as HoleAttribute }
            );
            if(size(attributes) > 0)
            {
                println(attributes);   
            }
        }
    
    
    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications
  • EvanReese
    EvanReese Member, Mentor Posts: 3,059 PRO

    Aw man, that's what I was starting to do, but it felt wrong somehow. Thanks, Caden!

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Caden_Armstrong
    Caden_Armstrong Member Posts: 462 PRO

    You could start with a smaller seed query by taking all the faces and putting it through qHoleFaces

    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications