现在,我们将介绍本教程开头所列出的最后两个话题:
iLogic 可以提供从 Excel 电子表单中读取信息的内置函数。在“系统”选项卡的“代码段”区域中,通过展开“Excel 数据链接”节点即可找到这些函数。
在本课程中,我们将撰写这样一个规则:基于指定尺寸使用嵌入式 Excel 电子表单中的值为用于控制端口几何图元的参数设定值。规则会在电子表格中查找端口尺寸来确定值所在的行。然后从该行中读取字段来获取相应的参数值。
三通样式块中包含三个端口。每个端口都在“参数”对话框中列出。但是,在“参数”对话框中更改端口尺寸并不会更改模型中的端口尺寸。我们必须添加规则来驱动端口尺寸的变化。
第一步就是添加用于设定端口尺寸和每个端口周围螺钉阵列尺寸的规则。在部件中使用螺钉阵列将凸缘固定到块上。
规则必须要做的第一件事就是在电子表单中找到包含 Port A 所用的值的行。我们要在标签为 port_size 的列中查找与 port_a_size 参数匹配的值。
i = GoExcel.FindRow(“3rd Party:Embedding 1”, “Sheet1”, “columnName”, “<=”, 0.2)
i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_a_size)
此代码表示我们要在嵌入式电子表单中找到 port_size 列与 port_a_size 参数值相等的行。
i = GoExcel.CurrentRowValue("columnName")
如此处所示,编辑代码段副本。
port_a_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw") port_a_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw") port_a_port_dia = GoExcel.CurrentRowValue("port_dia") Port_A_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth")
Feature.ThreadDesignation("featurename") = “3/8-16 UNC”
如此处所示,修改文本。
Feature.ThreadDesignation("Port_A_Threads") = GoExcel.CurrentRowValue("tap_dim")
我们已经说明,应该使用 tap_dim 单元来获取螺栓孔的螺纹规格。
i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_a_size) port_a_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw") port_a_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw") port_a_port_dia = GoExcel.CurrentRowValue("port_dia") Port_A_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth") Feature.ThreadDesignation("Port_A_Threads") = GoExcel.CurrentRowValue("tap_dim") i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_b_size) port_b_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw") port_b_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw") port_b_port_dia = GoExcel.CurrentRowValue("port_dia") Port_B_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth") Feature.ThreadDesignation("Port_B_Threads") = GoExcel.CurrentRowValue("tap_dim") i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_c_size) port_c_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw") port_c_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw") port_c_port_dia = GoExcel.CurrentRowValue("port_dia") Port_C_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth") Feature.ThreadDesignation("Port_C_Threads") = GoExcel.CurrentRowValue("tap_dim")