Variable Studio
Available in: Variable Studio
本主题介绍使用 Variable Studio 创建变量的功能和机制,这些变量可在创建它们时所在的文档以及其他文档中使用。您只能通过 Onshape 的浏览器平台创建 Variable Studio,但可以在所有移动平台上查看和使用变量。
Variable Studio 是在文档中创建的,其中的变量可立即在该文档工作区的所有 Part Studio 和装配体中使用。
See also: Variable Studio Configurations.
-
在文档中,单击左下角的“插入新页签”图标 (
),然后选择“创建 Variable Studio”:
-
Variable Studio 将打开,其中一个变量表可用于输入:
-
在 “名称” 列中键入第一个变量的名称。(仅允许使用字母数字字符。)
-
按 Tab 键可移至下一行。系统会为变量输入默认长度类型,若要更改类型,请使用下拉箭头,并选择一种新类型。
To import a variable from a CSV file, select the From import option and follow these instructions: Importing a variable from a CSV table.
-
输入变量的默认值和可选说明。
要对表格中的输入重新排序,请右键单击并选择向上移动或向下移动。您也可以拖动输入以对其进行重新排序。
使用 Variable Studio 标题左侧的插入符号来折叠或展开该章节。要同时折叠(或展开)所有表格,请单击标题块右侧的三点菜单,然后选择折叠(或展开)所有表格。
可以使用之前在表中定义的变量,稍后在该表中定义其他变量的值。例如:
L1 变量(桌边的长度)用于计算 W1 变量(桌面的宽度)。
要使变量可用于工作区中的所有 Part Studio 和装配体,请选中“Variable Studio”选项卡底部边缘的框:
取消选中此框可移除在此文档的工作区中的 Part Studio 和装配体中使用变量的功能。(如果变量处于草稿状态,则保持此框为取消选中;如果变量可供使用,则选中此框。)
The From import variable type enables users to create a single variable that stores a subset of rows and columns from an imported CSV table. The Row options filter the rows and determine the Result type (Single value, Array, or Map) of the variable. The Column options then filter each row and determine the type of each entry in the final variable.
- In the table, click the Variable type arrow and select From import.

- In the Value cell, click the Edit pencil icon. The Variable dialog opens with the From import tab selected:

- In the dialog:
- Under CSV file, click the Select CSV file field to open the dialog:

Select the CSV file from either the Current document, Other documents, or click the Import button at the bottom of the dialog to select a CSV file from your device.
Once selected, click the file. It is loaded into the Select CSV file field.
- Fill out the Row and Column fields according to your requirements:
- Access type - Select By index, By index range, By label, or All values.
- Index - If By index is selected, enter a single Index value.
- Min/Max index - When By index range is selected, enter both the minimum and maximum index values.
- Value - If By label is selected, enter the label's string value.
- Regular expression - Check to pattern match a set of target strings.
- Result type - Select Single value, Array, or Map.
- Label column/row index - If the Result type is a Map, enter either a numerical index value or a variable.
- Access type - Select By index, By index range, By label, or All values.
- Check Conversion factor and enter a value with measurement units if you are converting from one measurement to another (for example, if the table uses inches, and you want these values converted to centimeters).

- Optionally, enter a Description to provide some details about the Variable or CSV file being used.
- Under CSV file, click the Select CSV file field to open the dialog:
- Click
.
See also: Variable: From Import Examples.
要在定义变量表的文档以外的文档中使用它(以及其中定义的变量):
-
打开您要在其中将在 Variable Studio 中定义的变量用于其他文档的文档。
-
单击左下角的“插入新页签”图标 (
),然后选择“创建 Variable Studio”。 -
在新的 Variable Studio 中,单击顶部的插入 Variable Studio按钮。“插入 Variable Studio”对话框将会打开:
-
在要查找变量表的对话框的顶部选择两个选项卡中的一个:“当前文档”或“其他文档”。
如果在当前文档中有任何 Variable Studio,它们将在“当前文档”下列出。要在其他文档中找到 Variable Studio,请选择“其他文档”选项卡:
可以选择整个 Variable Studio 表(上图显示为 Variable Studio 1),也可以从列表中选择一个或多个不同的变量。您所做的选择在当前文档中立即可用。如果从其他文档插入变量表或变量,该文档必须具有包含这些变量的版本。如果版本不存在,系统会提示您创建一个,然后再继续。
成功选择变量和/或变量表后,您会在当前文档的 Variable Studio 中看到所选的图元:
从其插入表的 Variable Studio 的名称和版本会显示在表的顶部,在上图中显示为 Variable Studio 1 V1。
已配置 Variable Studio 必须在插入时设置其配置。请参见“参考已配置 Variable Studio”。
发布 Variable Studio
右击 Variable Studio 选项卡并选择“发布”:
无法发布已配置的 Variable Studio。
如需其他学习中心资源,请注册以下课程:变量和表达式(需要 Onshape 帐户)。