How to get a Perl Script file to Extract 1D EDD Data Along Z-Axis from 3D EDD Surface in BIOVIA Materials Studio?

Hello dear experts,

I am analyzing the calculated 3D electron density difference (EDD) data in BIOVIA Materials Studio and need to extract a 1D plot of EDD along the z-axis (0 to 20 Å). My field name in the XSD file is "DMol3 total electron density," and I'm looking to average the EDD values over the xy-plane for each z-value.

I've tried scripting this in Perl but encountered some issues, and I'm seeking help with a refined script or an example that correctly handles these calculations. Specifically, I need the script to:

  1. Import the XSD file and access the "DMol3 total electron density" field.
  2. Loop over the z-axis from 0 to 20 Å, averaging the EDD values at each step across the xy-plane.
  3. Output the results as a 1D plot data file (z-value vs. averaged EDD).

Any assistance with a Perl script that accomplishes this would be greatly appreciated!

Thank you in advance for your help.