AnsweredAssumed Answered

.pyc tool cannot find earlier output

Question asked by sethbassett on Apr 11, 2016
Latest reply on Apr 13, 2016 by sethbassett

Creating a python toolbox using the ESRI .pyt format. This tool is very straight forward (at least in theory) in that one polygon input generates three outputs: a convex hull layer for the input polys, a centroid layer for the input polys, and an intersection of the convex hull and centroids.

 

    def execute(self, parameters, messages):
        """Execute linear orientation analysis."""
        input = parameters[0].valueAsText
        baseName = arcpy.Describe(input).baseName
                
        arcpy.env.workspace = arcpy.Describe(input).catalogPath
        
        #overwrite doesn't work, tool still fails if output already exists
        arcpy.env.overwriteOutput = True
        
        #output names
        mbg = "{0}_MBG".format(baseName)
        cents = "{0}_centroids".format(baseName)
        intersectOutput = "{0}_MBG_Intersect".format(baseName)
                        
        #output
        arcpy.MinimumBoundingGeometry_management(input,
                                                 mbg,
                                                 "CONVEX_HULL",
                                                 "NONE", "#",
                                                 "MBG_FIELDS")
        arcpy.FeatureToPoint_management(input, 
                                        cents,
                                        "INSIDE")
        
        arcpy.Intersect_analysis(in_features = [mbg, cents],
                                 out_feature_class = intersectOutput,
                                 join_attributes = "ALL", 
                                 cluster_tolerance = "-1 Unknown", 
                                 output_type="INPUT")
        return

 

Stack trace on the error seems to indicate that arcpy.Intersect_Analysis cannot find the feature classes generated by MinimumBoundingGeometry and FeatureToPoint that the script just created:

 

Traceback (most recent call last):

  File "<string>", line 111, in execute

  File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 289, in Intersect

    raise e

ExecuteError: Failed to execute. Parameters are not valid.

ERROR 000732: Input Features: Dataset C:\GISData\scratch\acir_runs\Hernando_Fuzzy2.gdb\Mines\Mines_MBG #;C:\GISData\scratch\acir_runs\Hernando_Fuzzy2.gdb\Mines\Mines_centroids # does not exist or is not supported

Failed to execute (Intersect).

 

Commenting out lines 26-30 produces viable output from the MBG and F2P tools.

 

Anybody run into this one before? Am I missing something obvious - perhaps scoping issues - inherent to .pyc toolboxes/classes, or this is another instance of arcpy $#!^ing the bed?

Outcomes