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.

How to check if a part is hidden by the user?

david_riedelldavid_riedell Member Posts: 17 EDU
I've been searching the featurescript docs but I can't figure out how to tell if the user has hidden a part from the parts list.

I need something along the lines of:

if (part.isHidden()) {
    // do something
}

How can you tell if the part is visible?

Comments

  • john_mcclaryjohn_mcclary Member, Developers Posts: 2,895 PRO
    That's not really what featurescript is for, so I highly doubt it.

    But you can see what is hidden on the bottom of the tree.
  • alnis_smidchensalnis_smidchens Member Posts: 129 EDU
    edited August 16
    I'm still learning the very basics of FeatureScript, but I don't think that visibility is something that could be accessed since it is controlled outside of the feature tree. For example, if a feature is made while a part is hidden, but after more features are added and the user unhides the part, should the feature regenerate? It isn't possible to know without actually regenerating it to check the conditional statements, and that would be a big performance hit since every time an object's visibility is changed the whole tree would have to regenerate, and caching feature results would be nearly impossible since it would depend on the visibility of all of the objects in a part studio. Not an expert here by any means, just taking a guess!  :)
    Get in touch: [email protected] | My personal site: https://alnis.dev | My YouTube channel (I make tutorial videos for Onshape & Inventor): https://www.youtube.com/c/AlnisSmidchens
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 1,887 PRO
    @david_riedell
    Short answer: No, you cannot find out whether a part is hidden in the feature.

    Long answer: In order to do something like this, you can, in the editing logic function, use the hidden parts parameter, which will give you a query of the hidden parts. This can then be stored in the definition.

    If you can tell us what you are wanting the condition for, we could provide a better solution.
    MB - I make FeatureScripts: View FeatureScripts
  • david_riedelldavid_riedell Member Posts: 17 EDU
    Thanks for the responses guys. @alnis_smidchens that's a good point, hiding a part doesn't cause it to regenerate. I thought there was a chance that featurescript could at least read whether a part was hidden, but what you wrote makes sense.

    @MBartlett21
    I wrote a featurescript a few months ago that will populate a custom table with the dimensions of each individual part in a part studio. The goal was to make efficient use of sheet goods like plywood by finding the smallest bounding box around a panel regardless of its shape or orientation to minimize waste when cutting the panel out of the plywood sheet.

    I then thought that it might be nice if this featurescript would only operate on parts that are visible so that parts that are hidden by the user would be removed from the custom table.

    Are you talking about the hiddenBodies query from this page? https://cad.onshape.com/FsDoc/uispec.html Right now I'm doing a query to grab qAllModifiableSolidBodies. Is there an elegant way to subtract the results of hiddenBodies from qAllModifiableSolidBodies?
  • john_mcclaryjohn_mcclary Member, Developers Posts: 2,895 PRO
    edited August 16
    It seems dangerous to modify a model or extract information that can be used down stream based off of hide/show of a part.

    I probably hide/show hundreds of times while modeling. Too volatile...

    It would be best to use a selection scope.
    Or make a delete part feature that you can suppress with a config.
Sign In or Register to comment.