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.

Options

How can I change the BOM behavior of an assembly through the API?

I have a lot of drawings from my top assembly, I am kind of new to this API thing.
I would like to get a list of assemblies from the top assembly, use that list to go to the respective studios,
and then change the BOM behavior to Components only.

Is there a way that i can do this with the API? 
I took a look  through glassworks but i admit that i don't understand much of it.
Tagged:

Answers

  • Options
    caden_armstrongcaden_armstrong Member, User Group Leader Posts: 127 ✭✭✭
    You can get the current assembly using the endpoint


    /assemblies/d/{did}/{wvm}/{wvmid}/e/{eid}


    In the assembly definition, the field "subassemblies" gives a list of each subassembly.
    Each subassembly has a documentId, documentVersion, and elementId.
    These three fields will locate the assembly studio of each subassembly.

    You can then use the endpoint

    /metadata/d/{did}/wvm}/{wvmid}/e/{eid}

    to update the metadata property for subassembly bom behaviour.

    With a body similar to (replace href with your document href):

    {
       "items":[
          {
             "properties":[
                {
                   "value":"2",
                   "propertyId":"57f3fb8efa3416c06701d633"
                }
             ]
          }
       ]
    }

    Luckily, this field is editable in versions, so you can update the field without having to find the workspace and create a new version.
    The values are 0,1,2, where 0 is assembly and components, 1 is assembly, 2 is components.
Sign In or Register to comment.