How To: Automatically print different view frame extents from a single layout


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.


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.

    '-- Define the layout, view and theme objects

    aLayout = av.FindDoc("Layout1")
    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


    '-- 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)


  3. Compile and run the script.