'''****************************************************************************
Name: ASCII3D_to_Feature_Class Example
Description: Creates a TIN surface using XYZI files in a folder and breaklines
imported from ASCII files.
****************************************************************************'''
# Import system modules`
import arcpy
from arcpy import env
import exceptions, sys, traceback
try:
arcpy.CheckOutExtension("3D")
# Set environment settings
env.workspace = "C:/data"
# Define the spatial reference using the name
sr = arcpy.SpatialReference("Hawaii Albers Equal Area Conic")
#Create the elevation points
arcpy.ddd.ASCII3DToFeatureClass("Elevation Points", "XYZI",
"elevation_points.shp",
"MULTIPOINT", z_factor=3.28,
input_coordinate_system=sr,
average_point_spacing=2.5,
file_suffix="XYZ")
#Create the break lines
arcpy.ddd.ASCII3DToFeatureClass("brklines.gen", "GENERATE",
"breaklines.shp",
"POLYLINE", z_factor=3.28,
input_coordinate_system=sr)
arcpy.ddd.CreateTin("elevation_tin", sr,
[["breaklines.shp", "Shape", "hardline"],
["elevation_points.shp", "Shape", "masspoints"]],
"CONSTRAINED_DELAUNAY")
except arcpy.ExecuteError:
print arcpy.GetMessages()
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate error information into message string
pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
.format(tbinfo, str(sys.exc_info()[1]))
msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
# Return python error messages for script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)