Jump to content

Ray

WAsP team
  • Posts

    19
  • Joined

  • Last visited

Ray's Achievements

  1. Hi, there is no special value to disable the timeout completely. To avoid your script getting interrupted you can just set the value to something far greater than you might expect the script to run. For example 100000 will give you just over a day before the dialog appears. The upper limit is 2147483647 (68 years!). Cheers, Ray
  2. Hi there, there is indeed a parameter dictionary, here is some code which will list all the parameters of the project: Set Configuration = Project.AsIRveaConfigurable.Configuration Set Rv68ObjectFactory = CreateObject("Rvea0068.ObjectFactory") Set ParameterDictionary = Rv68ObjectFactory.CreateParameterDictionary ' Project level parameters Set Configuration = Project.AsIRveaConfigurable.Configuration EditReport = "Project parameters shown below (ID - Description - Value)" & vbcrlf EditReport = EditReport & "------------------" & vbcrlf & vbcrlf For ParameterIndex = 1 To Configuration.NumberOfParameters Set Parameter = Configuration.ParameterByIndex(ParameterIndex) Description = ParameterDictionary.Description(Parameter.ID, "unknown") EditReport = EditReport & Parameter.ID & " - " & Description & " - " & Parameter.Value & vbCrLf Next Msgbox EditReport You can access individual parameters using the parameter ID and change it's value: ' Change the standard height #1 parameter value Set Parameter = Configuration.ParameterByID("STDH1") Parameter.Value = 17 The parameter ID for air density is ROHFORPD so you can access it with: Set Parameter = Configuration.ParameterByID("ROHFORPD") Hope that helps. Cheers, Ray
  3. Hi, I appreciate that importing many new hierarchy members via scripting might clutter the GUI somewhat with all the windows opened, unfortunately however this behaviour cannot be controlled from a script. You will need to continue to manually close the windows, the fastest way is via the Window menu (Window -> Close All). I will add this to our suggested feature list for consideration. Cheers, Ray
  4. Hi again, I have added two new type casting options to the TypeCaster: CastObjectToSessionEditable CastObjectToRveaWeibullWindEditable which make it possible to edit the sector frequencies from a script. We will be making a beta build of Wasp 11.2 in the coming days, this will be the first version to have this update. If you are interested to try this beta then let me know and I will send you download details when it is available. Using these new type casts you will be able to edit sector frequencies with something like this: Set Atlas = ReportingAssistant.TypeCaster.CastMemberToWindAtlas(ReportingAssistant.SelectedHierarchyMember) Set Rose = Atlas.WeibullWindRose(1, 1) ' Before editing the WeibullWindRose an explicit type cast to IRveaSessionEdiatble is needed. Set Session = ReportingAssistant.TypeCaster.CastObjectToSessionEditable(Rose) ' Start the Weibull rose editing session Token = Session.StartEditingSession For SectorIndex = 1 To 12 ' Get a wind from the rose Set SectorWind = Rose.WindForSectorIndex(SectorIndex) ' Explicit type cast of the wind to editable wind Set WindEditable = ReportingAssistant.TypeCaster.CastObjectToRveaWeibullWindEditable(SectorWind) ' Set the frequency, the sum of frequencies across all sectors must be 1 Frequency = 1 / 12 WindEditable.SectorFrequency = Frequency Next ' End the wiebull rose editing session Session.EndEditingSession(Token) Sorry I couldn't give some something to use immediately but it is on the way. Cheers, Ray
  5. Hi Gianluca, It looks like you can't do this at the moment from a script. To get it to work we would need to add a couple of new type casting options to the TypeCaster. I will discuss this with Duncan and will let you know if this is something we can do. So unfortunately I think at the moment the only way would be with a Developer licence, then this could done now with VBA. Cheers, Ray
  6. Hi, Wasp scripting is done using VBScript which unfortunately has a few limitations. One big one is there is no implicit type casting. This means explicit type casting is required. Many objects in Wasp implement multiple interfaces so to get access to the properties of a particular interface you need to do the type cast and this is why you see so much of this going on in the scripts. The TypeCaster provides a convenient way to do this. If however you try to do an invalid type cast, the TypeCaster will return Nothing (this is a VB null value). So sometimes it is a good idea to do a check if the returned reference from a type cast is Nothing. The AsIXxx syntax is a simple shortcut that is sometimes available to type cast an object to another type. Basically if the ASIXxx method is available for the type you want then you can use that instead of the TypeCaster. Now in the first line of your example above you have: Set RotatingAtlas = ReportingAssistant.CastableSelectedMember.AsIWindAtlas The CastableSelectedMember is a reference to the Wasp hierarchy member that was selected when you ran the script. You then call the AsIWindAtlas method which will attempt to type cast the selected member to a wind atlas. So if the selected member is not an atlas (or generalised wind climate as its known in Wasp11) then the method will return Nothing. The error you see comes on the next line when you try to access the MetStation property of Nothing. If you try running that again on a generalised wind climate hierarchy member you should have better luck. Since the selected member you are referring to could be anything and you can't gaurantee the type cast will produce a proper wind atlas reference, it is probably worth doing a check to see if the reference is nothing before continuing: Set RotatingAtlas = ReportingAssistant.CastableSelectedMember.AsIWindAtlas If Not RotatingAtlas Is Nothing Then Set MetStation = RotatingAtlas.MetStation Else Msgbox "Please select a generalised wind climate and run the script again." End If Better still, you can avoid this problem by specifying the hierarchy member type that the script is allowed to run on in the script XML header. You will see this is done in most scripts, it looks something like this: WindAtlas This means the script will be disabled in the script menu unless you have the correct hierarchy member selected. Take a look at some of the other scripts to see how to do similar thing for other hierarchy members. Hope that helps. Cheers, Ray
  7. Hi newbie, The scripts folder can be found on the Reports tab of the Wasp options dialog: Tools -> Options -> Reports -> (Root) path for report and utility scripts. The Wasp 11 standard scripts are stored in a zip archive 'WAsP 11 standard scripts.zip' in the scripts folder. If you open that zip archive you will see the individual scripts in there. Custom (individual) scripts can be placed in the scripts folder as well and Wasp will pick them up and offer them via the reports and utility script menus (they are listed below the standard scripts in the menu). So if you would like to experiment by changing an existing script you just need to copy the script out of the zip archive into the scripts folder. Restart Wasp and you should now see the script appear in the scripts menu. It is a good idea to rename the script to differentiate it from the original script. The script name as it appears in the Wasp menu is read from the 'Description' attribute in the script's XML header. Let me know if you need any further clarification. Cheers, Ray
  8. Hi guys, just letting you know we now have a build of WAsP that supports the timeout attribute in the script header! If anyone would be interested in testing this feature please let me know via email and we will get a special build out to you. Cheers, Ray
  9. The problem with the generator insertion is that you have not specified the file extension (*.wtg or *.pow) in the file name. Regarding the turbine sites, I don't think inserting turbine sites from file is available in a scripting context, so your code above wont work. Instead what you can do is write some code to open the file (CSV or you could use Excel), loop through each line doing the following: 1) parse the site coordinates 2) insert a turbine site into the windfarm 3) set the turbine site's location Once you have the location of a site parsed into coordinates, say LocationX and LocationY, here is some code that will perform the insertion and set the site location: Set Member = WindFarm.AsIHierarchyMember.Insertions.New.ByClassID(ehmcTurbineSite).Execute Set TurbineSite = ReportingAssistant.TypeCaster.CastMemberToTurbineSite(Member) TurbineSite.Description = "My site name" Call TurbineSite.AsIWaspSite.Move(LocationX, LocationY)
  10. Hi, I assume you are using Wasp 11. This error occurs because you are attempting to add an OWC directly as a child of the project, which is not allowed. If you try to do this manually in Wasp you will see that Wasp inserts a generalised wind climate member with a met station child member and the OWC will be a child of the met station. When automating Wasp you need to insert each of these members individually. So the basic idea would be: 1) Insert new generalised wind climate as child of the project member 2) Insert new met station as child of the generalised wind climate, set it's coordinates if desired 3) Insert OWC from file as child of met station Similarly, in Wasp 11 the vector map cannot be added as a child of the project directly. You first need to add a Terrain Analysis IBZ member and then add the vector map to that. Here is some code which demonstrates this. Note the use of the TypeCaster. When inserting items into the Wasp hierarchy they are of the general type IHierarchyMember. To perform an action that is specific to an particular member type you first need to type cast the general member to the appropriate type. I have demonstrated the use of the TypeCaster below for each member created. mappath="X:\Work Folder\Script Forum Question\Waspdale.map" owcpath="X:\Work Folder\Script Forum Question\Waspdale.owc" Set Project = ReportingAssistant.SelectedHierarchyMember ' Insert a generalized wind climate Set Member = Project.Insertions.New.ByClassID(ehmcWindAtlas).Execute Set Gwc = ReportingAssistant.TypeCaster.CastMemberToWindAtlas(Member) Gwc.AsIHierarchyMember.Description = "My GWC" ' Insert a met station and set its coordinates Set Member = Gwc.AsIHierarchyMember.Insertions.New.ByClassID(ehmcMetStation).Execute Set MetStation = ReportingAssistant.TypeCaster.CastMemberToMetStation(Member) Call MetStation.AsIRveaSite.Move(LocationX, LocationY) ' Insert the OWC from file Set Member = MetStation.AsIHierarchyMember.Insertions.FromFile.ByClassID(ehmcObservedWindClimate).Execute(owcpath, Nothing) Set hmOwc = ReportingAssistant.TypeCaster.CastMemberToObservedWindClimate(Member) ' Insert a IBZ Terrain Analysis Set Member = Project.Insertions.New.ByClassID(ehmcTerrainAnalysisIbz).Execute Set TerrainIbz = ReportingAssistant.TypeCaster.CastMemberToTerrainAnalysisIbz(Member) ' Insert the vector map from file Set Member = TerrainIbz.AsIHierarchyMember.Insertions.FromFile.ByClassID(ehmcVectorMap).Execute(mappath, Nothing) Set VectorMap = ReportingAssistant.TypeCaster.CastMemberToVectorMap(Member) Hope that helps. Cheers, Ray
  11. Hi, an updated scripting help file can be found here: http://wasptechnical.dk/Services/Redirect.aspx?token=ee6ea31c-ee9e-40e0-a473-ee2895d500c8 It now contains some information to help getting started with WAsP scripting.
  12. Ellipse clipping is a nice idea. Unfortunately, however, this cannot be done with WAsP.
  13. Hi, Map Editor does not provide any automation features. You could however achieve map clipping through WAsP scripting. The IVectorMap interface provides a CutWindow method which will do the trick. Here is some sample code that will clip the selected map (I used Waspdale) in WAsP. Set Rvea0086Factory = CreateObject("Rvea0086.ObjectFactory") Set Map = ReportingAssistant.TypeCaster_ .CastMemberToVectorMap(ReportingAssistant.SelectedHierarchyMember) Set Rect = Rvea0086Factory.CreateRectangle(25000, 35000, 30000, 40000) Set ClippedMap = Map.CutWindow(Rect) You could of course then export the map to file and even add it back into the workspace: ' export map to file MapFilename = "C:\WaspdaleClipped.map" Set Exportable = ReportingAssistant.TypeCaster.CastObjectToRveaPreservableObject(ClippedMap) Exportable.PreserveToFile MapFilename ' add map to workspace Set InsertedMap = CurrentWorkspace.AsIHierarchyMember_ .Insertions.FromFile.ByClassID(ehmcVectorMap).Execute(MapFilename, Nothing)
  14. Ray

    export grid error

    Hi, The wrg file format is a fixed column width format. The error message above indicates that your resource grid contains a data value which exceeds the limits allowed by the format. See this link for details of the wrg file format. It would be useful to identify which value might be exceeding the limits of the file format. For example, very large coordinate values may be causing the problem or it could be a huge power density caused by some kind of anomaly in the underlying map data. If you can identify what data is exceeding the file format limits, then we can determine if there is anything that can be done about it. Cheers, Ray
  15. Hi, Yes you can view your WAsP results in Google Earth without WAsP running. In the left hand panel in Google Earth, items under the "Temporary Places" folder are not saved when you exit Google Earth, but items under the "My Places" folder are. When you sync a WAsP project with Google Earth the project items are listed under the "Temporary Places" folder. This means they will be discarded when you close Google Earth. To save them so that they will be available next time you start Google Earth (irrespective of whether or not WAsP is running) simply copy the item into the "My Places" folder. You can do this by either dragging the item or using cut & paste. Google Earth also allows you to export any item to a kmz (or kml) file. If you right click an item and choose 'Save Place As' then you can create a kmz file. You can then choose to open this file later in Google Earth or email it to a colleague to open on their computer. If Google Earth is installed then opening a kml or kmz file will automatically load Google Earth. Hope this helps. Cheers, Ray
×
×
  • Create New...