Feature Class to shapefile Arcpy & Arcgis JS

1717
3
05-10-2017 01:41 AM
NalydLeetlub
New Contributor

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.

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

Given the error message, I am leaning towards permissions not being correct on the workspace.  The code might run fine in ArcMap, but the user and permissions while running in ArcMap are completely different than the user and permissions while running it as a geoprocessing job on the server.

To check permissions, build a simple script that reads and writes a text file to the same locations.  If the simple script fails, then you know it is a permissions issue and not an issue with any of geoprocessing tools you are trying to run.

VinceAngelo
Esri Esteemed Contributor

Cross-posted to GIS StackExchange as Converting dwg to shapefile using arcpy and ArcGIS js

ChrisCatania
Esri Community Team

Hi Nalyd - Thanks for asking your questions! Since your question is related to arcpy and JS and similar to another past questions, I wanted to let you know that we're moving your question from the GeoNet Help group to the https://community.esri.com/community/developers/web-developers/arcgis-api-for-javascript?sr=search&s... space so our Esri and user subject matter experts can further help answer this and future questions.  So you're aware on how and where to post future questions, here's a few quick tips and reminders:

  1. First, use the GeoNet search (top right corner by your profile icon) to search and see if your question has already by asked/answered previously.
  2. If not, than we suggest reviewing the GeoNet Community Structure, to find the most relevant space to post your question. 
  3. The GeoNet GeoNet Help group is for questions and tips on how to use the GeoNet community platform not the Esri ArcGIS platform. Following steps 1 & 2 above will give you the best results for getting Esri product questions answered.
  4. This GeoNet 101 "How to Ask Questions on GeoNet" post is also a helpful guide to asking questions: https://community.esri.com/community/help-and-feedback/blog/2016/08/15/community-news-and-tips-how-t...

 

Thanks again for contributing and I hope this helps and let us know if you have any questions.

Esri Community Strategist
0 Kudos