You calculate the total energy of the configuration, but with different distances between the ribbon and molecule. The most optimal distance is the one that minimizes the total energy.
This can be done in a Pythons script with a loop over distances, for example:
distances = numpy.linspace(1.0, 3.0, 11) * Angstrom
for distance in distances:
cartesian_coordinates[molecule_indices, 1] += distance
configuration = BulkConfiguration(..., cartesian_coordinates=cartesian_coordinates)
total_energy_analysis = TotalEnergy(configuration)
nlsave(total_energy_analysis, ...)
Of course you have to write the actual script yourself so that it actually works. You can also do it by setting up multiple configurations in the Builder in the GUI and manually adjust the distance using the coordinate tools and submit each job separately if you're not experienced with Python programming.