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.
creating a custom enum inputs from imported part studio
nik_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.
0
Comments
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
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
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.