Procedure
How can I use Avenue to create a scalebar on a layout?
Answer:
The following sample script will create a scalebar on a Layout. Change the size, location and units in the script to suit your needs.
The order of the requests is important. If the same requests are issued in a different order, the scalebar may not display.
myLayout = av.GetProject.FindDoc("Layout1")
myGraphics = myLayout.GetGraphics
n = ScaleBarFrame.Make(Rect.Make((746@746.5),(5.76@0.5)))
n.SetViewFrame(myGraphics.Get(0)) 'assumes the 0th object is a viewframe
n.SetStyle(#SCALEBARFRAME_STYLE_ALTFILLED)
n.SetUnits(#UNITS_LINEAR_METERS)
n.SetInterval(2000)
n.SetIntervals(2)
n.SetDivisions(3)
n.SetTextRatio(4)
n.SetDisplay(myLayout.GetDisplay)
n.SetBounds(Rect.Make((746@746.5),(5.76@0.75)))
myGraphics.Add(n)
Notes:
The fill object for a legend frame is a view frame, not a view or a legend.