Variable library

The Variable library feature makes it possible to create and use global variables in Onshape by storing variables on cube parts. Variables may also have associated descriptions which can be viewed via a custom table.

The Variable library FeatureScript can be found here: Variable library suite document

Steps for using variable libraries

  1. Create a Variable library feature in a part studio.

  2. Set the Variable library useage behavior to Use.

  3. Click Select Part Studio…, then navigate to another part studio containing one or more library variable cubes and select them.

  4. The variables attatched to those parts are automatically added to the part studio.

  5. Click checkmark.

../_images/variableLibraryUse.png

Steps for creating variable libraries manually

  1. Create a Variable Library feature in a part studio.

  2. Set the Variable library usage behavior to Create.

  3. Set the library creation type to Manual.

  4. Add one or more variables. A library cube part is created containing each added variable.

  5. If desired, choose Add descriptions, then add descriptions to each variable in Variables.

See also

Variable descriptions for more information.

  1. Click checkmark.

../_images/variableLibraryManualUI.png

Steps for creating variable libraries from existing variables

Note

It isn’t currently possible to add custom variable descriptions when creating variable libraries this way.

  1. Create a Variable library feature in a part studio with one or more existing variables.

  2. Set the Variable library usage behavior to Create.

  3. Set the library creation type to Automatic.

  4. Specify a Library name.

  5. A library cube part is created containing all of the variables currently visible to the variable library feature.

  6. Click checkmark.

../_images/variableLibraryAutoUI.png

Steps for creating variable libraries from CSV files

  1. Open the Variable Library Template, make a copy, and then edit the template as desired.

The Variable Library Template can be found here: Variable Library Template

../_images/variableLibraryTemplate.png

Note

Keep in mind the following while adding variables: * An arbitrary amount of libraries may be created. * Variable names must start with a single letter, followed by letters, numbers, and underscores (_). Spaces and other special characters are not allowed. * Variable units must parse to a valid Onshape unit abbreviation like in, inch, deg, or degree. Punctuation and capitalization is ignored.

  1. AFter you’ve finished editing, download the template file as a .csv (Comma Seperated Values) file, then upload it into Onshape.

    1. Create a Variable library feature in a part studio in the same document as your uploaded CSV file.

  2. Set the Variable library usage behavior to Create.

  3. Set the library creation type to Import.

  4. Select the CSV file you uploaded to Onshape.

  5. If your CSV file has a top-level header row, select Skip first row.

  6. The variable library feature should add one or more variable library cube parts to the part studio.

  7. Click checkmark.

Variable descriptions

Descriptions can be added to manually created variables and to variables imported from CSV files. These descriptions can then be seen later on using a custom table.

To add and use the variable library custom table, you will need to first add it to your custom table tab.

  1. Open the Custom tables panel by clicking on the corresponding button on the far right side of your screen.

../_images/tableLocation.png
  1. Choose Add custom tables, then copy and paste the following link into the search bar:

  2. Open the resulting document and click Library variables to add it to your custom tables.

  3. Variables in your part studio which have been created by the library variable feature are displayed in a table format (along with their description, if added).