HOW TO

Automatically print different view frame extents from a single layout

Last Published: April 25, 2020

Summary

You can use Avenue to print multiple versions of a single layout at different extents. The script in this article is a typical example of working with views, layouts, view frames, and using different extents on a display.

Procedure

This script prints a copy of "Layout1" for each feaute in "Theme1.shp" in "View1". You may need to edit the script to reflect the name of your theme. layout and view.

  1. Create a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into the window and compile the script.

    Code:
    '-- Define the layout, view and theme objects

    aLayout = av.FindDoc("Layout1")
    aLayout.GetGraphics.Empty
    aView = av.FindDoc("View1")
    aTheme = aView.FindTheme("Theme1.shp")
    aFtab = aTheme.GetFtab

    '-- Create a ViewFrame object (vf)

    origin = aLayout.GetDisplay.ReturnMarginExtent.ReturnOrigin+(1@1)
    vf = ViewFrame.Make( Rect.Make( origin,(5@5)))

    '-- Add the ViewFrame object (vf) to the layout and
    '-- set the view of the ViewFrame to aView

    aLayout.GetGraphics.Add(vf)
    vf.SetView(aView,TRUE)

    '-- Loop for each feature in "Theme1.shp"
    '-- Set the extent of aView's Display to the extent returned for a feature (p)
    '-- The display is returned with the request aView.GetDisplay
    '-- The Fill Object of the ViewFrame is set to aView.
    '-- aLayout is sent the Print command.
    '-- Note: If you have 10 features, you will get 10 printed maps

    for each rec in aFtab
    p = aFtab.ReturnValue(aFtab.GetFields.Get(0),rec)
    aView.GetDisplay.SetExtent(p.ReturnExtent)
    'aView.GetDisplay.Flush
    'aView.Invalidate
    vf.SetFillObject(aView)
    aLayout.Print

    end

  3. Compile and run the script.

Article ID:000002698

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic