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)

EvanReeseEvanReese Member, Mentor Posts: 2,188 ✭✭✭✭✭

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

Best Answer

  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 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 --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 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 --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • EvanReeseEvanReese Member, Mentor Posts: 2,188 ✭✭✭✭✭

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

    Evan Reese
  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 PRO

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

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
Sign In or Register to comment.