Tutorial Part 3: Creating a Grid

Grid lines can be added to a design using the AddGridLines method of the Grids object. The following section of code adds waterlines, section lines and buttock lines to the current design. The variables for adding grid lines are in the following order: grid line type, name, location, and angle*

§   * = The grid line angle is ignored except for diagonal gridlines. 

Public Sub Tutorial_3()

    Dim msDesign As Maxsurf.Design

    Set msDesign = msApp.Design

 

    'Create a Grid

    'Create waterlines

    msDesign.Grids.AddGridLine msGTWaterlines, WL1, -2, 0

    msDesign.Grids.AddGridLine msGTWaterlines, WL2, -1, 0

    msDesign.Grids.AddGridLine msGTWaterlines, WL3, 1, 0

    msDesign.Grids.AddGridLine msGTWaterlines, WL4, 2, 0

    'Create Section lines

    msDesign.Grids.AddGridLine msGTSections, Sec1, -9, 0

    msDesign.Grids.AddGridLine msGTSections, Sec2, -5, 0

    msDesign.Grids.AddGridLine msGTSections, Sec3, -1, 0

    msDesign.Grids.AddGridLine msGTSections, Sec4, 1, 0

    msDesign.Grids.AddGridLine msGTSections, Sec5, 5, 0

    msDesign.Grids.AddGridLine msGTSections, Sec6, 9, 0

    'Create Buttock Lines

    msDesign.Grids.AddGridLine msGTButtocklines, B0, 0, 0

    msDesign.Grids.AddGridLine msGTButtocklines, B1, 1.5, 0

    msDesign.Grids.AddGridLine msGTButtocklines, B2, 3, 0

   

    msApp.Refresh

 

End Sub

 

This code creates new grid lines, regardless of existing grid lines. Running this code twice will create two sets of grid lines on top of each other. To avoid this situation, all the grid lines can be deleted, prior to creating the new grid lines by using the following code inserted before the grid is created in tutorial_3()

 

    'Remove any existing Grid

    msDesign.Grids.DeleteAllLines msGTWaterlines

    msDesign.Grids.DeleteAllLines msGTSections

    msDesign.Grids.DeleteAllLines msGTButtocklines

 

Running the code now will remove all existing grid lines, prior to creating the new ones.

 

See Also:

Grids on page 21

Modifying Grid Lines in Excel on page 58