Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python/Onshape Integration #201

Open
oliver-leung opened this issue Apr 16, 2019 · 3 comments
Open

Python/Onshape Integration #201

oliver-leung opened this issue Apr 16, 2019 · 3 comments
Assignees
Labels
aide_design Tasks for the AIDE Design subteam feature Feature request/addition high High priority

Comments

@oliver-leung
Copy link
Contributor

oliver-leung commented Apr 16, 2019

We need to integrate Ethan's onshape_client package to reach the following goals:

  1. Send data from Component objects into Onshape Part Studio/Assembly configurations.
    • In order for someone to pass data from Python into Onshape (from a Colab notebook or their local computer), they need to create an access key and secret key for their Onshape account, then pass it into onshape_client for authorization. Our two potential methods of achieving this are:
      1. Requiring users to enter their access/secret keys in Python
      2. Requiring users to save a .onshape_client_config.yaml in their home directory (local) or in GDrive (Colab)
      3. Creating a shared AIDE Onshape account, whose access/secret keys are built into the aguaclara package and are used whenever the package is imported.
  2. Utilize the new Super Derive feature in Onshape to propogate configurations into subcomponent Part Studios/Assemblies.
    • Two changes we must make to our JSON serialization methods:
      1. Component.write_properties_to_file(filename) should overwrite the file if filename already exists.
      2. In the JSON, if the key is a component, then the value must be a string representing a dictionary, not a dictionary itself.
@oliver-leung oliver-leung self-assigned this Apr 16, 2019
@oliver-leung oliver-leung added the aide_design Tasks for the AIDE Design subteam label Jun 18, 2019
@oliver-leung oliver-leung added feature Feature request/addition low Low priority medium Medium priority and removed low Low priority labels Jul 16, 2019
@oliver-leung oliver-leung changed the title onshape_client Integration Python/Onshape Integration Jul 22, 2019
@oliver-leung
Copy link
Contributor Author

I've run into a strange error which I've detailed here, preventing me from creating a Python object from an Onshape Part Studio. Aside from that, I think that I have the process complete for authorizing Onshape in Python.

@oliver-leung
Copy link
Contributor Author

The docutils version error has been resolved, so we can likely unpin it from Pipfile.

@oliver-leung
Copy link
Contributor Author

oliver-leung commented Aug 9, 2019

The error that I mentioned above (preventing me from creating a Python object) has been resolved due to an incorrect .onshape_client_config.yaml - tag me if you need to see what the corrected one is.

A discussion with @ethan92429 has revealed the following divine truths:

  1. Given the URL to an Onshape element, and a dictionary containing a custom configuration of that element, we can deterministically map that dictionary into an encoded string using urllib3. We can then append the string to the element URL, creating a custom configuration URL that is publicly-accessible.
  2. onshape_client requires Onshape credentials to instantiate the client, in order to access the API.
  3. The API is actually not necessary to create custom configuration URL's. Instead, they're mapped using the strategy mentioned above with urllib3.

For our purposes of creating custom configurations, it then becomes clear that we actually don't need onshape_client for our Onshape use case. Instead, we should be using the following strategy:

  1. Compile the necessary design outputs in a configuration dictionary.
  2. Map the dictionary to an encoded string via urllib3
  3. Append the encoded string to the element URL and give it to the user.

@oliver-leung oliver-leung added high High priority and removed medium Medium priority labels Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aide_design Tasks for the AIDE Design subteam feature Feature request/addition high High priority
Projects
None yet
Development

No branches or pull requests

2 participants