Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

How do I drive assembly-level dimensions with calculations?

tlewis3348tlewis3348 Member Posts: 18 ✭✭
With my day job, I use Mathcad and Creo to design mechanical parts. One of the features of those products is Mathcad can be used to drive calculations for determining dimensions in Creo. I would like to do something similar with Onshape via something like a Jupyter notebook or Google spreadsheet. Is this possible, or is the only option available to use FeatureScript?

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,175 ✭✭✭✭✭
    There is such thing as cadwolf app - an advanced integrated calculation invirinment with direct link to part studio variables, but for some reason I couldn't find it in onshape appstore anymore. Also you always have an option to import for example CSV or JSON file and make a featurescript which sets part studio varibles based on this imported info.
  • tim_hess427tim_hess427 Member Posts: 596 PRO
    You can also access your CAD data through the API. Here is some information about using python notebooks with the API. https://forum.onshape.com/discussion/comment/73094#Comment_73094
  • matthew_mueller537matthew_mueller537 Member Posts: 4 EDU
    Yes, @tim_hess427 beat me to it, but we have been doing a lot with the Onshape API and Jupyter (mostly through Google Colab, but works just as well with a local Jupyter Notebook kernel). Here's a link to the latest bunch of documentation and examples of driving or getting data between Onshape and computational workflows in Python.
  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,605 PRO
    I'd look into configurations. They link assemblies with part studios and can also expose values to a webpage via the api.

    It's a good way to manage something you're wanting to expose on the web and make it configurable.

    Each input value in OS can be an expression and you can make variable declarations using #var1. You'll quickly realize this isn't a good way to control geometry with numbers and should move your expressions into feature script. The IDE for feature script is wonderful and a great place to build some logic.

    Here's a link to an example https://rustyshed.com/?quill=60e8c55ea30a1413a2b2f99a

    Change one of the values and design updates. It's written so I can expose any OS assembly by passing in OS DWE. I use the API to read the assembly configuration table and display it as html. Onchange, I make a call to OS, it rebuilds the geometry and then sends back an image.

    I've been working on web based geometry designs for a while, but, I have long way to go. I think it's got a great future.


  • tlewis3348tlewis3348 Member Posts: 18 ✭✭
    There is such thing as cadwolf app - an advanced integrated calculation invirinment with direct link to part studio variables, but for some reason I couldn't find it in onshape appstore anymore. Also you always have an option to import for example CSV or JSON file and make a featurescript which sets part studio varibles based on this imported info.
    Yeah, I had previously installed the SwiftCalcs app, but it has also disappeared from the app store. To say the least, I was fairly surprised to not find any similar offerings in the app store.
    You can also access your CAD data through the API. Here is some information about using python notebooks with the API. https://forum.onshape.com/discussion/comment/73094#Comment_73094
    Yes, @tim_hess427 beat me to it, but we have been doing a lot with the Onshape API and Jupyter (mostly through Google Colab, but works just as well with a local Jupyter Notebook kernel). Here's a link to the latest bunch of documentation and examples of driving or getting data between Onshape and computational workflows in Python.
    Correct me if I'm wrong, but the Jupyter Notebook is merely used as a space to launch and run FeatureScript code. Am I understanding that correctly? If that's the case, I think I'd prefer to just write the FeatureScript directly. This isn't completely undesirable, but I'd prefer something similar to Mathcad, if it's available.
  • tim_hess427tim_hess427 Member Posts: 596 PRO
    @tlewis3348 - all part modeling is done through FeatureScript as it's the language behind all of the native modeling functions as well as the custom features that users create. So, eventually everything will go through it. 

    The API (which you can use through a jupyter notebook) gives you way to interact with onshape remotely. So, you can do your calculations in python with the Jupyter notebook, then use the API to tell the part studio what to do. Where again, all features in the part studio are written with featurescript. 

    So, within a part studio, you can create variables and use them within custom features that include all of your calculations.  Alternatively, you can do your calculations in Python and then have python tell onshape what do with the results using the API. 

    https://onshape-public.github.io/docs/
    https://cad.onshape.com/glassworks/



Sign In or Register to comment.