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.
Abusing UIHints for Fun and Profit
juliaschatz
Member, Developers Posts: 8 EDU
I had some fun making an early April Fool's joke about adding microtransactions to my featurescripts. This uses UIHint.REMEMBER_PREVIOUS_VALUE, UIHint.ALWAYS_HIDDEN, and an editing logic function to keep track of how many times someone has used a script and encourages them to buy more uses when they run out. An example of this applied is here.
This isn't practical for this purpose for a few reasons: There's no way to access the internet to verify redemption codes (although large random numbers stored in a private document could work), and all REMEMBER_PREVIOUS_VALUE values are reset when the user changes the version of the script (updates it, for example).
I originally did this just as an experiment about transferring data that the user doesn't interact with between script runs, essentially turning any field marked REMEMBER_PREVIOUS_VALUE into a storage location for anything that can be serialized to a string. This could be used to store configuration information, copy data between part studios, or any number of things.
Hope this is a little bit interesting at least.
Tagged:
9
Comments
Seriously, that's a pretty creative use of the system; I certainly never thought of the interaction of the two UIHints.
BTW (and I know it's still not practical) the way to get around keeping a list of random numbers is to use a secure pseudo-random number generator (https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) based on just one secret key.