Now that we can change the size of each port, we must determine which face has the largest port, so that the block can be sized appropriately. It requires another rule.
To determine the largest port, we examine the values of the three port size parameters, and retain the largest value. As with block_shape_rule, the behavior for tee-style blocks must be different than for elbow-style blocks.
For tee-style blocks, all three ports are used, so we check the sizes for all them. For elbow-style blocks, we do not check Port B, which is suppressed. We use the MaxOfMany function to get the largest value from a set of input values.
If block = "tee" Then port = MaxOfMany(port_a_size,port_b_size,port_c_size) ElseIf block = "elbow" Then port = MaxOfMany(port_a_size,port_c_size) End If
A new local variable named port holds the size of the largest available port. Now we have to tell the model what to do with this information. The model obtains its information from an embedded Excel spreadsheet, so we look at the spreadsheet to update the overall sizes of the model.
i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port)
We are using the port_size column for the lookup, and the value of the assigned variable as the value to look for.
block_depth = GoExcel.CurrentRowValue("block_depth") port_c_depth_from_front = GoExcel.CurrentRowValue("port_c_depth_from_front") block_width = GoExcel.CurrentRowValue("block_width") port_a_hor_offset = GoExcel.CurrentRowValue("hor_offset") port_b_hor_offset = GoExcel.CurrentRowValue("hor_offset") port_c_hor_offset = GoExcel.CurrentRowValue ("hor_offset")
We have now determined which port is the largest, and we are sizing the top of the block accordingly. Now, we determine the height of the block by examining the tee and elbow to determine which port size is bigger on the Port A / Port B face.
If block = "tee" Then porta = MaxOfMany(port_a_size, port_b_size) ElseIf block = "elbow" porta = port_a_size End If
The MaxOfMany function, is not used for elbow-style blocks, since only one value must be considered. We can set the variable from that value.
i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", porta)
port_a_vert_offset = GoExcel.CurrentRowValue("vert_offset") port_b_vert_offset = GoExcel.CurrentRowValue("vert_offset")
For this value, we add special logic to insert extra space beyond the vertical offset used for the other ports. This information is obtained from another spreadsheet cell. We only do it for elbow-style blocks.
If block = "elbow" Then port_c_vert_offset = GoExcel.CurrentRowValue("vert_offset") + (GoExcel.CurrentRowValue("port_dia")/4) Else port_c_vert_offset = GoExcel.CurrentRowValue("vert_offset") End If block_height = GoExcel.CurrentRowValue("block_height")
The block_size rule is complete.