sketchgraphs.onshape.call

Simple command line utilties for interacting with Onshape API.

A sketch is considered a feature of an Onshape PartStudio. This script enables adding a sketch to a part (add_feature), retrieving all features from a part including sketches (get_features), and retrieving the possibly updated state of each sketch’s entities/primitives post constraint solving (get_info).

Functions

sketchgraphs.onshape.call.add_feature(url, sketch_dict, sketch_name=None, logging=False)

Adds a sketch to a part.

Parameters
  • url (str) – URL of Onshape PartStudio

  • sketch_dict (dict) – A dictionary representing a Sketch instance with keys entities and constraints

  • sketch_name (str) – Optional name for the sketch. If none provided, defaults to ‘My Sketch’.

  • logging (bool) – Whether to log API messages (default False)

Returns

Return type

None

sketchgraphs.onshape.call.get_features(url, logging=False)

Retrieves features from a part.

Parameters
  • url (str) – URL of Onshape PartStudio

  • logging (bool) – Whether to log API messages (default False)

Returns

features – A dictionary containing the part’s features

Return type

dict

sketchgraphs.onshape.call.get_info(url, sketch_name=None, logging=False)

Retrieves possibly updated states of entities in a part’s sketches.

Parameters
  • url (str) – URL of Onshape PartStudio

  • sketch_name (str) – If provided, only the entity info for the specified sketch will be returned. Otherwise, the full response is returned.

  • logging (bool) – Whether to log API messages (default False)

Returns

sketch_info – A dictionary containing entity info for sketches

Return type

dict

sketchgraphs.onshape.call.get_states(url, logging=False)

Retrieves states of sketches in a part.

If there are no issues with a sketch, the feature state is OK. If there are issues, e.g., unsolved constraints, the state is WARNING. All sketches in the queried PartStudio must have unique names.

Parameters
  • url (str) – URL of Onshape PartStudio

  • logging (bool) – Whether to log API messages (default False)

Returns

sketch_states – A dictionary containing sketch names as keys and associated states as values

Return type

dict

sketchgraphs.onshape.call.main()
sketchgraphs.onshape.call.update_template(url, logging=False)

Updates version identifiers in feature_template.json.

Parameters
  • url (str) – URL of Onshape PartStudio

  • logging (bool) – Whether to log API messages (default False)

Returns

Return type

None