Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Custom Feature: Query Variable+
Derek_Van_Allen_BD
Member Posts: 315 PRO
-Link to feature up front-
Query Variable has been a game changer for more programmatic workflows that save me from needing to develop custom scripts when I can instead pass other existing features through a QV and get results that way. That being said, there are some more powerful querying techniques which haven't yet been added to the default Query Variable implementation that I'm taking some time to write into an extended toolset. For example: just about everything in the old Query Explorer feature could be used as a QV to enable more parametric workflows involving spatial, geometric, or directional filtering of your queries. My long term goal is to implement all of these Query Explorer features into the new Query Variable feature but I'm starting out small with a few easier lift features and will add more over time.
The first two features in my Query Variable+ implementation are the following:
Tangent(ish) Faces
This one is simple, the qTangentConnectedFaces() function in the standard library already has an overload which allows you to specify an angle tolerance for some flexibility in the definition of the word "tangent" so I just replaced the version in Query Variable with this angular tolerance version. This lets me flood select face groups from cursed not-mesh import geometry and use the selections to create patch faces and create new clean parametric surfaces without having a feature tree to work with.
This is not a mesh.
But with a little bit of curve approximation and resurfacing later it can become usable geometry again. Selecting groups of nearly tangent faces made this much easier to execute.
Matching Bodies
Query Variable comes with the ability to select matching edges or matching faces, why not matching bodies? Well the qMatching feature doesn't allow this selection type so that's why it's not allowed here, but there's a similar function called clusterBodies that does something close to this for cut list purposes. I leveraged this into a qMatchingBodies function that allows you to select a part and the function will return all parts in the studio that clusterBodies identifies as a geometric match for the input. (With some tolerance)
Useful for workflows where you're working with repetitive geometry that's not necessarily the result of a pattern, or if you've willfully ignored the "best practices" instructions of assembly modeling workflows and need to check that your parts actually are still copies of each other at the end of the tree.
Other features I'd like to implement into the list from Query Explorer:
- Geometry filters for face types
- Distance filters
- Direction filters
- Attribute filters for sheet metal and frames
- Cap entity filters
- …And more things I'm sure will be useful to someone at some point that I have yet to discover



Comments
YES! I'm glad you're taking this on. It needs to be a thing.
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
qAdjacent functionality added. Kinda wild that this one wasn't in the original Query Variable implementation actually.
If you look closely there's the seeds of another useful featurescript in here too.
Derek Van Allen | Engineering Consultant | MeddlerIf you look closely there's the seeds of another useful featurescript in here too.Hmm. The Median curves? I had no idea there was functionality for that in Parasolid.
Simon Gatrall | Product Development Specialist | Open For Work
There isn't, as far as I know. That tab is an extrude with an 89 degree draft, a query variable to grab all the edges of that operation and another one to subtract all edges adjacent to the first input face, and a projection of the remainder onto the input face. It's one of a few methods of medial axis approach and is somehow way more performant than the delaunay method I was working on before. Could use some size comparison threshold filtering though, which will be one of the things I add to QV+. Could turn into its own script when the concept is proven, and actually a lot of use cases for QV+ could be turned into dedicated scripts based on concept studios like this one.
Derek Van Allen | Engineering Consultant | MeddlerqGeometry support added. Now you can filter by all the things that qGeometry lets you filter by and use them as an input in future operations. Edge filtering for straight lines vs arcs vs other curves could have some utility for frames features. Face filters have some less obvious use cases but I could see them being handy for working with stubborn import geometry.
If you're following along with these additions and have suggestions on which query functions to tackle next let me know and I'll slot them into a future update. Probably next is gonna be fillets and direction queries.
Derek Van Allen | Engineering Consultant | MeddlerHi Derek,
I've had needs for qCapEntities before, so that'll be very useful!
Jelte
Hi @Derek_Van_Allen_BD :
I was in need of the qCapEntities Filter and created it myself as an additional option filter to "Is Created By"
feel free to add it to your query variable+ to prevent clutter. I'd rather contribute to your good query variable + version, then create a whole bunch of new ones…
Just ctrl-F for: "//added by for Cap Filter by Jelte" … "//end added by Jelte" and copy paste those bits. (after a bit of review and checking perhaps):
https://cad.onshape.com/documents/d235b229e9002129febbb90e/w/4681d88c2fa02968068670d3/e/4243c76ef0022c2f4089c1f7?renderMode=0&uiState=690ddcf38ff2a03fae52d925
AND then I went for a walk and realised a better way to implement it that's more compliant to the original Query Variables UI. So please disregard v1 and use V2 wich requires 11 small code changes/additions…