각 포트의 크기를 변경할 수 있으므로 가장 큰 포트가 포함된 면을 확인해야 합니다. 그러면 그에 따라 블록 크기를 적절히 조정할 수 있습니다. 이 작업을 수행하려면 또 다른 규칙이 필요합니다.
가장 큰 포트를 확인하려면 세 포트 크기 매개변수 값을 살펴보고 가장 큰 값을 그대로 유지합니다. block_shape_rule에서와 마찬가지로 T자형 블록의 동작은 엘보우 스타일 블록의 동작과 달라야 합니다.
T자형 블록의 경우 세 포트가 모두 사용되므로 모든 포트 크기를 확인합니다. 엘보우 스타일 블록의 경우에는 억제되어 있는 포트 B를 확인하지 않습니다. MaxOfMany 함수를 사용하여 입력 값 세트에서 가장 큰 값을 가져옵니다.
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
이름이 port인 새 로컬 변수는 사용 가능한 포트 중 가장 큰 포트의 크기를 가집니다. 이제 이 정보를 사용하여 모형에 수행할 동작을 지정해야 합니다. 모형은 포함된 Excel 스프레드시트에서 정보를 가져옵니다. 따라서 스프레드시트를 확인하여 전체 모형 크기를 업데이트하게 됩니다.
i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port)
찾고 있는 열은 port_size 열이며 찾을 값은 지정된 변수 값입니다.
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")
이제 크기가 가장 큰 포트를 확인했으므로 이에 따라 블록 상단 크기를 조정합니다. 이제 T자형과 엘보우를 살펴봐서 포트 A/포트 B 면에서 어느 포트 크기가 더 큰지 확인하여 블록 높이를 결정합니다.
If block = "tee" Then porta = MaxOfMany(port_a_size, port_b_size) ElseIf block = "elbow" porta = port_a_size End If
값이 한 개만 사용되어야 하기 때문에 MaxOfMany 함수는 엘보우 스타일 블록에 사용되지 않습니다. 이 값에서는 변수를 설정할 수 있습니다.
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")
두 번째 매개변수 값의 경우에는, 다른 포트에 사용되는 수직 간격띄우기 외에 추가 공간을 삽입하기 위한 특수 논리를 추가합니다. 이 정보는 또 다른 스프레드시트 셀에서 가져옵니다. 엘보우-스타일 블록에만 이와 같이 수행합니다.
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")
block_size 규칙이 완료되었습니다.