Welcome to Golden Software Support

Comments

4 comments

  • Avatar
    Kien Pham

    The code works great. Thank you.

    Is there a way to have the contours added to the same plot insteading of generating new plot for during each i in the loop?

    Is there a way to modify the placement of the contour in the plot window within the loop?

    0
    Comment actions Permalink
  • Avatar
    Leslie McWhirter

    Hi Kien,

    You could us something like this to add the contour layers to the existing map:

    Sub Main
        
        Dim SurferApp As Object
        Set SurferApp = CreateObject("Surfer.Application")
        SurferApp.Visible = True
    
        'Opens a new plot document
            Dim Plot As Object
            Set Plot = SurferApp.Documents.Add
    
        '==================================
        '               User-defined variables
        '==================================
            Path$ = "c:\temp\SAMPLE\datafile"
            Num = "1"
            FileFmt$ = ".dat"
        '==================================
    
        'Create ther first grid from the first data file
            SurferApp.GridData(DataFile:=Path$+Num+FileFmt$, OutGrid:=Path$+Num+".grd")
    
        'Creates a contour map from the grid file
            Dim Map As Object
            Set Map = Plot.Shapes.AddContourMap(GridFileName:=Path$+Num+".grd")
    
    'This starts a loop to grid teh 4 remaining data files'that have consecutive names
    ' (such as datafile1.dat, datafile2.dat,) then add them as contour layers to the existing map
        For i = 2 To 5
    
            'Specifies the path to the data file
                Path = "c:\temp\SAMPLE\datafile"+Format(i)
    
            'Create a grid from the data file
                SurferApp.GridData(DataFile:=Path+FileFmt$, OutGrid:=Path+".grd")
    
            'Creates a contour map from the grid file
                Plot.Shapes.AddContourLayer(Map:= Map, GridFileName:=Path+".grd")
    
        Next i
    
        'Prints the plot document
            Plot.PrintOut
    
    End Sub
    

     

     

    You could add a line in the loop to move the map (see below), but it doesn't make sense to do so for the above script, since you just have one map rather than multiple maps:

     

    Map.Left = Map.xLength+i
    Map.Top =Map.yLength+i

     

     

    Thanks,

    Leslie

     

    1
    Comment actions Permalink
  • Avatar
    Kien Pham

    I am looking to add to this loop the automation of transformation, setting the x scale and z scale within each i data set. Can someone help?

    0
    Comment actions Permalink
  • Avatar
    Leslie McWhirter

    Hi Kien,

    You can use the zLength command or the zMapPerPU command for the MapFrame object to set the Z scale, and you can use the xLength command or the xMapPerPU command to set the X scale. Put these in the loop with a defined number to set the same size for all maps, or use the loop variable (i) in an equation to vary the size.

    Thanks,

    Leslie

    1
    Comment actions Permalink

Please sign in to leave a comment.