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

timo_schmid
timo_schmid Member Posts: 36 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_schmid
    timo_schmid Member Posts: 36 EDU
    edited March 2020
    -

  • timo_schmid
    timo_schmid Member Posts: 36 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