' Name: PrintGraphs
'
' Title: Print a set of same-size views on a single layout automatically
'
' Topics: Views, Layouts
'
' Description: Prints a set of same-size views on a single layout, automatically scaling.
' Would use a subroutine if Avenue had that desirable item.
'
' Author: Michael Silberbauer 2001-04-26
' Institute for Water Quality Studies, Department of Water and Sanitation
' Private Bag X313 PRETORIA South Africa 0001
' 2001-04-26
'
' Requires: A set of consistently-named views
' Self:
'
' Results:
' -----------------------------------------------------------------------------
'ISOdate is a datestamp string:
nowDate = Date.Now
nowDate.SetFormat("yyyy-MM-dd")
nowTime = Date.Now
nowTime.SetFormat("hhhh:m")
ISOdate = nowDate.asString++nowTime.AsString
theProject = av.GetProject
n = 1
LayoutName = "GraphLayout"+n.AsString
myDoc = theProject.FindDoc(LayoutName)
if (myDoc<>nil) then
theProject.RemoveDoc(myDoc)
end
theLayout = Layout.Make
theLayout.Setname(LayoutName)
theDisplay = theLayout.GetDisplay
yPage = 11.69
xPage = 16.54
theDisplay.SetPageSize(xPage@yPage)
theDisplay.SetGridActive(false)
theDisplay.SetUsingPrinterMargins(true)
theDisplay.SetMarginVisible(true)
theDisplay.SetUsingPrinterPageSize(true)
theDisplay.ZoomToPage
thePageExtent = theDisplay.ReturnPageExtent
thePageOrigin = thePageExtent.ReturnOrigin
x0 = thePageOrigin.GetX
y0 = thePageOrigin.GetY
xPage = thePageExtent.GetWidth
yPage = thePageExtent.GetHeight
xm = xPage/33
ym = yPage/33
xPlot = (xPage-(4*xm))/3
yPlot = 0.2*xPlot
ViewL = List.Make
DocumentList = theProject.GetDocs
for each anItem in DocumentList
if (anItem.is(view)) then
ViewL.Add(anItem)
end
end
sieve = MsgBox.Input("Enter a view selection string","SIEVE"++ISOdate,"pH")
ViewList = List.Make
for each aView in ViewL
if (aView.GetName.AsString.Contains(sieve)) then
ViewList.Add(aView)
end
end
if (ViewList=nil) then
MsgBox.Info("No views to print","CHEAP ROUND!")
exit
end
aTitle = MsgBox.Input("Enter a layout title","SIEVE"++ISOdate,sieve)
nPage = 1
xg = x0+xm
yg = y0+yPage-ym
theTitlePt = xg@yg
theGText = GraphicText.Make(aTitle++"("+nPage.AsString+")",theTitlePt)
GTextSymbol = theGText.ReturnSymbols.Get(0)
GTextSymbol.SetSize(10)
theLayout.GetGraphics.Add(theGText)
xg = x0+(0.87*xPage)
yg = y0+ym
theDatePt = xg@yg
theGText = GraphicText.Make("Layout created"++ISOdate,theDatePt)
GTextSymbol = theGText.ReturnSymbols.Get(0)
GTextSymbol.SetSize(8)
theLayout.GetGraphics.Add(theGText)
xg = x0+xm
yg = y0+yPage-ym-yPlot
for each nView in ViewList
if (yg-ym<y0) then
xg = xg+xm+xPlot
xr = xg+xPlot
yg = y0+yPage-ym-yPlot
if (xr>(x0+xPage)) then 'page full
n = n+1
xg = x0+xm
yg = y0+yPage-ym-yPlot
LayoutName = "GraphLayout"+n.AsString
myDoc = theProject.FindDoc(LayoutName)
if (myDoc<>nil) then
theProject.RemoveDoc(myDoc)
end
theLayout = Layout.Make
theLayout.Setname(LayoutName)
theDisplay = theLayout.GetDisplay
theDisplay.SetPageSize(xPage@yPage)
theDisplay.SetGridActive(false)
theDisplay.SetUsingPrinterMargins(true)
theDisplay.SetMarginVisible(true)
theDisplay.SetUsingPrinterPageSize(true)
theDisplay.ZoomToPage
nPage = nPage+1
theGText = GraphicText.Make(aTitle++"("+nPage.AsString+")",theTitlePt)
GTextSymbol = theGText.ReturnSymbols.Get(0)
GTextSymbol.SetSize(10)
theLayout.GetGraphics.Add(theGText)
theGText = GraphicText.Make("Layout created"++ISOdate,theDatePt)
GTextSymbol = theGText.ReturnSymbols.Get(0)
GTextSymbol.SetSize(8)
theLayout.GetGraphics.Add(theGText)
end
end
r = nView.ReturnExtent
nView.GetDisplay.SetExtent(r.Scale(1.1))
vRectOrigin = xg@yg
vRect = Rect.Make(vRectOrigin,(xPlot@yPlot))
vViewFrame = ViewFrame.Make(vRect)
vViewFrame.SetView(nView,true)
theLayout.GetGraphics.Add(vViewFrame)
yg = yg-yPlot
end
theLayout.Invalidate