You simply replace the top part of the script that define the configuration with the two lines of code in the the post you refer to.
# -------------------------------------------------------------
# Configuration from Trajectory
# -------------------------------------------------------------
trajectory = nlread('filename.nc', Trjaectory)[-1]
configuration = trajectory.lastImage()
# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
.....
# -------------------------------------------------------------
# Optimize Geometry
# -------------------------------------------------------------
.....
Full example attached.
There is an error in the code given above: It should be
trajectory = nlread('filename.nc', Trajectory)[-1]
instead of
trajectory = nlread('filename.nc', Trjaectory)[-1]