'---------------------------------
'Name: View.Avl2Icm
'Date: 1-17-01
'Author: Marco Morais
'
' prompts the user for a grid in current view
'
' generates an Index Color Map file (*.icm)
' corresponding to the legend in the grid
'
'Returns:
'NILL
'
'Called By:
'MANY
'
'Calls:
'View.ZoomFullExtentArgs
'
'Arguments:
'None
'---------------------------------
MsgBox.Report("Grid.AddGridsAvl" + NL +
"1. prompts the user for a grid in the current view" + NL +
"2. generates an Index Color Map file (*.icm)" + NL +
" from the legend of the selected grid", "About Script....")
theView = av.GetActiveDoc
if ( (theView = NIL) or (theView.Is(View).Not) ) then
MsgBox.Error("This script can only be run from within a View document", "Error")
return NIL
end
theThemeList = theView.GetThemes
if ( theThemeList.Count = 0 ) then
MsgBox.Error("You must have at least one theme loaded into the legend to create an ICM file.", "Error")
return NIL
end
theTheme = MsgBox.Choice(theThemeList, "Select the theme whose legend will be exported as an ICM file.", "Choose Theme")
if ( theTheme = NIL ) then
return NIL
end
'--------------------------------------------
'determine if themes legend suitable for ICM
'--------------------------------------------
if ( (theTheme.GetLegend.GetLegendType = #LEGEND_TYPE_SIMPLE).Not and
(theTheme.GetLegend.GetLegendType = #LEGEND_TYPE_UNIQUE).Not ) then
MsgBox.Error("Only SIMPLE or UNIQUE legend types can be made into ICM files.", "Error")
return NIL
end
theSymbolsList = theTheme.GetLegend.GetSymbols
theClassificationsList = theTheme.GetLegend.GetClassifications
if ( theClassificationsList.Get(0).ReturnMinimum.Is(Number) = FALSE ) then
MsgBox.Error("Only numeric classifications can be made into ICM files.", "Error")
return NIL
end
'--------------------------------
'get icm file
'--------------------------------
theICMTextFile = av.Run("Util.CreateNewTextFilePrompt", {theTheme.GetName, "icm"})
if ( theICMTextFile = NIL ) then
return NIL
end
'--------------------------------
'populate contents ICM file
'--------------------------------
i = 0
for each s in theSymbolsList
if ( theClassificationsList.Get(i).GetLabel = "No Data" ) then
i = i + 1
continue
end
theColor = s.GetColor
if ( theColor = NIL ) then
i = i + 1
continue
end
theICMLine = theClassificationsList.Get(i).ReturnMinimum.AsString + "=" +
theColor.GetRgbList.Get(0).AsString + ":" +
theColor.GetRgbList.Get(1).AsString + ":" +
theColor.GetRgbList.Get(2).AsString + NL
av.Run("Util.AppendToFile", {theICMTextFile, theICMLine})
i = i + 1
end
theICMTextFile.Close
av.PurgeObjects
return NIL
Last Updated: Marco Morais