Jump to content

documentation


Recommended Posts

Hi there!
I know there isn't any documentation released by WAsP, but are there some descriptions for the codes. I'm trying to adjust some codes by myself and need to know for example whats:
- TypeCaster
- AsIXxx (eg AsIWindAtlas)
- CastMemberToMetStation(Member)

In my opinion its partly hard to derive the functions

For example: I get an error for
Set RotatingAtlas = ReportingAssistant.CastableSelectedMember.AsIWindAtlas
Set MetStation = RotatingAtlas.MetStation

"Wasp Object required: 'RotatingAtlas'

Can anyone help?
Link to comment
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
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...