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.
New function tolerantSort()
kevin_o_toole_1
Onshape Employees, Developers, HDM Posts: 565
Hi all,
The latest release (Onshape 1.129 and FeatureScript 1483) came with a new helpful function in the Standard Library: tolerantSort().
This function is useful for sorting items based on measurements that have some inherent imprecision, like sorting a list of lines by length. This function sorts based on those measurements, except that when measurements are within the provided
This can provide stability to your features, preventing the sort order of two items of equal size from occasionally switching due to unrelated changes.
Documentation for the function and simple example code can be found here.
One Feature Studio which has already been updated to utilize this function is @lemon1324's Laser Joint Utils, used by FeatureScript laser joint. The feature sorted parts from smallest to largest so it could consider the smaller part the "tab" and the larger part the "base". Using tolerantSort ensures that ties in size are broken by the original selection order, not arbitrarily.
Thanks for updating that script Arul, and happy FeatureScripting all!
– Kevin
The latest release (Onshape 1.129 and FeatureScript 1483) came with a new helpful function in the Standard Library: tolerantSort().
This function is useful for sorting items based on measurements that have some inherent imprecision, like sorting a list of lines by length. This function sorts based on those measurements, except that when measurements are within the provided
tolerance
of each other, it defers to their order in the original list.This can provide stability to your features, preventing the sort order of two items of equal size from occasionally switching due to unrelated changes.
Documentation for the function and simple example code can be found here.
One Feature Studio which has already been updated to utilize this function is @lemon1324's Laser Joint Utils, used by FeatureScript laser joint. The feature sorted parts from smallest to largest so it could consider the smaller part the "tab" and the larger part the "base". Using tolerantSort ensures that ties in size are broken by the original selection order, not arbitrarily.
Thanks for updating that script Arul, and happy FeatureScripting all!
– Kevin
1
Comments
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! cadsharp.com/featurescripts 💎
Incidentally, if anyone wants to get a hold of me on the forums, my personal Onshape account @lemon1324 is a bit more likely to actually ping me, rather than my work account - I'm not sure I have forum notifications enable there, and I definitely check the forum with that account less often.
PhD, Mechanical Engineering, Stanford University