ChemCAD 5 services to visual basic applications: User Manual, страница 7

Method             GetStreamIDsToUnitOp / GetInletStreamIDsToUnitOp / GetOutletStreamIDsToUnitOp

Returns                        total number of IDs returned in idArray, idInlets or idOutlets

Argument

Type

Description

unitOpID

idArray

idInlets

idOutlets

short

short[]

short[]

short[]

ID of a unit on the flowsheet [in]

IDs of inlets (>0) and outlet (<0) to the unit [out]

IDs of inlets to the unit [out]

IDs of outlets to the unit [out]

Method             GetNoOfFeedStreams

Returns                        count of feed streams on the current flowsheet

Method             GetFeedStreamIDs

Returns                        count of feed stream IDs returned in idArray

Argument

Type

Description

idArray

short[]

Integer array containing feed stream IDs [out]

Method             GetNoOfProductStreams

Returns                        count of product streams on the current flowsheet

Method             GetProductStreamIDs

Returns                        count of product stream IDs returned in idArray

Argument

Type

Description

idArray

short[]

Integer array containing product stream IDs [out]

Unit IDs can be retrieved for the entire flowsheet or a given stream using

Method             GetNoOfUnitOps

Returns                        count of unit operations on the current flowsheet

Method             GetAllUnitOpIDs

Returns                        count of unit IDs returned in idArray

Argument

Type

Description

idArray

short[]

Integer array containing all unit IDs

Method             GetSourceAndTargetForStream

Returns                        number of unit IDs returned

Argument

Type

Description

streamID

sourceID

targetID

short

short

short

ID of a stream on the flowsheet [in]

count of inlets to the unit [out]

count of outlets to the unit [out]

Example          The example shows how to make a table of the inlets and outlets for all the units on the current flowsheet. In this example, the inlets appear as positive integers, and the outlets as negative integers.

Sub PrintFlowsheetIDs(ByVal ChemCADEntry As Object)

On Error Resume Next

' get cc5 object

Dim flowsheet As Object

Set flowsheet = ChemCADEntry.GetFlowsheet

'streams and unitops

Dim streamCount As Integer

Dim unitOpCount As Integer

streamCount = flowsheet.GetNoOfStreams

unitOpCount = flowsheet.GetNoOfUnitOps

Dim check As Integer

Dim streamIDs(1 To 100) As Integer

Dim unitOpIDs(1 To 100) As Integer

check = flowsheet.GetAllStreamIDs(streamIDs)

If (check <> streamCount) Then

    MsgBox "Not all stream IDs are returned"

End If

check = 0

check = flowsheet.GetAllUnitOpIDs(unitOpIDs)

If (check <> unitOpCount) Then

    MsgBox "Not all unitOp IDs are returned"

End If

'feed and product streams

Dim feedCount, prodCount As Integer

Dim feedIDs(1 To 100) As Integer

Dim prodIDs(1 To 100) As Integer

feedCount = flowsheet.GetNoOfFeedStreams

check = flowsheet.GetFeedStreamIDs(feedIDs)

If (check <> feedCount) Then

    MsgBox "Not all feed stream IDs are returned"

End If

prodCount = flowsheet.GetNoOfProductStreams

check = flowsheet.GetProductStreamIDs(prodIDs)

If (check <> prodCount) Then

    MsgBox "Not all product stream IDs are returned"

End If

Dim curUnitIndex As Integer

Dim curID As Integer

Dim curInletIndex As Integer

Dim curOutletIndex As Integer

Dim curStreamIndex As Integer

Dim curRow As Integer

Dim curCol As Integer

Dim id As Integer

Dim dummy As Integer

Dim flowSht As Worksheet

Set flowSht = Worksheets("FLOWSHEET")

flowSht.Activate

curRow = 1

curCol = 1

flowSht.Cells(curRow, curCol).value = "UnitOp ID"

curCol = 3

flowSht.Cells(curRow, curCol).value = "Stream ID"

curRow = 2

For curUnitIndex = 1 To unitOpCount Step 1