Once we have the surface in the design, we can edit the locations of the control points to create the desired hull shape. The control points are moved using the SetControlPoint method. The method takes in 5 variables in the following order: row, column, position offset and height;
Public Sub Tutorial_2()
Dim msDesign As Maxsurf.Design
Set msDesign = msApp.Design
i = msDesign.Surfaces.Count 'This finds the number
'of surfaces in the design
'Move all the control Points to form a vessel shape.
'All these dimensions are in metres,
'regardless the units set inside of Maxsurf
msDesign.Surfaces(i).SetControlPoint 1, 1, -10, 0, -2
msDesign.Surfaces(i).SetControlPoint 2, 1, -10, 3, -1.5
msDesign.Surfaces(i).SetControlPoint 3, 1, -8, 3, 2
msDesign.Surfaces(i).SetControlPoint 1, 2, 0, 0, -2.5
msDesign.Surfaces(i).SetControlPoint 2, 2, 0, 5, -2
msDesign.Surfaces(i).SetControlPoint 3, 2, 0, 5, 2
msDesign.Surfaces(i).SetControlPoint 1, 3, 7.5, 0, -2
msDesign.Surfaces(i).SetControlPoint 2, 3, 9.5, 0, -2
msDesign.Surfaces(i).SetControlPoint 3, 3, 10, 0, 3
'To update the screens in Maxsurf, use the refresh command
msApp.Refresh
End Sub
This script also uses the Surfaces.Count method. This finds the total number of surfaces in the design. This is then used by the Surfaces object, to ensure that the SetControlPoints method is acting on the most recently created surface.
The code looks cluttered with all the control point coordinate data in it. Instead of including all the data in the code, automation allows us to place the data in an Excel spreadsheet and make references to this from the code. This way, changes to the design can be easily implemented in the spreadsheet, rather than in the code. This is where the power of automation comes in. Examples using this are included in Chapter 6 Examples.
See Also:
Surface Object on page 44