Tutorial Part 4: Calculating the Hydrostatics

The Maxsurf automation interface allows calculation and reading of Hydrostatic data for a design.

 

For this tutorial exercise, we will read some of the hydrostatic data and display it in a message box. Although this code only takes in a small amount of data, all of the data that is available through the Hydrostatics window inside Maxsurf is available through the automation interface.

The code is comprised of four sections:

·   Defining variables

·   Calculating the hydrostatics

·   Reading in hydrostatic data and

·   Displaying the data in message boxes.

 

Public Sub Tutorial_4()

 

    Dim msDesign As Maxsurf.Design

    Set msDesign = msApp.Design

 

    'Define Variables for use in the code

    Dim Displacement As Long

    Dim Draft As Long

    Dim Beam As Long

   

    'Calculate the Hydrostatic Data for the Hull

    msDesign.Hydrostatics.Calculate 1025, -2

    'Get the Hydrostatics of the Hull

    Displacement = msDesign.Hydrostatics.Displacement

    Draft = msDesign.Hydrostatics.ImmersedDepth

    Beam = msDesign.Hydrostatics.BeamWL

    'This is only a selection of all the hydrostatic data

 'available

 

    'Display the Hydrostatic Data in Message Boxes

    MsgBox "The Displacement is " & Displacement & " kg"

    MsgBox "The Draft is " & Draft & " m"

    MsgBox "The Beam is " & Beam & " m"

 

End Sub

 

The Calculate method reads in two inputs, these are the water density (kg/m3) and the vertical centre of gravity (m). These are the same two options as the Hydrostatics dialog box inside Maxsurf.

 

Other hydrostatic data could be displayed by:

·   Defining another variable name

Eg Dim WSA As Long

·   Setting the variable to equal a data amount

Eg WSA = msDesign.Hydrostatics.WSA

·   Creating another message box to display the amount

Eg MsgBox “The Surface Area is “ & WSA &  “ m2

 

See Also:

Hydrostatics on page 22

Calculating the Hydrostatics on page 67