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.
Debugging a feature script
baumar
OS Professional Posts: 77 PRO
Hi all,
I start to use feature script, great stuff indeed. As there are not too many tutorials and a basic doc I still make a lot of errors and many operations I have to learn by try and error.
Now when something is wrong I see in the part studio the message "Feature did not regenerate properly " plus a short error message which sometimes helps to find the issue, sometimes it's just too short (for my current state of knowledge). What I really miss is a way to debug through such a function. Eventually it is just a program and I thought today every program editor had a way to debug. I guess the engineers at Onshape don't resolve the issues they find just by guessing otherwise they would not be that fast with developing new features.
Is that a intellectual property because debugging would need to include also the code onshape created? But even if that was the reason, I assume every function that has an issue is raising some kind of exception. To have just that concrete exception would already be more helpful. I assume that the detailed messages are 'swallowed' and reduced to high level message like "invalid input selections".
But maybe I'm looking into the wrong direction and there is a better and more efficient way or practice to find an error in the code?
kind regards
Markus
I start to use feature script, great stuff indeed. As there are not too many tutorials and a basic doc I still make a lot of errors and many operations I have to learn by try and error.
Now when something is wrong I see in the part studio the message "Feature did not regenerate properly " plus a short error message which sometimes helps to find the issue, sometimes it's just too short (for my current state of knowledge). What I really miss is a way to debug through such a function. Eventually it is just a program and I thought today every program editor had a way to debug. I guess the engineers at Onshape don't resolve the issues they find just by guessing otherwise they would not be that fast with developing new features.
Is that a intellectual property because debugging would need to include also the code onshape created? But even if that was the reason, I assume every function that has an issue is raising some kind of exception. To have just that concrete exception would already be more helpful. I assume that the detailed messages are 'swallowed' and reduced to high level message like "invalid input selections".
But maybe I'm looking into the wrong direction and there is a better and more efficient way or practice to find an error in the code?
kind regards
Markus
1
Answers
FeatureScript doesn't yet have a full-blown debugger, but that doesn't mean you're blind. Your features can output data to the console (maybe you haven't found it? You can open it with a {✓} icon at the top to the left of the share button) and to the part studio (see https://cad.onshape.com/FsDoc/output.html) and you can monitor and profile feature studios to get a picture of what's going on. See https://cad.onshape.com/FsDoc/debugging-in-feature-studios.html. If you haven't gone through our official tutorials, I definitely recommend them: https://cad.onshape.com/FsDoc/tutorials/create-a-slot-feature.html -- they also cover a little basic debugging.
BTW, all the debugging options we (as Onshape devs) have are available to you, including the FeatureScript source code of all our standard features and library functions in a public document here: https://cad.onshape.com/documents/12312312345abcabcabcdeff The only stuff we can debug that you can't is if FeatureScript itself is misbehaving or an opaque built-in function @something() is producing unexpected results.
Hope this helps.
I really didn't know about the console, that is a gread help indeed. (Maybe you want to advertise in tutorials etc?-)
Kind regards
Markus