#1 2016-12-06 11:34:39

Duncan
WAsP team
From: Europe
Registered: 2009-05-14
Posts: 282

Simple sectorwise site corrections text output script

Hi everyone,

Yesterday I hacked up a quick script for a colleague. It's simple and useful, so I thought of just posting it here in case anyone finds it helpful. I'll just paste the script source in here.


The script finds all the turbine sites in the project root and writes a text file of sectorwise corrections in a way which is convenient for some other progam to read and use.


Best wishes, Duncan.




<?xml version="1.0" encoding="UTF-8"?>
<RveaWaspInternalScript MinimumApplicationVersion="11.01.0001" CurrentApplicationVersion="11.05.0001" FormatVersion="01.01.0001" Description="2016-12-05 Turbine site corrections to file" ScriptVersion="11.01.0001">
<ScriptType OutputType="Text">Utility</ScriptType>
<RequiredProjectSelection>Project</RequiredProjectSelection>
<ScriptCode><![CDATA[

Sub Main()

Filename = "c:\temp\Output.txt"
'Delimiter = vbTab
'Delimiter= "; "
Delimiter = ", "

Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextStream = FSO.CreateTextFile(Filename, True)

Set Project= ReportingAssistant.TypeCaster.CastMemberToProject(ReportingAssistant.SelectedHierarchyMember)

Project.DoAllFeasibleCalculations

Set Iterator = Project.AsIHierarchyMember.Children.FilterByClass(ReportingAssistant.AllClasses.TurbineSiteClass)

Set TurbineSite = ReportingAssistant.TypeCaster.CastMemberToTurbineSite(Iterator.FirstMember)

Do While Not TurbineSite Is Nothing
    X = TurbineSite.AsIWaspSite.Location.X
    Y = TurbineSite.AsIWaspSite.Location.Y
    Z = TurbineSite.HubHeightAgl
    SectorCount = TurbineSite.AsIWaspSite.SiteAssessment.CountOfSectors
    For SectorIndex = 1 To SectorCount
        OroSpeed = TurbineSite.AsIWaspSite.SiteAssessment.SectorForIndex(SectorIndex).OrographicCorrection.SpeedMultiplier
        OroTurn = TurbineSite.AsIWaspSite.SiteAssessment.SectorForIndex(SectorIndex).OrographicCorrection.DirectionDeflectionDegrees
        RoughSpeed = TurbineSite.AsIWaspSite.SiteAssessment.SectorForIndex(SectorIndex).RoughnessCorrection.SpeedMultiplier
        OneLine = TurbineSite.Description
        OneLine = OneLine & Delimiter & X & Delimiter & Y & Delimiter & Z & Delimiter & SectorIndex & Delimiter
            OneLine = OneLine & ReportingAssistant.FormatValueWithPointDecimal(OroSpeed) & Delimiter
            OneLine = OneLine & ReportingAssistant.FormatValueWithPointDecimal(OroTurn) & Delimiter
            OneLine = OneLine & ReportingAssistant.FormatValueWithPointDecimal(RoughSpeed)
        TextStream.WriteLine OneLine
    Next
    Set TurbineSite = ReportingAssistant.TypeCaster.CastMemberToTurbineSite(Iterator.NextMember)
Loop

Call ReportingAssistant.DisplayFileInNotepad(Filename)
TextStream.Close
Set fso = Nothing

End Sub

]]></ScriptCode></RveaWaspInternalScript>

Offline

Board footer

Powered by FluxBB