AnsweredAssumed Answered

Feature Class to shapefile Arcpy & Arcgis JS

Question asked by Nalydleetlub on May 10, 2017
Latest reply on May 11, 2017 by CCatania-esristaff

The following code in arcpy is used to convert a dwg file into shapefile and it works perfectly when you run it within arcmap:

 

    import sys, zipfile, arcpy, os, traceback
    from arcpy import env

    # Set environment settings
    env.workspace = "C:/GISApplication/GIS/Layer_Updated_Drawings"

    # Set local variables
    fileName = arcpy.GetParameterAsText(0)
    featureType = arcpy.GetParameterAsText(1)

    file = os.path.join(fileName, featureType)
    inFeatures = [file]
    outLocation = "C:/GISApplication/GIS/Layer_Updated_Drawings/Converted"

    # Execute FeatureClassToGeodatabase
    arcpy.FeatureClassToShapefile_conversion(inFeatures, outLocation)

 

However when I try to run this script using the following javascript code:

 

    url = ARCGIS_SERVER + 'Toolbox/DwgToZippedShapefile/GPServer/LayerUpdate';
    convParams = {
    FileName: "MIPBoundary.dwg",  //Hardcoded for testing
    FeatureType: "Polyline" //Hardcoded for testing
    };
    convExportToolName = "SHPFileResults";
    convJobFolder = "DwgToZippedShapefile_GPServer";
    var gpConversionProcess = new Geoprocessor(url);

    gpConversionProcess.submitJob(convParams, gpConversionComplete, gpConversionStatus, gpConversionFailed);

 

it keeps failing and I keep getting the following error on arcgis server manager:

 

Error executing tool. LayerUpdate Job ID: j7af4b50ca616491eb13dce08dfe17b7f : Traceback (most recent call last): File "(PATH)\Toolbox\DwgToZippedShapefile.GPServer\extracted\v101\my_toolboxes\UpdateLayer.py", line 25, in arcpy.FeatureClassToShapefile_conversion(inFeatures, outLocation) File "(PATH)arcgis\server\arcpy\arcpy\conversion.py", line 2775, in FeatureClassToShapefile raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Boundary.dwg\Polyline does not exist or is not supported Failed to execute (FeatureClassToShapefile). Failed to execute (LayerUpdate). Failed to execute (LayerUpdate).

 

However I don't know why it isn't working as I am passing all the parameters and when running the tool in arcmap with the exact same parameters it works fine.

Outcomes