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.
Tips for writing reusable code
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm new to code of any kind, so perhaps this is obvious, but is there a clean way to reuse feature scripts and update them all from a central place? I'd love to be able to write an "edge selection" module that can just be imported into new custom features to create parts of the UI and selection logic. I'd like to have the option to update all features using the module from a central place. I see things in the standard Onshape library that seem to do this but I don't fully get how, and what the limitations are.
Evan Reese
0
Answers
How the standard library works is that it is all in one workspace.
I ran into this problem a few times.
I had created a simple library to make creating a Cutout FeatureScript easier, by providing predicates for the definition and a simple library of functions (https://cad.onshape.com/documents/2ad339efe44128f5171291fa)
I also had created a library to evaluate expressions, by tokenising them, then converting them to RPN notation, then finally evaluating it, returning an error code if a variable wasn't found. (https://cad.onshape.com/documents/429fd7dda5f0fdb93833a34a)
I find that the easiest way is to just have a simple document with the main code and test cases. You can then create versions of this and import it into other documents. The disadvantage of this approach is that it isn't easy to see what documents use that library.
IR for AS/NZS 1100
thanks
I'm getting the same error on the first link (https://cad.onshape.com/documents/2ad339efe44128f5171291fa)
@billy2
Done. It is public now.
IR for AS/NZS 1100