;Присваивание сохраненной легенды темам ,выбранным из списка
'-----------------------------------------------------------------------------------
' GET THE VIEW AND THE THEMES
theView = av.GetActiveDoc
if (theView.is(View).not) then
msgBox.Info("Activate a View before running this Script","")
return NIL
end
theThemes = theView.GetThemes
theActThemes = theView.GetActiveThemes.clone
'-----------------------------------------------------------------------------------
' LET'S CLONE THE LIST
theThmList = theThemes.clone
'-----------------------------------------------------------------------------------
' IF THE USER'S PLAYING UP; SHOW HER
if (theThmList.Count = 0) then
theThmList.Add("Ну_ты_блин_даешь.shp")
Msgbox.MultiListAsString(theThmList,"Select the Themes to load a Legend... "," Load LEGEND")
return NIL
end
'-----------------------------------------------------------------------------------
' ASK THE USER WHICH THEMES
theView.getDisplay.flush
selList = Msgbox.MultiList(theThmList,"Select the Themes to load a Legend: (PS: Click OK without Selection to sort this "+
"List by Theme Type)"," LOAD LEGEND FOR")
'-----------------------------------------------------------------------------------
' CHECK TO SEE IF SOME WHERE SELECTED, BAIL IF NOT AND USER CANCELS, PREPARE FOR A
' NEW LIST IN ORDER OF THEME-TYPE - IF NOTHING WAS SELECTED AND USER CLICKS OK:
if (selList = NIL) then
av.ShowMsg(" BREAKUP: Load Legend ...")
return NIL
elseif (selList.Count = 0) then
sortByType = TRUE
else
sortByType = FALSE
end
'-----------------------------------------------------------------------------------
if (sortByType = FALSE) then
'-----------------------------------------------------------------------------------
' ASK THE USER WHICH LEGEND TO TAKE
theLegendFile = FileDialog.Show ("*.avl", "ArcView Legend (*.avl)", "Choose a legend file:")
if (theLegendFile = nil) then
av.ShowMsg(" BREAKUP: Load Legend ...")
return NIL
end
i = 0
theCF = nl+"Can not find Classification Field : "+nl+nl
theCFC = 0
theTF = nl+"Legend improper for : "+nl+nl
theTFC = 0
'-----------------------------------------------------------------------------------
' ASSIGN THE LEGEND, CHECK FOR SOME ERRORS
for Each thm in selList
theCurLegCl = thm.GetLegend.clone
theCurLeg = thm.GetLegend
if (thm.GetClass.GetClassName = "STheme") then
theTF = theTF +" '"+thm.getName+"'"+nl
theTFC = theTFC + 1
continue
elseif (thm.is(ITheme)) then
theTF = theTF +" '"+thm.getName+"'"+nl
theTFC = theTFC + 1
continue
end
theLegLo = theCurLeg.Load(theLegendFile, #LEGEND_LOADTYPE_ALL)
if (theLegLo = TRUE) then
i = i + 1
else
theTF = theTF +" '"+thm.getName+"'"+nl
theTFC = theTFC + 1
continue
end
theNuLeg = thm.GetLegend
if ((theNuLeg.getLegendType = #LEGEND_TYPE_SIMPLE) and (thm.GetClass.GetClassName = "GTheme")) then
thm.setLegend(theCurLegCl)
theTF = theTF +" '"+thm.getName+nl
theTFC = theTFC + 1
i = i - 1
continue
end
if ((theNuLeg.getLegendType <> #LEGEND_TYPE_SIMPLE) or (theNuLeg.getlegendtype <> #LEGEND_TYPE_DOT)) then
theFldNames = theNuLeg.GetFieldNames
for each Nm in theFldNames
if (thm.is(Ftheme)) then
theFTab = thm.getFTab
if ((theFTab.FindField(Nm) = NIL)) then
thm.setLegend(theCurLegCl)
theCF = theCF + " Field '"+Nm.asString+"' misses in '"+thm.getName+"'"+nl
theCFC = theCFC + 1
i = i - 1
end
elseif ((thm.GetClass.GetClassName = "GTheme") and (thm.hasTable)) then
theVTab = thm.getVTab
if ((theVTab.FindField(Nm) = NIL)) then
thm.setLegend(theCurLegCl)
theCF = theCF + " Field '"+Nm.asString+"' misses in '"+thm.getName+"'"+nl
theCFC = theCFC + 1
i = i - 1
end
elseif ((thm.GetClass.GetClassName = "GTheme") and (thm.hasTable).not) then
if (Nm.AsString <> "Value") then
thm.setLegend(theCurLegCl)
theCF = theCF + " Field '"+Nm.asString+"' misses in '"+thm.getNa