I've created a number of profiles as shp using SAGA and i want to create a model to export x,y,z and distances between points to a .txt format. The problem is that the model i've created goes through my folder where i keep my shapefiles (profile_tot) and where the file are (starting from agigea_asc[Profile0].shp agigea_asc[Profile0]_1.shp, and so on until agigea_asc[Profile0]_78.shp, yet the files that get exported do not contain all the values in the attribute table of the shapefiles. For example the results of 3 consecutive profiles each of them containing more than 3 thousand points is an amount similar (not exact - within 50 points missing -) for profile 1 and 3 and around 300-400 for profile 2. This issue has no pattern and it happens random, withing the exported files.
Is it possible to export your model to a Python script and to attach it to this thread. That allows us to examine what is going wrong (or at least to see if the process is not correct). If it is all correct, then the next step would be to look at the data.
The alternative would be to script it with python. This would not be a long script. It is quite easy to loop through files and for instance use a cursor to export the information (in case the tool has issues).
Below is the script and the files i am using have generated names starting from agigea_asc [Profile 0]; agigea_asc [Profile 0]_1 up to agigea_asc [Profile 0]_78. I get same problem when exporting to dwg.
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# model_script.py
# Created on: 2015-06-29 09:39:05.00000
# (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
profile_tot = "E:\\AGIGEA\\New folder\\profile\\profile_tot"
agigea_asc__Profile_0__shp = "E:\\AGIGEA\\New folder\\profile\\profile_tot\\agigea_asc [Profile 0]_9.shp"
profi_n_ = "C:\\Users\\Andrei\\Desktop\\asd\\profi%n%"
profil_n__DWG = "C:\\Users\\Andrei\\Desktop\\dwg\\profil%n%.DWG"
# Process: Iterate Feature Classes
arcpy.IterateFeatureClasses_mb(profile_tot, "", "", "NOT_RECURSIVE")
# Process: Export Feature Attribute to ASCII
arcpy.ExportXYv_stats(agigea_asc__Profile_0__shp, "DIST;Z", "SPACE", profi_n_, "ADD_FIELD_NAMES")
# Process: Export to CAD
arcpy.ExportCAD_conversion("'E:\\AGIGEA\\New folder\\profile\\profile_tot\\agigea_asc [Profile 0]_9.shp'", "DWG_R2007", profil_n__DWG, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "")
Looking at the code generated by ModelBuilder I see some strange things, but this does not have to be the reason for the errors that you encounter in the output. I mean the output generated are based on the different input shapes, right?
Maybe you could try this code snippet:
# -*- coding: utf-8 -*- import arcpy import os def main(): # folder and file settings profile_folder = r"E:\AGIGEA\New folder\profile\profile_tot" out_folder_txt = r"C:\Users\Andrei\Desktop\asd" out_prefix_txt = "profi" out_folder_dwg = r"C:\Users\Andrei\Desktop\dwg" out_prefix_dwg = "profil" # export settings sep = " " flds = ("SHAPE@X", "SHAPE@Y", "DIST", "Z") # environment arcpy.env.workspace = profile_folder # list featureclasses and loop through list fcs = arcpy.ListFeatureClasses("agigea_asc*") for fc in fcs: # define output file name postfix = getPostFix(fc) out_txt = os.path.join(out_folder_txt, "{0}{1}.txt".format(out_prefix_txt, postfix)) # open output file with open(out_txt, 'w') as f: f.write("X Y DIST Z\n") # create search cursor on input shape with arcpy.da.SearchCursor(fc, flds) as curs: for row in curs: # write to file f.write("{0} {1} {2} {3}\n".format(row[0], row[1], row[2], row[3])) # Export fc to DWG out_dwg = os.path.join(out_folder_dwg, "{0}{1}.txt".format(out_prefix_dwg, postfix)) arcpy.ExportCAD_conversion(os.path.join(profile_folder, fc), "DWG_R2007", out_dwg, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") def getPostFix(fc): # agigea_asc[Profile0].shp -> '' # agigea_asc[Profile0]_1.shp -> '_1' # agigea_asc[Profile0]_78.shp -> '_78' return fc.split(']')[1].split('.')[0] if __name__ == '__main__': main()
... and check it the output is different (and the missing points are included). Please do create a copy of the output you have created with the ModelBuilder, since it might generate the same output file names (not sure how they are generated in ModelBuilder).