Similar to a symbol, Custom Assembly provides for dynamic outputs (that is, outputs whose count may vary dynamically at runtime). An example of this might be the structural member legs of an equipment foundation. Declaring a dynamic output can appear similar to the following:
'Declaring a dynamic structural member leg output.
<AssemblyOutput(1, "FoundationMemberlegsā)> _
Public m_objFoundationLegs As AssemblyOutputs
The definition of a field variable of type AssemblyOutputs with same AssemblyOutput defining attribute as present for singularly declared assembly outputs. AssemblyOutputs inherits from List<BusinessObject>; hence, AssemblyOutptus is a collection (i.e., list) of BusinessObjects. The code within the EvaluateAssembly method would add and subtract business objects from this list based on the needed count:
<InputString(2, "FoundationShape", "Foundation Shape", "Rectangle")> _
Public m_sFoundationShape As InputString
<AssemblyOutput(1, "FoundationLegs")> _
Public m_objFoundationLegs As AssemblyOutputs
'Evaluate assembly outputs.
Public Overrides Sub EvaluateAssembly()
Dim iLegCount As Integer
iLegCount = 0
If m_sFoundationShape.Value = "Rectangle" Then
iLegCount = 4
ElseIf m_sFoundationShape.Value = "Hexagon" Then
iLegCount = 6
End If
' Current leg count.
Dim iCurrentLegCount As Integer
iCurrentLegCount = m_objFoundationLegs.Count
Dim iCnt As Integer
If iCurrentLegCount = iLegCount Then ' No change.
ElseIf iCurrentLegCount < iLegCount Then ' Need to add some legs.
For iCnt = iCurrentLegCount + 1 To iLegCount
m_objFoundationLegs.Add(New Member(...
Next
Else ' remove some legs
For iCnt = iCurrentLegCount To iLegCount + 1 Step -1
m_objFoundationLegs.RemoveAt(iCnt)
Next
End If
.
.