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 to update many feature variables at once via the API

Hi,
I have built a model in PartStudio using feature variables. I want to remote control the model via an app, and have successfully managed to update variables using the PartStudio/featureId/{fid} endpoint. However, for bulk update of many variables (~15) this is too time consuming. So I tried several ways to bulk update multiple variables with a single call:
- using the PartStudio/features endpoint did not succeed, as I did not manage to correctly create the entire feature tree
- I tried using the Variables endpoint, but learned this is only valid for VariableStudios
- Then I created a configuration table that has as columns my feature variables, but I failed when using the Elements/configuration endpoint to update the values.

Does anyone have a sample that shows which endpoint would be best and how to create the payload/the body for the POST request?

Answers

  • Konst_ShKonst_Sh Member Posts: 141 PRO

    there is no public api to update a few features at a time, assuming update endpoint is what you need for what you trying to do:

    https://cad.onshape.com/glassworks/explorer#/PartStudio/updatePartStudioFeature

    The one option could be to run the api calls in parallel, without awaiting every next one.

    Another option is using part studio configuration instead of variables, in this case the update is made in one api call:
    https://cad.onshape.com/glassworks/explorer#/Element/updateConfiguration

  • alexander_schneegansalexander_schneegans Member Posts: 7

    I have tried this (I mean the updateConfiguration), and the response was a success, unfortunately, the configuration parameters were not modified. Here's the body of the POST:

    {"configurationParameters":[{"btType":"BTMConfigurationParameterEnum-105","parameterId":"List_HfBJywBgIRELfT","enumName":"List_HfBJywBgIRELfT_conf","enumOptionVisibilityConditions":{"btType":"BTEnumOptionVisibilityConditionList-2936","visibilityConditions":[]},"isCosmetic":false,"options":[{"btType":"BTMEnumOption-592","optionName":"wingParameters","option":"wingParameters","nodeId":"Mh3zOXVAViisxnltF"}],"namespace":"","defaultValue":"wingParameters","nodeId":"Mok2sXZbKdN6RgBOc","parameterName":"Configuration","visibilityCondition":{"btType":"BTParameterVisibilityCondition-177"}}],"currentConfiguration":[{"btType":"BTMParameterQuantity-147","parameterId":"rootChord","expression":"5000 mm"},{"btType":"BTMParameterQuantity-147","parameterId":"kinkChord","expression":"3000 mm"},{"btType":"BTMParameterQuantity-147","parameterId":"tipChord","expression":"1200 mm"},{"btType":"BTMParameterQuantity-147","parameterId":"span","expression":"13000 mm"},{"btType":"BTMParameterQuantity-147","parameterId":"sweeLE","expression":"13.00 deg"},{"btType":"BTMParameterQuantity-147","parameterId":"relKinkPosition","expression":"0.35"},{"btType":"BTMParameterQuantity-147","parameterId":"dihedral","expression":"3.00 deg"},{"btType":"BTMParameterQuantity-147","parameterId":"rootRelThickness","expression":"9"},{"btType":"BTMParameterQuantity-147","parameterId":"kinkRelThickness","expression":"8"},{"btType":"BTMParameterQuantity-147","parameterId":"tipRelThickness","expression":"6"},{"btType":"BTMParameterQuantity-147","parameterId":"twistRoot","expression":"2.00 deg"},{"btType":"BTMParameterQuantity-147","parameterId":"twistKink","expression":"2.00 deg"},{"btType":"BTMParameterQuantity-147","parameterId":"twistTip","expression":"-4.00 deg"},{"btType":"BTMParameterEnum-145","parameterId":"List_HfBJywBgIRELfT","value":"wingParameters","enumName":"List_HfBJywBgIRELfT_conf"}]}

  • Konst_ShKonst_Sh Member Posts: 141 PRO
    edited March 16

    I'm not 100% sure here, but the updated configuration change could be not something you will see directly when opening element, all configurations existing at the same time, so it should default to something, try exporting it and check if its matches to what you expect

  • Caden_ArmstrongCaden_Armstrong Member Posts: 412 PRO

    What are you trying to do? Theres a chance that a different workflow will get you to your goal, but it would help to have some context.

    www.smartbenchsoftware.com --- Renaissance --- fs.place
    Experts in Onshape Automation - Custom Features and Integrated Applications
  • alexander_schneegansalexander_schneegans Member Posts: 7

    Thanks, unfortunately doesn't seem to explain the issue. I have one row in the configurations table only (named "wingParameters" in the above example, which is the default configuration. Neither do the values in the table update, nor the element. It seems as if the values are not written in the configuration table's columns, …, which may be due to a wrong body content. Strangely, the answer to the POST is code 200 == success. Chatted quite a bit with Gemini, but turned around in circles after a while. I was hoping that the update of values in configuration tables was a standard use case for API usage, and find some examples in the community.

  • alexander_schneegansalexander_schneegans Member Posts: 7

    Just had a success! What I am trying to do (and now achieved) is to interface with OnShape from an App that does some preliminary design stuff and simulation, and that hosts a somewhat intelligent model that also contains geometry. For the purpose of visualization but also in order to get derived values (wetted areas, volumes, …) I have to interace with OnShape via the API. I had successfully managed to update singular (feature)variables in my PartStudio, but found it very lengthy and time consuming to go this way when updating a set of variables.
    So I tried a few things, and now found a working endpoint: not PartStudio→features but PartStudio→features→updates. This accepts my bulk request an nicely updates the entire models.
    Just cost me a few (more) trials …
    Thanks for your interest in my problem and the support!

Sign In or Register to comment.