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.
Comments
my prompt from this morning:
new FS time, I want to build a pipe/wire routing script that allows the user to construct a polyline (with corner bends) through a series of mate connectors, where each MC's z controls the direction of the segment starting at that mc. however, between MCs, the polyline should automatically form 90deg bends in order to get from one MC's location and z, to the next MC's location and z. attached is a phot of my result so far and the code. I want you, as a professional FS coder, using strictly, only officially supported syntax and code according to the documentation at https://cad.onshape.com/FsDoc/library.html and the STD code mirror at https://github.com/javawizard/onshape-std-library-mirror to help me finish the code for a series of arbitrarily located and oriented mate connectors. you will ask me questions to confirm my intent and preferences for UI and behavior before presenting code, and you will always confirm your code is compliant before presenting it to me.
Only had 4 errors in 225 lines of code, and three of them were just lhs vs rhs unit issues. another was an initialized variable without a value.
Cool! 😎
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
That's awesome, thanks for sharing!
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
If anyone is curious to see exactly how I've got mine set up, here's my public repository with included AGENTS.md file. I've already loaded it with instructions to help avoid the most common AI hallucinations involving featurescript. I've also loaded it full of custom features, both my own and some published by others that I've made modifications to.
One huge benefit to building a repository this way is the ability to add other non-featurescript reference to build off of, for example I've loaded some whitepaper references and books with interesting algorithms or functions I wanted to port to featurescript. Codex is able to read PDFs and work with the information found within, so when I was doing some bSpline surfacing work I saw The NURBS Book explicitly referenced in Onshape's developer documentation for one of the features in the standard library. I went and sourced that book myself to plug it into this repository and pull more algorithms from it since it's such a useful reference.
@Derek_Van_Allen_BD 🤯 what a legend
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
I'll follow up with a more formal write up about how to set up your own copy of this, too. I'm also looking into getting Github to formally recognize featurescript as a valid language so I can remove some instructions from that prompting. To be perfectly transparent, it helps me out if more people are doing the same thing I'm doing so that more examples of code exist in Github for Copilot and Codex to learn from. So the more of you that follows this blueprint the better these tools will work for everyone. This is as opposed to custom GPTs or prompts where knowledge bases aren't actually being effectively baked back into the tools to get better at featurescript specifically.
Interesting thread!
I've actually had great luck with some simpler FS directly in chatGPT, 4o was the last model I used it on. I have not tried 5 yet. Using the trick that @joshtargo mentioned to ask chatGPT to improve on the prompt is excellent. Not only for FS prompts ;)
It can have a few syntax bugs here and there, usually quick to fix. I find it can definitely be a good basis for something to work off.
I have not had luck at all with anything at all useful from Gemini.
My top tip:
I have such trouble reading long debug outputs of nested queries and maps, it just becomes a wall of text in the debug window - copy-paste the debug output into chatGPT, ask it to format it nicely with indentation and colors. Sooo easy to read now!
I like the idea of getting it to format for you! I did write myself a few functions to print maps with key/value pairs on new lines, and arrays with each item on a new line here https://cad.onshape.com/documents/9f4c9835d8018ff7dbdb5683/w/9d9e75e708f4a5dafd5966cb/e/c60f4a6e12f07acee647a2a1
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
Not sure how to use this though.
Oh yeah that's nice! Great idea
I recall Greg had a suite of better debug tools too, I have not got around to have a deep dive in that yet.
Step 0 is to be paying for ChatGPT Plus. Basically you fork the javawizard github mirror as step 1, follow this guide for linking that new github repo into Codex as step 2. Create a new AGENTS.md file and plug it into your new forked repository as step 3. Step 4 is to make a folder containing your custom code samples and populate it.
Using Codex over basic chatgpt is an improvement because you can run the same prompts through 4 different agents in parallel and it's got inherent access to other examples of your code without needing to be provided it. This cuts way down on getting stuck in a prompt hole where things go sideways and you need to abort the thread and start a new prompt because usually at least 1 of the 4 is on the right track.
It would be a bigger improvement if Onshape were able to be ran locally or if I could hook it into an a test environment for automatic debugging and patching of code but I'd probably need to do some API stuff to get it plugged into Onshape's feature studios, so application between prompts is still the old copy and paste. But you can set it up so the code is displayed in split diff mode to make things easier to paste over.
I'm gonna need GTP just to help me understand this. I've never even used github before.