'LOADING SCRIPTS ' 1. Double-click on an empty area on the bar containing all buttons, The "Customize" dialog appears ' 2. In the "Type" pull-down, select "View" ' 3. In the "Category" pull-down, select "Buttons", The display right below the pull down changes to show an array of buttons ' 4. Slide the scrollbar (below the button display) to the right and select the last button by clicking on it, Now click on "New" ' 5. A new blank button appears. Double-click on the blank area to the right of the entry "Click" (just below the button display) ' 6. The "Script Manager" Dialog appears, Click on "New", Enter any name in the input box that appears (prefix it with "Z_" so that it goes in the last) ' 7. A new blank script document (With the name just specified) appears. Delete whatever is on it... ' 8. Either copy-paste this ENTIRE script on the document, or, click on the button with the open-folder icon (tooltip reads "Load text file") and navigate to this file ' 9. Either done, click on the button with the tick-mark icon ("compile"). If spatial analyst is not loaded, there will be some error message, Load it ' 10. After the script is compiled (the tick-mark buton should be grayed out), close the script window and return to the view ' 11. Click on the new button to run the script 'FOR THIS SCRIPT ' There should be at least TWO CATEGORICAL GRIDS ACTIVE for the script to work 'SCRIPT COMMENTARY:: 'RECOGNIZE THE OPEN DOCUMENT AS THE VIEW (THE SCRIPT IS FIRED FROM A BUTTON ADDED TO THE VIEW) TheView = av.GetActiveDoc 'GET ALL ACTIVE THEMES AS A LIST TheGThemes = TheView.GetActiveThemes 'CHECK THE NUMBER OF ACTIVE GRIDS, BAIL OUT IF LESSER THAN 2 ThemeCount = TheGThemes.Count if (ThemeCount < 2) then msgbox.info("Leser than two Grids active, Please select a minimum of two grids", "Combine Grids") exit end 'INITIATE EMPTY LISTS TO CONTAIN INTERMEDIATE RESULTS GridList={} NewGridList={} 'LOOP OVER ALL ACTIVE THEMES ctr=0 for each g in TheGThemes 'CHECK IF FEATURE THEME IS ACTIVE if (g.Is(FTHeme)) then msgbox.info("Theme"++g.GetName++"is a feature theme, Removing...", "Feature theme active!!") continue end 'CHECK IF GRID IS CONTINUOUS TestVtab = g.GetGrid.GetVtab if (TestVtab = Nil) then msgbox.info("Grid"++g.GetName++"is continuous, Will be removed", "Continuous grid theme active!!") else 'ADD TO INTERMEDIATE LIST IF ALL PROBLEMS ARE SOLVED NewGridList.Add(g) end ctr=ctr+1 end 'AGAIN CHECK IF NEW LIST CONTAINS LESSER THAN TWO ITEMS If (NewGridList.Count < 2) then msgbox.info("Lesser than two grids left...Aborting!!", "Grid count lower than two") exit end 'PREPARE THE BASE AND JOIN GRID LISTS cnt=0 for each g in NewGridList if (cnt=0) then BaseGrid=g.GetGrid else GridList.Add(g.GetGrid) end cnt=cnt+1 end 'FINALLY JOIN THE BASEGRID WITH ALL GRIDS IN THE LIST NewGrid=BaseGrid.Combine(GridList) TheVtab = NewGrid.GetVtab 'ADD THE COMBINED GRID TO THE VIEW TheView.AddTheme(GTheme.Make(NewGrid)) TheView.Invalidate 'ASK FOR EXPORTING CROSSTABULATED VALUES Resp = msgbox.YesNo("Do you want to export the crosstabulated values?","Export Data?",TRUE) if (Resp) then aFN=FileDialog.Put("crosstab.dbf".AsFileName,"*.dbf","Specify save location") theVTab.Export (aFN, dBASE, TRUE ) end 'OPEN TABLE FOR VIEWING zoneTable = Table.Make(theVTab) zoneTable.GetWin.Activate