English

How To: Add Library layers to a View [SCRIPT]

Procedure

Question:

How do I properly bring in a Library layer using Avenue code?

Answer:

The following script might assist you with bringing in your libraries from ARC/INFO Librarian as themes into ArcView. The online Avenue Help for SrcName.Make request gives an example of dot notation between the libraries. In the Help example, you must substitute your real library.layer names. If you are using variables for these "real" names, you will need to concatenate the
variables with the dot notation character, as follows.

Prerequisites:

You should have a View active in your project before running this script. You should also have libraries already setup for ArcView.
'------ Begin Script

theView = av.GetActiveDoc

'--- Retrieve your Librarian
theLList = Librarian.ReturnLibrarians
myLibrarian = MsgBox.List(theLList,"","")

'--- Retrieve your Library
aLib = myLibrarian.ReturnLibraries
myLibrary = MsgBox.List(aLib,"","")

'--- Or you can make your own library directly using ...
'--- myLibrary = Library.Make("your_library","ARC/INFO*LIBRARIAN")

'--- Check to see if you have a valid path set for the library you've chosen.
thepath = myLibrary.GetPath
MsgBox.Info(thePath,"")

'--- Choose a layer based on your previously-selected Library
theLayers = myLibrary.ReturnLayers
mylayer = Msgbox.List(theLayers,"","")

'--- Add the ARC/INFO*LIBRARIAN layer with polygon feature class
theSrc = SrcName.Make(myLibrary.AsString+"."+mylayer.AsString++"polygon")

'--- Create a theme from theSrc and add it to a View
aTheme = theme.Make(theSrc)
theView.AddTheme(aTheme)

' aTheme.SetName("MyGreatLayer") '--- Optional
aTheme.InvalidateLegend
aTheme.SetVisible(TRUE)

'------ End Script