The WEAPTag class represents a single Tag, whereas WEAPTags is a collection of Tags. The WEAPTagCategory class represents a single Tag Category, whereas WEAPTagCategories is the collection of all Tag Categories in the active area.
You can get access to a WEAPTags collection in three different ways:
The Tags property of the WEAPApplication class, giving all tags defined: WEAP.Tags
The Tags property of the WEAPBranch class, giving all tags assigned to a specific branch, e.g., WEAP.Branch("\Demand Sites\South City").Tags
The Tags property of the WEAPTagCategory class, giving all tags within a tag category, e.g., WEAP.TagCategories("Demand Types").Tags
You can get access to a WEAPTag in two different ways:
Specify either the name of the Tag or a number from 1 to WEAP.Tags.Count, e.g., WEAP.Tags("Agriculture") or WEAP.Tags(2)
Iterate through the collection of Tags, e.g., For Each Tag in WEAP.Tags, For Each Tag in WEAP.Branch("\Demand Sites\South City").Tags, For Each Tag in WEAP.TagCategories("Demand Types").Tags
WEAPTags Properties and Methods |
Example (using VB script) |
Add(Tag, TagCategory, Color, Description): The Add method can be used in three different ways:
When a new tag is being created, you specify the Name and optionally the Category, Color and Description. Category is either the tag category name or a WEAPTagCategory object. If the tag category name does not exist yet, it will be created. For Color, see the WEAPTag.Color property below for the list of valid colors. Category, Color and Description are all optional parameters. If omitted, Category will be "Uncategorized," Color will be White, and Description will be blank. You can only add or change tags in the Schematic or Data Views. The Add method has no effect if the Tags collection came from a WEAPTagCategory object. Note: WEAPBranchObject.Tags.Add(Existing Tag Name) is equivalent to WEAPBranchObject.HasTag(Tag Name) = TRUE |
CALL WEAP.Tags.Add("Agriculture", "Demand Types", "Red", "Demand Sites with irrigation demand.") ' Create a tag CALL WEAP.Tags.Add("Municipal", WEAP.TagCategories("Demand Types")) ' Create a tag CALL WEAP.Tags.Add("Urban") ' Create a tag (category is unspecified) CALL WEAP.Branch("\Demand Sites\South City").Tags.Add("Large", "City Size", "Green", "Cities with population greater than one million people.") ' Create a tag and add it to the branch CALL WEAP.Branch("\Demand Sites\South City").Tags.Add(WEAP.Tags("Urban")) 'tag the branch with an existing tag
|
Count: The Count property gets the number of Tags in the WEAPTags collection.
Read only. |
PRINT "There are " & WEAP.Tags.Count & " tags in " & WEAP.ActiveArea.Name FOR EACH TC in WEAP.TagCategories PRINT "There are " & TC.Tags.Count & " tags in " & TC.Name NEXT FOR EACH Br in WEAP.Branches PRINT "There are " & Br.Tags.Count & " tags on " & Br.Name NEXT FOR i = 1 to WEAP.Tags.Count PRINT WEAP.Tags(i).Name
& ", (" & WEAP.Tags(i).Category.Name & ")" ' This is equivalent to: FOR EACH Tag in WEAP.Tags |
Exists(TagName): The Exists method can be used in three different ways: Read only.
Returns TRUE or FALSE. Read only. |
IF WEAP.Tags.Exists("Agriculture")
THEN WEAP.Tags("Agriculture").Delete '
delete it if it exists IF NOT WEAP.Branch("\Demand Sites\South City").Tags.Exist("Urban") THEN WEAP.Branch("\Demand Sites\South City").Tags.Add(Urban) ' add the tag to the branch if it isn't already there END IF |
Item(TagName or Index): Get the Tag identified by name or index (from 1 to Tags.Count). Item is the default property, so ".Item" can be omitted. Read only. |
PRINT WEAP.Tags.Item("Agriculture").Color PRINT WEAP.Tags("Agriculture").Color WEAP.Tags("Agriculture").Color = "Blue" Note: the Item property is the "default" property, and therefore is usually omitted. Thus, the first two examples above are equivalent. |
NameList: Get a list of tags separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only. |
PRINT "Tags: " & WEAP.Tags.NameList |
WEAPTag Properties and Methods |
Example (using VB script) |
Branches: Get collection of branches that have this tag, if any. |
FOR EACH Tg in WEAP.Tags FOR EACH Br IN Tg.Branches PRINT
" "
& Br.Name NEXT |
Category: Set or get the WEAPTagCategory object for the tag. Initially, tags are in the "Uncategorized" category. You can only add or change tags in the Schematic or Data Views. |
PRINT WEAP.Tags("Agriculture").Category.Name WEAP.Tags("Agriculture").Category = WEAP.TagCategories("Demand Types") WEAP.Tags("Municipal").Category = WEAP.Tags("Agriculture").Category |
Color: Set or get the color associated with the tag. The color can be used to set the color for branches in the tree, according to the color of the branch's tag (if any). Valid colors are: Red, Orange, Yellow, Green, Blue, Indigo, Violet, Lavender, Turquoise, Pink, Gold, Rose, Tan, Teal, Lime, Aqua, Plum, Olive Green, Dark Green, Dark Teal, Dark Blue, Dark Red, Dark Yellow, Blue Gray, Bright Green, Sky Blue, Light Orange, Sea Green, Light Blue, Light Yellow, Light Green, Light Turquoise, Pale Blue, White, Black, Brown, Gray 25%, Gray 40%, Gray 50% and Gray 80%. You can only add or change tags in the Schematic or Data Views. |
PRINT WEAP.Tags("Agriculture").Color WEAP.Tags("Agriculture").Color = "Red" |
Delete: either delete the tag from the area's list or remove it from a branch's list of tags. Delete tag: if the Tags collection came from the Tags property of the WEAPApplication class, Delete will delete the tag from the area's list of tags. Remove tag from branch: if the Tags collection came from the Tags property of the WEAPBranch class, Delete will remove that tag from the branch. Note: WEAPBranchObject.Tags(Tag Name).Delete is equivalent to WEAPBranchObject.HasTag(Tag Name) = FALSE You can only add or change tags in the Schematic or Data Views. The Delete method has no effect if the Tag came from a WEAPTagCategory object Tags collection. |
WEAP.Tags("Agriculture").Delete ' Delete tag "Agriculture" IF WEAP.Branch("\Demand Sites\South City").Tags.Exists("Municipal") THEN WEAP.Branch("\Demand Sites\South City").Tags("Municipal").Delete ' Remove tag "Municipal" from Demand Site South City's tags. END IF FOR EACH Tag IN WEAP.Branch("\Demand Sites\West City").Tags Tag.Delete ' Remove every tag from West City NEXT |
Description: Set or get the tag's description. You can only add or change tags in the Schematic or Data Views. |
FOR EACH Tag in WEAP.Tags NEXT WEAP.Tags("Municipal").Description = "Only large cities -- over 1 million people" |
ID: Get WEAP's internal ID code of the Tag. Most users will never need this information. Read only. |
PRINT "ID code for "; WEAP.Tags("Agriculture").Name; "is "; WEAP.Tags("Agriculture").ID |
Name: Set or get the tag's name. You can only add or change tags in the Schematic or Data Views. |
FOR EACH Tag in WEAP.Tags NEXT WEAP.Tags("Agriculture").Name = "Farming" ' Change name from Agriculture to Farming |
You can get access to a WEAPTagCategories collection from the WEAPApplication class: WEAP.TagCategories.
You can get access to a WEAPTagCategory in two different ways:
Specify either the name of the TagCategory or a number from 1 to WEAP.TagCategories.Count, e.g., WEAP.TagCategories("Demand Types") or WEAP.TagCategories(2)
Iterate through the collection of TagCategoris, e.g., For Each TagCategory in WEAP.TagCategories
WEAPTagCategories Properties and Methods |
Example (using VB script) |
Add(TagCategoryName): Add a tag category.
You can only add or change tag categories in the Schematic or Data Views. |
WEAP.TagCategoies.Add("Basin")
|
Count: The Count property gets the number of Tag Categories in the WEAPTagCategories collection. Read only. |
FOR i = 1 TO WEAP.TagCategories.Count PRINT WEAP.TagCategories(i).Name NEXT |
Exists(TagCategoryName): Return TRUE if the Tag Category exists, FALSE if it does not. Read only. |
IF not WEAP.TagCategoies.Exists("Demand Types") THEN WEAP.TagCategoies.Add("Demand Types") END IF |
Item(TagName or Index): Get the Tag identified by name or index (from 1 to Tags.Count). Item is the default property, so ".Item" can be omitted. Read only. |
PRINT WEAP.Tags.Item("Agriculture").Color PRINT WEAP.Tags("Agriculture").Color WEAP.Tags("Agriculture").Color = "Blue" Note: the Item property is the "default" property, and therefore is usually omitted. Thus, the first two examples above are equivalent. |
NameList: Get a list of tag categories separated by character specified by optional parameter ListSeparator (which defaults to comma). Read only. |
PRINT "Tag Categories: " & WEAP.TagCategories.NameList |
WEAPTagCategory Properties and Methods |
Example (using VB script) |
Delete: Delete this Tag Category. Any tags that were in this category will be reset to be in the "Uncategorized" category. You can only add or change tag categories in the Schematic or Data Views. |
WEAP.TagCategories("Demand Types").Delete |
ID: Get WEAP's internal ID code of the Tag Category. Most users will not ever need this information. Read only. |
PRINT "ID code for "; WEAP.TagCategories("Demand Types").Name ; "is "; WEAP.TagCategories("Demand Types").ID |
Name: Set or get the tag category's name. The name of the Uncategorized category is "Uncategorized" (this cannot be changed). You can only add or change tag categories in the Schematic or Data Views. |
WEAP.TagCategories("Demand Types").Name = "Types of Demand" |
Tags: Get the list of tags in this tag category. |
FOR EACH TagCategory IN WEAP.TagCategories PRINT "The following are the tags in tag category " & TagCategory.Name & ":" FOR EACH Tag IN TagCategory.Tags PRINT " " & Tag.Name NEXT NEXT |