3

I'm trying to loop through a directory of shp files with an XTool Pro tool via arcpy. My script successfully performs the operation on the first shp file, but then fails on the rest with a 000584 error "Implementation of this Tool's Validate is invalid" Here is my script:

import arcpy, os
from arcpy import env
arcpy.env.workspace = r"C:\Data_State\MT\temp"
arcpy.AddToolbox("C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx")
for fc in arcpy.ListFeatureClasses():
   arcpy.XToolsGP_AddXYZ_xtp(fc,"X longitude;Y latitude","CENTER","GEOGCS['GCS_WGS_1984',DATUM['D_WGS84',SPHEROID['WGS84',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]","NONE")

Does anyone know why the tool is unable to loop through the files?


Updated script and I'm still having the same issue

import arcpy, os
from arcpy import env
arcpy.env.workspace = r"C:\Data_State\MT\temp"
arcpy.AddToolbox("C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx")
for fc in arcpy.ListFeatureClasses():
    if fc.endswith(".shp"):
        try:
            print(fc)
            arcpy.RepairGeometry_management(fc)
            print(fc + " Parcels Repaired")

        except:
            print(fc + " repair failed.")
for fc in arcpy.ListFeatureClasses():
    if fc.endswith(".shp")
        try:
            arcpy.XToolsGP_AddXYZ_xtp(fc,"X longitude;Y latitude","CENTER","GEOGCS['GCS_WGS_1984',DATUM['D_WGS84',SPHEROID['WGS84',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]","NONE")
        except:
            print(fc + " failed.")
  • It doesn't look like you have put any sort of filter in for type of feature classes. As it cycles through the feature classes, it may be running across a feature type that this tool cannot handle, thus causing a validation error. – Get Spatial Jun 9 '16 at 15:21
  • All of the shp files in the directory are polygons, so I don't think that's it. I added an if fc.endswith(".shp"): to the script and I'm still having the same issue. I'll edit my code to reflect this – morgan Jun 9 '16 at 16:07
  • Are all of the polygons valid? Have you checked for bad geometries in the layers? You say the operation fails on the rest with that error. Is it possible it is simply failing on the next one alphabetically and not on all the rest? You might try to specifically list another feature class and see if the function works. This might point to an issue with just the 2nd feature class in the list. – Get Spatial Jun 9 '16 at 16:10
  • I added arcpy.RepairGeometry_management(fc) and still getting the same results – morgan Jun 9 '16 at 16:14
  • Are you trying to run this with 32bit or 64bit arcpy? Xtools won't run in 64bit. – Midavalo Jun 9 '16 at 18:20
1

I get the same error when trying to loop through feature classes to Add X,Y,Z to features. The ArcGIS Error 000584 message suggests it's a third party tool error, so XTools Pro will need to fix it.

However, it appears that XTools Pro also has a "batch" tool for the Add X,Y,Z Coordinates tool, called arcpy.XToolsGpAddCoordsBatch_xtp which will allow you to add to a batch of feature classes (as you're doing) - Maybe this is their workaround to the above error.

import arcpy, os
from arcpy import env

arcpy.env.workspace = r"C:\Data_State\MT\temp"
arcpy.AddToolbox("C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx")

fcList = ";".join(arcpy.ListFeatureClasses("*.shp"))

arcpy.XToolsGpAddCoordsBatch_xtp(fcList, "CENTER", "CENTER", "CENTER", "Longitude", "Latitude", "", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS84',SPHEROID['WGS84',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]", "NONE")

The line fcList = ";".join(arcpy.ListFeatureClasses("*.shp")) is because the tool accepts a semicolon (;) separated string of feature classes, not a list.

  • Ah, perfect! I was trying to batch tool also but wasn't adding the semicolon to my list so it was failing. Your method works perfectly, thank you for the help! – morgan Jun 10 '16 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.