This script example demonstrates how to save point x and y coordinates along with another point attribute to a text file. The text file has xyz format, where each row includes x, y, and z data of a point. The z value could be any attribute value of a point. This example may be used as a reference on how to export model data to external text files.
This script is provided as-is, please see the disclaimer below for more information.
Download script
# export point data to text file of xyz format def export_xyz_file(junctions, z_field, out_xyz_file): with open(out_xyz_file, 'wt') as f: for junc in junctions: x, y = junc['X'], junc['Y'] # obtain the X and Y fields z = junc[z_field] # obtain the Z field row = '{0},{1},{2}'.format(x, y, z) f.write('{0}\n'.format(row)) file = r'D:\Test\test.xyz' # new text file to be saved. If already exists, the file will be overwritten junctions = pcpy.Map.Layer['Junctions'].get_entities() # get all junction entities export_xyz_file(junctions, 'InvertElev', file) # export points to the file print 'done'
Disclaimer
All scripts are provided as-is, and no warranty is made as to the script's accuracy, completeness, or suitability for any particular purpose. This script may contain errors and require correction or modification by the modeler before its use.
The modeler is obligated to review the script code in its entirety and determine its suitability for its intended usage.
This script may also be updated from time to time to fix issues or provide enhanced functionality. If you have suggestions for improvement, please create a support ticket to let us know.