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.
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.
Cross-posted to GIS StackExchange as Converting dwg to shapefile using arcpy and ArcGIS js
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:
Thanks again for contributing and I hope this helps and let us know if you have any questions.