Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting "ResultObject: Error in getting output" message when I run the following code. I know it has something to do with "os.path.join" but can't figure out what.

Thanks. Sam

import arcpy
import os

    arcpy.env.overwriteOutput = True
    CADInput = arcpy.GetParameterAsText(0)
    OutputFolder = arcpy.GetParameterAsText(1)
    OutputGDB = arcpy.CreateFileGDB_management(OutputFolder, "AllPipes.gdb", "CURRENT")
    SpatialReference = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1983\NAD 1983 UTM Zone 17N.prj"
    OutputData = arcpy.CreateFeatureDataset_management(OutputGDB, "Data", SpatialReference)
    OutputCAD = arcpy.CADToGeodatabase_conversion(CADInput,OutputGDB,"CAD_Converted","1000",SpatialReference)
    OutputCADLocation = OutputCAD.getOutput(0)

    layerfld = arcpy.AddFieldDelimiters(os.path.join(OutputCADLocation,"Point"),"Layer")
    query = layerfld + "='WM-VALVE-ID'"
    outfile = os.path.join(OutputData,"Valve")
    ValveFC = arcpy.CopyFeatures_management("Valve_lyr8",outfile)
share|improve this question

The error here is that you are using the result of operations as values, instead of Result Objects. Any built-in tool returns a Result Object, not a string or path like you assume in your code. Assuming the output of arcpy.CADToGeodatabase is the feature dataset created, you would save it by calling getOutput(0).

Based on your above example:

OutputCAD =  arcpy.CADToGeodatabase_conversion(CADInput,OutputGDB,"CAD_Converted","1000",SpatialReference)
OutputCADLocation = OutputCAD.getOutput(0)

I haven't played with CADToGeodatabase to know if it provides multiple results, but you can check if it has multiple outputs by reading the outputCount

print "The output consists of", OutputCAD.outputCount, "results"

Your os.path.join should stop complaining about joining a result object with a string after that.

share|improve this answer
Michalis, The output of arcpy.CADToGeodatabase is a featuredataset consisting of Annotation, Multipatch, Polygon, Point and Polyline feature classes. But the print command outputCAD.outputCount says only one result. I am trying to query out certain records from Point feature class. As you suggested, I used getOutput(0) but it is still giving me the same error. I have edited my code to reflect the change you suggested. – Sam Sep 25 '12 at 20:07
Sam, I would check the output to make sure it is the full name of the Geodatabase. AddFieldDelemeters excepts a Workspace. If your output is simply the FeatureDataset name, then AddFieldDelimeters will not function properly. You could try using os.path.join(OutputFolder, "AllPipes.gdb") to get the geodatabase workspace to pass through to AddFieldDelemeters. – Michalis Avraam Sep 25 '12 at 20:31
Michalis, I am sorry if I confused you. The code results in all the feature classes I mentioned. I am not sure why print statement says only one result; may be its refering one feature dataset. And AddFieldDelimeters and rest of the code work fine if I hardcode the filepath. It is just not liking how I am using os.path.join. – Sam Sep 25 '12 at 20:40
@Sam, try to print out the result to verify that it is what you expect it to be. Just print OutputCad.getOutput(0) and see if that is the FeatureDataset name, the Geodatabase name, or something else. – Michalis Avraam Sep 25 '12 at 21:15
As an alternative to using os.path.join, you could set the current workspace by setting arcpy.env.workspace. You may also consider debugging in an IDE such as PyScripter to better understand what is actually happening in your code. – blah238 Sep 25 '12 at 21:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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