#1 20.06.11 01:36
кто работал с серфером
имею:
туеву хучу фалов типа txt (порядка 3.000 штук). в них три столбца, первый координата по Х, второй координата по У, третий значение функции в этой точке. серфер умеет конвертировать txt -> grd а потом grd -> bmp. но делает он это с каждым файликом по отдельности, то есть ручками приходится каждый файл конвертировать из формата в формат. но у меня их 3.000 штук! попробовал поделать, хватило на 50 штук. чуть не трехнулся:)
вообще задача из этих файликов собрать видеоролик. gifanimator отлично работает с кучей bmp файлов, но как их получить из txt ума не приложу. думал уже прогу написать, которая с помощью OpenGL выдает картинки, но возиться не охота, и надо желательно через серфер это организовать. как это сделать, мож че посоветуете?
Offline
#7 20.06.11 20:04
Re: кто работал с серфером
итак, проблема решена.
открыл внутри серфера штуку, в которой пишутся скрипты, там, долго мучаясь нашел и написал следующий скрипт (херовая документация), вдруг кому понадобится:
Sub Main
'Declare object and string variables used in the script
Dim SurferApp, Plot, ContourMapFrame, ContourMap As Object
Dim InFile, GridFile, tmpname, counetr_str, BaseName As String
Dim counter, counter_int As Integer
counter = 1
counter_int = 0
'Create the Surfer Application object and assign it to the "SurferApp" variable
Set SurferApp = CreateObject("Surfer.Application")
'SurferApp.Visible = True 'Make Surfer visible
While counter<1000
counter_int = counter_int + 1
counter_str = Int (counter_int)
'InStr (counter, counter_str)
InFile = "D:\surfer\T_Pr_2700_Gr_" + counter_str + ".txt"
'Get file name without the extension (for example, "week5.txt" becomes "week5")
BaseName = InFile
ExtStart = InStrRev(InFile,".")
If ExtStart > 1 Then BaseName = Left(InFile,ExtStart-1)
'Create a grid from the specified data file using the Kriging algorithm
GridFile = BaseName + ".grd"
SurferApp.GridData DataFile:=InFile, ShowReport:=False, OutGrid:=GridFile
'Create a plot document in Surfer and assign it to the variable named "Plot"
Set Plot = SurferApp.Documents.Add(srfDocPlot)
'Create a contour map. Assign the map frame to the "ContourMapFrame" variable
Set ContourMapFrame = Plot.Shapes.AddContourMap(GridFile)
'Assign the contour map properties to the variable named "ContourMap"
Set ContourMap = ContourMapFrame.Overlays(1)
ContourMap.FillContours = True 'Fill the contour map levels
'Returns the Levels collection object.
Set Levels = ContourMap.Levels
'Set the level fill color with a gradation from blue to red
n = Levels.Count
n2 = n / 2
ColorInc = 255.0 / (n-1)
For i = 1 To n
ColorInc = 255.0 * (i-1) / (n-1)
If n2 >= i Then
Levels(i).Fill.ForeColor = RGB(ColorInc, 2 * ColorInc, 255-ColorInc)
Else
i2 = (n - i) * 2 + 1
ColorInc = 255.0 * (i2-1) / (n-1)
Levels(i).Fill.ForeColor = RGB(ColorInc, ColorInc, 255-ColorInc)
End If
Next i
'ContourMap.BlankFill.ForeColor.ColorMap.LoadFile(FileName:="D:\Rainbow.clr")
'ContourMap.BlankFill.ForeColor = srfColorBrown
'Plot.PrintOut 'Print the page on the default printer
'Plot.SaveAs(BaseName + ".srf") 'Save the map
tmpname = BaseName + ".jpg"
Plot.Export2 (FileName:= tmpname , SelectionOnly:=False , Options:="Width=400, Height=529”, FilterId:=”tif")
counter = counter + 1
Wend
End Sub
этот скрипт решает проблему (из файлов *.txt конвертирует их в картинки *.jpg), у меня например 1000 штук. Ну кому надо, думаю разберется.
Offline

