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

EvanReese
EvanReese Member, Mentor Posts: 3,099 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: 472 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: 472 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,099 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: 472 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