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.
Use Report, viz(), and dbg() for conditional println and debug visualizations
jnewth
Member, OS Professional Posts: 87 PRO
Earlier this year I wrote a utility called "Report". The one-sentence description is "Conditional debug visualization and println controlled by feature and not by code".
Here's an intro video: https://www.youtube.com/watch?v=Eu7puEa8Oak
You can find the feature and functions here: https://cad.onshape.com/documents/e2576bfe13aaaabd67b0fe1d/v/4322f20d8f97ab12eeab937c/e/e954caf65d5d66b94f8bb90a
Here's how it works:
1. Import the feature Report in to your toolbar.
2. Import the functions dbg() and viz() in to your custom features.
3. When writing code, use dbg() instead of println and use viz() instead of adding debug entities through debug or addDebugEntities functions.
4. When your custom feature call viz() and dbg() functions instead of println() and debug(), the Report feature will enable the console printing and debug visualization for only the viz() and dbg() calls you want to activate, all controlled by keyword.
5. Suppress and unsuppress Report features to enable/disable visualization in your custom feature while your custom feature is being edited:
Note: This is very similar to another reporting tool I wrote a while back. I've renamed that tool "Log" as it's much more focused on mimicking logging tools like log4j but otherwise its behavior is unchanged. If that is a better match for your needs you can read about it here: https://forum.onshape.com/discussion/23476/featurescript-writers-stop-using-println-and-start-using-report-new-featurescript-announcement
Let me know what you think!

Comments
@jnewth thanks so much for creating and sharing this. It is proving invaluable in a current project I'm working on (as you know!) which otherwise was full of numerous messy debug and println's…
My surface tweening feature is over 2000 lines of code but most of it is diagnostics as I build the core logic.
I wonder how much of that I could scrape out of there using this.
Derek Van Allen | Engineering Consultant | MeddlerI literally just stumbled upon the other video this morning! Great work!
Ramon Yip | glassboard.com