コード例 #1
0
def test_create_configuration_link():

    # A configurable cube URL
    url = "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/aaa25d18038e06f0b2964e2d/e/69c9eedda86512966b20bc90"
    element = ConfiguredOnshapeElement(url)

    # Desired configuration to apply to the cube
    new_config_map = {
        'size': 10 * u.inch,
        'edge_configuration': 'chamfered',
        'show_cube': True
    }
    element.update_current_configuration(new_config_map)
    print("Link to model with the desired configuration applied: " +
          element.get_url_with_configuration())
コード例 #2
0
def configurable_cubes_assemblies(client):
    versions = []
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/369ac699891d9659ce2d42ba/e/32fbe5d87f9b2777a37ddee9"
        ))
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/d44016efbdb31aae56a63ca2/e/32fbe5d87f9b2777a37ddee9"
        ))
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/c6834b0f25c7d098d5053970/e/32fbe5d87f9b2777a37ddee9"
        ))
    return versions
コード例 #3
0
def configurable_cubes():
    versions = []
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/2c9608e8e443574edf757851/e/69c9eedda86512966b20bc90"
        ))
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/e21a30638b85226b651e74f9/e/69c9eedda86512966b20bc90"
        ))
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/ca51b7554314d6aab254d2e6/e/69c9eedda86512966b20bc90"
        ))
    versions.append(
        ConfiguredOnshapeElement(
            "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/aaa25d18038e06f0b2964e2d/e/69c9eedda86512966b20bc90"
        ))
    return versions
コード例 #4
0
def configurable_cube():
    return ConfiguredOnshapeElement(
        "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/ca51b7554314d6aab254d2e6/e/69c9eedda86512966b20bc90"
    )
コード例 #5
0
'''
Export an STL
==============

Demos 307 redirects with the Onshape API
'''

from onshape_client.client import Client
from onshape_client.onshape_url import OnshapeElement, ConfiguredOnshapeElement
from onshape_client.units import u

client = Client()

# Turn the URL into an "OnshapeElement"
url = "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/aaa25d18038e06f0b2964e2d/e/69c9eedda86512966b20bc90"
cube = OnshapeElement(url, client=client)

# get the STL export
stl = client.part_studios_api.export_stl1(cube.did, cube.wvm, cube.wvmid, cube.eid, _preload_content=False)

print("Resulting STL data (unconfigured): \n" + stl.data)

cube = ConfiguredOnshapeElement(url, client=client)
cube.update_current_configuration({'size': 40 * u.inch, 'edge_configuration': 'chamfered'})

# get the STL export
stl = client.part_studios_api.export_stl1(cube.did, cube.wvm, cube.wvmid, cube.eid, configuration=cube.get_configuration_string(), _preload_content=False)

print("Resulting STL data (configured): \n" + stl.data)
コード例 #6
0
def three_axes_assembly(client):
    return ConfiguredOnshapeElement(
        "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/3395c071ca9534c3b1151e4b/e/19fb95609c4cb02622ca9079"
    )
コード例 #7
0
def test_configuration_update(element):
    element = ConfiguredOnshapeElement(element.get_url())
    assert element._get_default_configuration_map() == {
        'size': 500 * u.inch,
        'edge_configuration': 'Default',
        'show_cube': True
    }
    element.update_current_configuration({"size": 20 * ureg.m})
    assert element.get_url_with_configuration(
    ) == 'https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/c9b07497bec5975f317b0eb7/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3DDefault%3Bshow_cube%3DTrue%3Bsize%3D20%2Bmeter'
    element.update_current_configuration({
        'size': 40 * u.inch,
        'edge_configuration': 'chamfered'
    })
    assert element.get_url_with_configuration(
    ) == 'https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/c9b07497bec5975f317b0eb7/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3Dchamfered%3Bshow_cube%3DTrue%3Bsize%3D40%2Binch'
    element.update_current_configuration({
        'size': 10 * u.inch,
        'edge_configuration': 'chamfered',
        'show_cube': False
    })
    assert element.get_url_with_configuration(
    ) == 'https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/c9b07497bec5975f317b0eb7/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3Dchamfered%3Bshow_cube%3DFalse%3Bsize%3D10%2Binch'
コード例 #8
0
def test_configuration_update(element):
    element = ConfiguredOnshapeElement(element.get_url())
    assert element._get_default_configuration_map() == {
        "size": 500 * u.inch,
        "edge_configuration": "Default",
        "show_cube": True,
    }
    element.update_current_configuration({"size": 20 * ureg.m})
    assert (
        element.get_url_with_configuration() ==
        "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/6ccf88eb92d55be180c06cf9/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3DDefault%3Bshow_cube%3DTrue%3Bsize%3D20%2Bmeter"
    )
    element.update_current_configuration({
        "size": 40 * u.inch,
        "edge_configuration": "chamfered"
    })
    assert (
        element.get_url_with_configuration() ==
        "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/6ccf88eb92d55be180c06cf9/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3Dchamfered%3Bshow_cube%3DTrue%3Bsize%3D40%2Binch"
    )
    element.update_current_configuration({
        "size": 10 * u.inch,
        "edge_configuration": "chamfered",
        "show_cube": False
    })
    assert (
        element.get_url_with_configuration() ==
        "https://cad.onshape.com/documents/cca81d10f239db0db9481e6f/v/6ccf88eb92d55be180c06cf9/e/69c9eedda86512966b20bc90?configuration=edge_configuration%3Dchamfered%3Bshow_cube%3DFalse%3Bsize%3D10%2Binch"
    )