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.

Can I use API to add multiple parts in an assembly?

timo_schmidtimo_schmid Member Posts: 15 EDU
Hi,
I'm trying to put multiple parts in to an assembly in a semi-automatized manner. (i.e. I want to select only a few points, and then the program automatically adds multiple parts in the right place & orientation in relation to the selected points)
I'm wondering if the API (potentially using the python client) is feasible for this kind of task?
If yes, are there any ressources (apart from the API explorer) that provide guidance?

Thanks for your help,
Timo

Best Answer

Answers

  • timo_schmidtimo_schmid Member Posts: 15 EDU
    edited March 4
    -

  • timo_schmidtimo_schmid Member Posts: 15 EDU
    Hi Ethan
    Thanks for your answer. I tried running the create_circle.py script and it gives an InsecureRequestWarning from the urllib3 package. Despite the warning, it does create a new document on my onshape Account, but it cannot create the circle. I receive the following error:

    AttributeError: 'PartStudiosApi' object has no attribute 'add_part_studio_feature'
    (line 49 in the create_circle script)

    Similarly, in the test_assemblies_api.py script that you suggested, I added the following lines to try running the function test_assembly_definition
    test=Client()
    test_element=OnshapeElement('https://cad.onshape.com/documents/226f6d6bcf86b8b901b42113/w/4be950d3288c6267581068e4/e/2799ad870ef186e43363f7d4')
    test_assembly_definition(test,test_element)
    This yielded the following error:



    Do you know the reason for the two errors? Or is there a documentation to understand the python client for the API better?

    Best,
    Timo
Sign In or Register to comment.