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.

Options

creating a custom enum inputs from imported part studio

nik_lalnik_lal Member Posts: 5
Would it be possible to create an enum with a list of possible imported configurations? And if not what would be the best approach here? I am trying to present the user with a list of available configuration parameters, typically lengths, that can be adjusted, and to have the user select up to 2 of the options.

Comments

  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,064 PRO
    Interesting idea. Can you share an example of what you want?
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Options
    nik_lalnik_lal Member Posts: 5
    I would like to create a pattern of models with one configuration variable I can iterate, the name of the variable will change from Part Studio to Part Studio. In the following screenshot, the drop down menus are defined by the same enumeration, and I currently define that manually. One implementation that would be great is to have the input enum defined by the configuration map generated from the PartStudioData type, but I'm not sure how to implement that. Thanks!


  • Options
    nik_lalnik_lal Member Posts: 5
    Hi all - just a bump, any ideas? Thank you!
  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,064 PRO
    edited May 2023
    Ooh! I had typed out most of a reply and got pulled away and forgot about it. Now that I'm back to it I actually had the time and curiosity needed to mock it up and I think I've got it working. Check it out here.

    This problem is tricky. Based on the order the code regenerates, the UI is evaluated before the feature code, so to drive the UI via something the feature does, you need to use an editing logic function and a hidden parameter (UIHint.ALWAYS_HIDDEN). The UI can't do any mathy stuff, it can only be conditional based on a boolean or enum, so in my case I chose to use an enum since it is expandable to more options
    annotation { "Name" : "Enum type", "UIHint" : UIHint.ALWAYS_HIDDEN }
            definition.enumType is EnumType;
    I had to dig into PartStudioData to understand what's in there, and found that I was able to get a string of which configuration was selected with
    const config = definition.myPartStudio.configuration.List_LfiqGXUvBqPiQE->toString();
    I got "List_LfiqGXUvBqPiQE" and what each configuration is called ("Cyilder" or "Cube") by clicking the 3 dot menu for the configuration in the source studio, and choosing "edit featurescript IDs", and it didn't work without the toString() function. From there, I just compared it to a string, and changed the definition to the right enum and returned it. If you're not used to editing logic functions learn that here.

    This method is really generally expandable to controlling any part of your UI's visibility based on the config of an input studio. I might be glossing over steps that aren't obvious, so follow back up if you get stuck.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
Sign In or Register to comment.