We now cover the last two topics listed in the beginning of this tutorial:
iLogic provides built-in functions that read information from Excel spreadsheets. These functions are available in the Snippets area, on the System tab, by expanding the Excel Data Links node.
In this lesson, we write a rule that uses values from an embedded Excel spreadsheet to set the values for parameters that control the port geometry, based on a specified size. Our rule looks up the port size in the spreadsheet to identify the row of values. Then it reads fields from that row to get the appropriate parameter values.
A tee-style block includes three ports. Each port is listed in the Parameters dialog box. However, changing the port size in the Parameters dialog box does not change the port size in our model. We must add rules to drive the different port sizes.
Our first step is to add a rule that sets the size of the ports and the dimensions of the screw pattern around each port. The screw pattern is used in the assembly to hold a flange onto the block.
The first thing our rule must do is locate the row in the spreadsheet that contains the values to use for Port A. We look up the value matching the port_a_size parameter in a column labeled port_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)
This code indicates that we want to find the row in the embedded spreadsheet that has a port_size column that equals the value of the port_a_size parameter.
i = GoExcel.CurrentRowValue("columnName")
Edit your copies of the snippet as shown here.
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”
Modify the text as shown here.
Feature.ThreadDesignation("Port_A_Threads") = GoExcel.CurrentRowValue("tap_dim")
We have indicated that we should use the tap_dim cell to get the thread designation for the bolt holes.
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")