# Import system modules import arcpy from arcpy import env import exceptions, sys, traceback try: # Obtain a license for the ArcGIS 3D Analyst extension arcpy.CheckOutExtension("3D") # Get input parameter inLyr = arcpy.GetParameterAsText (0) outFolder = arcpy.GetParameterAsText (1) # Set environment settings env.workspace = inLyr # Use the ListFiles method to identify all layer files in workspace if arcpy.ListFiles("*.lyr"): for lyrFile in arcpy.ListFiles("*.lyr"): # Set Local Variables #outFC = "Test.gdb/{0}".format(lyrFile[:-4]) #Strips '.lyr' from name outFC = outFolder + "/" + lyrFile[:-4]+ "_3D" #Execute Layer3DToFeatureClass arcpy.Layer3DToFeatureClass_3d(lyrFile, outFC) else: "There are no layer files in {0}.".format(env.workspace) 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)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.