You are on page 1of 3

'********************************************* '* This example shows how to use Avenue to * '* autolabel many themes have have conflicts

* '* between labels resolved within a theme's * '* labels and with other theme's labels. * '********************************************* '************************************************** '* Identify the view and the themes that are to * '* be labeled, then set those themes to be active * '* because the labeler object will not load them * '* unless they are active. * '************************************************** theView = av.GetActiveDoc theGraphics=theView.GetGraphics theHighways = theView.FindTheme("Highways") theRivers = theView.FindTheme("Rivers") theLakes = theView.FindTheme("Lakes") theCities = theView.FindTheme("City Population") theHighways.SetActive(true) theRivers.SetActive(true) theLakes.SetActive(true) theCities.SetActive(true) '************************************************* '* Set the textSymbol of all the themes to be * '* labeled, it needs to be large enough to be * '* useful for all themes, since that textSymbol * '* is initially used for all themes. The reason * '* you need to do this is that there is a bug * '* with setting the textSymbol for any other * '* theme to be different that causes ArcView to * '* crash. * '************************************************* aTextSym = TextSymbol.Make aTextSym.SetFont(Font.Make("Arial","Bold")) aTextSym.SetSize(12) theHighways.SetLabelTextSym(aTextSym) theRivers.SetLabelTextSym(aTextSym) theLakes.SetLabelTextSym(aTextSym) theCities.SetLabelTextSym(aTextSym) '*************************************************** '* Make the labeler object and set the extent that * '* is to be labeled. This example uses the entire * '* view's extent. You might want to use * '* theView.GetDisplay.ReturnVisExtent to label * '* just the visible extent of the view. * '*************************************************** anExt = theView.ReturnExtent aLabeler = Labeler.Make(anExt)

'********************************************* '* As each of the themes are loaded into the * '* labeler object, their feature and label * '* weights may need to be set in order to * '* create the most appropriate result. * '********************************************* aLabeler.SetFeatureWeight(#LABEL_WEIGHT_HIGH) aLabeler.SetLabelWeight(#LABEL_WEIGHT_HIGH) aLabeler.RemoveDuplicates(true) aLabeler.Load(theCities) aLabeler.SetFeatureWeight(#LABEL_WEIGHT_MEDIUM) aLabeler.Load(theHighways) aLabeler.Load(theRivers) aLabeler.Load(theLakes) theView.GetAutoLabels(aLabeler, false) '******************************************* '* Due to a bug, the textSymbols for each * '* theme are not honored during the label * '* placement process, so here is a the * '* workaround to this. Note, that the * '* size of labels are not accounted for * '* here, so be careful about setting a * '* theme's labels to be a larger size as * '* conflicts may arise. * '******************************************* aTextSym2 = TextSymbol.Make aTextSym2.SetFont(Font.Make("Arial","Normal")) aTextSym2.SetSize(10) theView.GetDisplay.HookUpSymbol(aTextSym2) theHighways.SetLabelTextSym(aTextSym2) thedeleteList = {} theGraphics.UnSelectAll for each HwyLabel in theHighways.GetGraphics thedeleteList.Add(HwyLabel.clone) HwyLabel.SetSelected(true) end theGraphics.ClearSelected aHwyGTS = {} for each oldGL in thedeleteList aString = oldGL.GetText aPoint = oldGL.GetBounds.ReturnOrigin anAngle = oldGL.GetAngle newGL = GraphicLabel.MakeWithSym ( aString, aPoint, aTextSym2, aHwyGTS ) newGL.SetAngle(anAngle) theGraphics.addbatch(newGL) end aTextSym3 = TextSymbol.Make

aTextSym3.SetFont(Font.Make("Arial","Italic")) aTextSym3.SetSize(10) aTextSym3.SetColor(Color.GetBlue) theView.GetDisplay.HookUpSymbol(aTextSym3) theDeleteList = {} theGraphics.UnSelectAll for each lakeLabel in theLakes.GetGraphics theDeleteList.Add(lakeLabel.Clone) lakeLabel.SetSelected(true) end for each riverLabel in theRivers.GetGraphics theDeleteList.Add(RiverLabel.clone) riverLabel.SetSelected(true) end theGraphics.ClearSelected aWaterGTS = {} for each oldGL in thedeleteList aString = oldGL.GetText aPoint = oldGL.GetBounds.ReturnOrigin anAngle = oldGL.GetAngle newGL = GraphicLabel.MakeWithSym ( aString, aPoint, aTextSym3, aWaterGTS ) newGL.SetAngle(anAngle) theGraphics.AddBatch(newGL) end theGraphics.EndBatch

You might also like