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.

Query Explorer feature

kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
Hello FeatureScripters!

Learning what FeatureScript's queries can do is often a slow process of reading lots of documentation, and the number of different queries avaiable can be overwhelming during this phase!

To help make this easier, we've made a "Query Explorer" custom feature. This custom feature's dialog lets you play around with Onshape's query functions, using and combining them, and seeing what the results are in real time.



You can add the feature to your toolbar here, or make a copy of the document to play around with its samples.
https://cad.onshape.com/documents/a5d9b2a6211c9576e5747d3d/w/0a149e82759d30f76fc88bb6/e/db0fd8f10a5c8328d3232869

Happy FeatureScripting!

Comments

  • TimRiceTimRice Member, Moderator, Onshape Employees Posts: 315
    Did you make this so I stop bugging you and Jake for help all the time? Great feature! Thanks Kevin!
    Tim Rice | User Experience | Support 
    Onshape, Inc.
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭
    @kevin_o_toole_1

    How does the `convertToFs` function work? I tried opening its document, but it says I don't have permission.
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    I want to beleve this is some preparation to make possible to feed filtered queries to the native features. But I see you also faced the problem of too long user interface section. If we only had ability to pack more UI options into something like lookup table.
  • MichaelPascoeMichaelPascoe Member Posts: 1,989 PRO
    Thanks Kevin!

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • EvanReeseEvanReese Member, Mentor Posts: 2,148 ✭✭✭✭✭
    Kevin, this is really cool! thanks. I'm with @konstantin_shiriazdanov it would be sooo helpful for many things to have robust updatable selections built into the model. I'm kind of scratching that itch with my Selection Fillet feature, but the real deal would be something like a "Query Feature" that lets you set it all up, then call the query in any downstream features.
    Evan Reese
  • EvanReeseEvanReese Member, Mentor Posts: 2,148 ✭✭✭✭✭
    by the way. does anyone have any idea why this document is taking so long in "loading custom features and tables"? it's been spinning for over 10 minutes, and I can't add the feature
    Evan Reese
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    does anyone have any idea why this document is taking so long in "loading custom features and tables"?
    We're aware of this bug and working on a fix. In the meantime a workaround is to simply refresh the page.
  • john_mcclaryjohn_mcclary Member, Developers Posts: 3,936 PRO
    Oh nice! this should help a lot when trying to debug my fail queries.
  • EvanReeseEvanReese Member, Mentor Posts: 2,148 ✭✭✭✭✭
    does anyone have any idea why this document is taking so long in "loading custom features and tables"?
    We're aware of this bug and working on a fix. In the meantime a workaround is to simply refresh the page.
    got it. I tried another day and it worked.
    Evan Reese
  • lemon1324lemon1324 Member, Developers Posts: 225 EDU
    This is going to be amazingly helpful, thanks for putting this together!
    Arul Suresh
    PhD, Mechanical Engineering, Stanford University
  • S1monS1mon Member Posts: 2,991 PRO
    edited November 21

    Any chance of this being updated? I assume there have been updates to the query functionality since 2021.

    One thing I noticed is that I can't figure out a way to select a sketch feature and a sketch entity at the same time as seeds. There's also no option to create an implicit mate connector as part of the selection process.

    [edit: a quick search of the changelog shows at least one new query since 2021: "FeatureScript: New query for objects on one side of a plane ('qInFrontOfPlane')"]

  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭

    Changes in query.fs since 8th October 2020 (FS 1378):

    GeometryType now includes ALL_MESH and MIXED_MESH options.

    New functions:

    • qAllSolidBodies
    • qAllModifiableSolidBodiesNoMesh
    • qHasAttribute
    • qHasAttributeWithValue
    • qHasAttributeWithValueMatching
    • qOpHoleProfile
    • qOpHoleFace
    • qToleranceFilter (marked internal)
    • qSourceMesh with EntityType
    • qEdgeVertex (for getting the edge vertices at start and end rather than having to filter with a qAdjacent)
    • qTangentConnectedFaces with a tangency tolerance
    • qInFrontOfPlane
    • areQueriesEquivalent
    • isQueryEmpty
    • qCoincidentFilter (marked internal)

    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • S1monS1mon Member Posts: 2,991 PRO

    @MBartlett21
    Good catches.

    The last update was V5 which was in 2021. It references FS 1389, but it looks like they were just starting to update as there's a few commented references to "qSourceMesh", but the rest of those others are completely missing.

    Kevin seems to be at Formlabs now so I'm not sure if anyone at Onshape is actively maintaining this. It is a really useful tool.

  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭

    Also fyi, I've done a mirror of the FS standard library at GitHub here. (making it easier to see changes). I also normalised it on the nover branch, taking version numbers out of each studio.

    mbartlett21/fs-std at nover

    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
Sign In or Register to comment.