'------------------------------------------------------------------------------| ' ProjMeta.ave ' Release 1.9.2 ' This Iteration: 11/2/00 8:46AM ajw ' ' Purpose: Create Metadata for an ArcView Project. ' ' History: Start January 1999, Andrew Wooley -- awooley@mountainland.org ' ' 02/03/99 4:53PM Added File Dialog to browse through directory structure ' to place file in desired location. Also, minor cosmetic fixes ' 02/05/99 5:22PM Added Show Comments section and automatic execution of Notepad ' to show the resulting file. ' 03/04/99 4:01PM Fix the GRID BUG!!. (Thanks to Dovey Dee for the clue) ' 03/10/99 2:11PM Fix the ViewFrame Name in a Grouped Graphic ' 03/12/99 7:22AM Added code, courtesy of Stewart Edwardes, to check the OS and ' execute the appropriate text editor to view the saved file. ' 03/15/99 8:23AM Fixed the Dialog bug, Thanks for the heads up from Colin Wright ' Really fixed the Viewframe/Graphic Group bug (probably). ' 03/29/99 12:02PM Fixed the Library Path Name so that it no longer returns a nil value. ' Thanks to Timothy Case for the tip. ' 06/04/99 9:40AM (CET) Event themes in view (.txt) are mentioned and the ' path's are added to the tablenames (Bart Willemse RIKZ nl) ' script runs under HP-UX version 10 ' 06/17/99 1:06PM Added the check for joins in a Table. This will now be ' shown in the End Notes ' and for each table with joins a ^ is added. ' Thanks to Rick Gray for the suggestion ' 6/13/00 4:50PM Added Total document/theme count and directory list ' 8/21/00 12:14PM Misc Fixes ' 9/13/00 4:42PM Add Scale to Layout and View ' 9/26/00 10:53AM Fix Grid Theme Def bug. Other misc changes. ' 10/5/00 4:13PM AAARRHG!!! Really Fixed Grid/Image Problems. Added Dependencies list ' 11/2/00 8:46AM Added live link check to view frame ' 11/7/00 1:33PM Check for user specified scale in layouts ' 11/22/00 9:34AM Fixed a bug at ReturnScale in Layout section ' ' Legal: No warranty is implied or expressed regarding ' the functionality of this program. ' ' Methodology: Gets each view in a doc and gets the source for each theme and type ' and puts it into a text file called [project name].apm ' ' Requires: An ArcView Project ' ' Notes: Has been tested for Windows 95, 98 and NT and HP-UX version 10 (Bart Willemse RIKZ nl) ' ' Suggestions or Bug Fixes?? Send to: awooley@mountainland.org ' ' Future Enhancements: HTML Version in addition to Plain Text in an Extension ' '------------------------------------------------------------------------------| '------------------------------ ' Setting the Initial Variables '------------------------------ theTitle = "Project Metadata" theProjName = av.GetProject.GetFileName.AsString Date.SetDefFormat("MMMM d, yyyyy h:m AMPM") if (theProjName = "nil") then theProjName = "Untitled.apr" end SA = Extension.Find("Spatial Analyst") if (SA = nil) then SA = Extension.Find("3d Analyst") end depList = av.GetProject.GetDependencies c = theProjName.Count theName = theProjName.Left(c - 4) theName = theName+".apm" fFile = FileDialog.Put(theName.AsFileName, "*.apm", theTitle) if (fFile = nil) then return nil end fName = LineFile.Make(FFile, #FILE_PERM_WRITE ) fname.WriteElt("Description for "+theProjName++ Date.Now.AsString+nl+ " ("+fname.AsString+")") fname.WriteElt(nl+"Project Dependencies:" ) deplist.sort(TRUE) for each dep in depList fname.WriteElt(" "+ dep.getname) end 'From Avenue Toolkit '~~~~getlistofdocs.ave 'Getting List of Docs vlist = {} laylist = {} scrlist = {} tablist = {} chalist = {} dialist = {} pathList = {} for each d in av.getproject.getdocs if (d.Is(View)) then vlist.Add(d) elseif ((d.Is(Layout)) and (d.Is(DialogEditor).Not))then laylist.Add(d) elseif (d.Is(SEd)) then scrlist.Add(d) elseif (d.Is(Table)) then tablist.Add(d) elseif (d.Is(Chart)) then chalist.Add(d) elseif (d.Is(DialogEditor)) then dialist.Add(d) end 'if docs end 'for each doc '~~~~end getlistofdocs.ave fname.WriteElt(""+nl+"VIEWS - "+ vlist.Count.AsString + " Total Views") 'start looping through each view. if (vlist.Count <> 0) then for each v in vlist 'Writing the Name of the View theThemes = v.GetThemes fname.WriteElt(nl+" "+v.GetName+ " - "+theThemes.Count.AsString + " themes in this View") fname.WriteElt( " "+ "Scale: " + v.ReturnScale.AsString ) 'Getting the View Comments com = v.GetComments if (com <> "") then fname.WriteElt(" "+"Comments for: "+v.GetName+nl+" "+com+nl) else 'fname.WriteElt(nl) end if (theThemes.Count <> 0) then 'Looping Through Each ofthe Themes in the View for each t in theThemes if (t.IsVisible.Not) then vis = "*" else vis = " " end 'if visible tname = t.GetName 'writing full pathname or connect with table (event theme) if (t.GetSrcName.GetFileName <> nil) then tfName = t.GetSrcName.GetFileName.GetFullName pthName = tfName.Left(tfName.Count - (t.GetSrcName.GetFileName.GetBaseName.Count + 1)) pathList.Add(pthName) else tfName = "event theme from table "+tname end thmDef = "" if ((t.HasTable) and (t.Is(FTheme) and (Not(t.Is(Library))))) then ttype = t.GetFtab.FindField("shape").GetType.AsString sType = t.GetLegend.ReturnDefaultSymbol.GetType if (ttype = "FIELD_SHAPEPOLY") then ttype = "polygon" elseif (ttype = "FIELD_SHAPELINE") then ttype = "polyline" elseif (ttype = "FIELD_SHAPEPOINT") then ttype = "point" elseif (ttype = "FIELD_SHAPEMULTIPOINT") then ttype = "multipoint" end 'if ttype = 'This is to solve the anno problem if (sType = #SYMBOL_TEXT) then ttype = "annotation" end thmDef = t.GetFtab.GetDefinition elseif (t.Is(Library)) then ttype = "A/I Library" tfName= t.GetSrcName elseif ((SA <> nil) and (Not(t.Is(ITheme)))) then ttype = "grid" elseif (t.Is(ITheme)) then ttype = "image" end 'if HasTable tLine = " "+tname.AsString+" -- "+tfName.AsString+" ("+ttype+")"+vis fname.WriteElt(tLine) 'Get Theme Comments thmCom = t.GetComments if (thmCom.Count <> 0) then fname.WriteElt(" "+"Comments for: "+tname.AsString+nl+" "+t.GetComments) end 'GetTheme Definition if (thmDef <> "") then fname.WriteElt(" "+thmDef) end end 'for each t else tLine = " There are no themes in "+(v.GetName)+nl fname.WriteElt(tLine) end ' if theme count <> 0 end 'for each view else vLine = " This project has no Views"+nl fname.WriteElt(vLine) end 'if vlist count <> 0 '~~~~~~~~LAYOUTS fname.WriteElt(nl+"LAYOUTS - "+ laylist.Count.AsString + " Total Layouts"+nl) 'Start looping through each layout if (laylist.Count <> 0) then for each l in laylist fname.WriteElt(" "+l.GetName) gl = l.GetGraphics '~~~Start of the Beautiful code from odb.avx ODB.ReturnViewFrames '~~~This corrects the grouped viewframe name return bug ~~~~~~~ theVFList = {} theViewFrames = gl.FindAllByClass(ViewFrame) if (theViewFrames <> nil) then for each i in theViewFrames theScale = i.GetUserScale theScaleTxt = theScale.AsString if (theScale = 0) then theScale = i.ReturnScale theScaleTxt = theScale.AsString end if (i.IsLiveLinked.Not) then theVFList.Add(i.GetView.GetName.AsString + "!" + "~~~~~" + theScaleTxt) else theVFList.Add(i.GetView.GetName.AsString + "~~~~~" + theScaleTxt) end 'theVFList.Add(i.GetView.GetName.AsString + "~~~~~" + i.GetView.ReturnScale.AsString) 'fname.WriteElt(" ViewFrames: "+i.GetView.GetName.AsString+nl) end end 'msgbox.info("#VF's:"++theViewFrames.Count.AsString,"Test") ' Must Check all Graphic Groups in Layout for ' viewframes theGGs = gl.FindAllByClass(GraphicGroup) ' Check Graphic Groups for ViewFrames ' add Viewframes in Graphic groups to theViewframes List if (theGGs <> nil) then theGGCount = theGGs.Count for each GG in theGGs aGG = GG.GetGraphics.Clone ' Remove an graphic from the graphic group. ' If the graphic is a viewframe add it to the ' viewframes list. If it is a graphic group, add all ' of the graphics of that graphic group back to original ' graphic group. Continue until all graphics have been checked While (aGG.Count > 0) aGraphic=aGG.Get(0) aGG.Remove(0) if (aGraphic.Is(ViewFrame)) then theScale = agraphic.GetUserScale theScaleTxt = theScale.AsString if (theScale = 0) then theScale = agraphic.ReturnScale theScaleTxt = theScale.AsString end if (aGraphic.IsLiveLinked.Not) then theVFList.Add(aGraphic.GetView.GetName.AsString + "!" + "~~~~~" + theScaleTxt) else theVFList.Add(aGraphic.GetView.GetName.AsString + "~~~~~" + theScaleTxt) end 'theVFSList.Add(aGraphic.GetView.ReturnScale) 'fname.WriteElt(" ViewFrames: "+aGraphic.GetView.GetName.AsString+nl) elseif (aGraphic.Is(GraphicGroup)) then aGList = aGraphic.GetGraphics aCount = aGList.Count-1 for each i in 0..aCount aGG.Add(aGList.Get(i)) end end end 'While end ' For each GG end ' theGGs <> nil '~~~~~~~End ODB.ReturnViewFrames if (theVFList.Count <> 0) then for each x in theVFList fname.WriteElt(" ViewFrames: "+x.AsTokens("~~~~~").Get(0)) fname.WriteElt(" Scale: "+x.AsTokens("~~~~~").Get(x.AsTokens("~~~~~").Count - 1)+nl) end else fname.WriteElt(" There are no Views in "+(l.GetName)+nl) end 'if gl count <> 0 end 'for each l else fname.WriteElt(" This project contains no Layouts") end 'if l count <> 0 '~~~~~~~~TABLES fname.WriteElt(nl+"TABLES - "+ tablist.Count.AsString + " Total Tables"+nl) 'Start looping through each Table if (tablist.Count <> 0) then for each t in tablist hasjoined = false for each f in (t.GetVtab.GetFields) if (t.GetVtab.IsJoinedField(f)) then hasjoined = true end end if (hasjoined ) then fname.WriteElt(" "+t.GetName+"^") else fname.WriteElt(" "+t.GetName) end end else fname.WriteElt(" This project contains no Tables") end '~~~~~~~~SCRIPTS fname.WriteElt(nl+"SCRIPTS - "+ scrlist.Count.AsString + " Total Scripts"+nl) 'Start looping through each script if (scrlist.Count <> 0) then for each s in scrlist fname.WriteElt(" "+s.GetName) end else fname.WriteElt(" This project contains no Scripts") end '~~~~~~~~CHARTS fname.WriteElt(nl+"CHARTS - "+ chalist.Count.AsString + " Total Charts"+nl) 'Start looping through each CHART if (chalist.Count <> 0) then for each c in chalist fname.WriteElt(" "+c.GetName) end else fname.WriteElt(" This project contains no Charts") end '~~~~~~~~DIALOGS fname.WriteElt(nl+"DIALOGS - "+ dialist.Count.AsString + " Total Dialogs"+nl) 'Start looping through each DIALOG if (dialist.Count <> 0) then for each d in dialist fname.WriteElt(" "+d.GetName) end else fname.WriteElt(" This project contains no Dialogs") end '~~~~~Notes fname.WriteElt(" "+nl+"NOTES: "+nl+ "* Theme is not drawn in the view"+nl+ "^ Tables contains Joins"+nl+ "! View NOT Live Linked") pathList.RemoveDuplicates fname.WriteElt(nl+"All Paths in this project:") pathList.Sort(TRUE) for each i in pathList fname.WriteElt(" " + i) end 'Closing the File for writing fname.Close 'Code offered by Stewart Edwardes 12 March 99 'Makes it work on Unix. theOS = System.GetOS.asstring UNIXOS = "SYSTEM_OS_UNIX" WINDOWSOS = "SYSTEM_OS_MSW" MAC = "SYSTEM_OS_MAC" 'I don't know what macs have to execute, but feel free to add it if you need if (theOS = UNIXOS) then system.execute("/usr/dt/bin/dtpad"++ffile.GetFullName++"&") elseif (theOS = WINDOWSOS) then system.execute("notepad"++ffile.GetFullName.asstring) else msgbox.error("Don't understand what operating systems you are working"+ +"on!!!! File has been saved to"+NL+ffile.GetFullName.asstring, theTitle) end