script generated with trace doesn't work with pvbatch

xz_animation_vortmag_vtk_series_batch.py (6.7 KB)
Attached is a file generated using paraview trace utility. The scripts runs without any error when runscript is used in gui. However, the script fails when pvbatch command is used. It give the following error.

Traceback (most recent call last):
File “/mnt/sdb/Research/GATS/MURI/cases/GW20/paraview_macros/xz_animation_vortmag_vtk_series_batch.py”, line 139, in
layout1.SetSize(914, 695)
AttributeError: ‘NoneType’ object has no attribute ‘SetSize’

Can anyone help me with this?