Best way to query threaded faces (tapped Hole and External Thread)
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.
Best 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 Applications1
Answers
-
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 Applications1 -
Aw man, that's what I was starting to do, but it felt wrong somehow. Thanks, Caden!
1 -
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 Applications1
