Select to view content in your preferred language

cad in geoprocessing service

3670
10
10-06-2016 05:51 AM
ZachTagar
Emerging Contributor

I want to use the CAD to Geodatabase tool as a service, where a user can upload a dwg file and have it shown on a web map as map service. Trouble is that the dwg file is always a 'constant' parameter as it cannot be passed by the browser. I need the user to pass files they receive as part of their workflow. Any suggestions?  

10 Replies
JonathanQuinn
Esri Notable Contributor

What about writing your own script to have the user upload a zip file of the DWG, (input parameter is of File type), the script unzips the zip file, and then processes it?

ZachTagar
Emerging Contributor

Thanks. This would add a task to the user which I would ideally like to avoid: they would have to zip the DWG before uploading it to the app. It's a workaround, but it would be great to have a quicker way, from the user's point of view. Any ideas?  

0 Kudos
JonathanQuinn
Esri Notable Contributor

Good point, Zach.  Are you familiar with Python?  If so, you can use the Copy_management tool and set the input as a File type.  This will set the initial input to the tool as a GPDataFile type, and after enabling uploads on the GP service, will tell the browser that the user can upload a file to that parameter.  The file can then be copied to the scratch folder and used as input to the CADToGeodatabase tool.  The result requires a resulting map service, as it returns a feature dataset, so you should be good as long as your application can retrieve the resulting map service.  You could also loop through the scratch geodatabase and then the feature dataset to find the feature classes if you want to return them individually.  I've uploaded a sample for you to take a look at.  See if you can grab it from here.

ZachTagar
Emerging Contributor

Thank you Jonathan. This is indeed very helpful. I will try this .

0 Kudos
NagorneacConstantin
Emerging Contributor

Dear Jonathan,

I tried to use your sample to upload CAD file and view it as map service, but when I publish it as Geoprocessing service on portal and try to execute it, it fails with the following arcgis server log:

Invalid return value: c:\arcgisserver\directories\arcgisjobs\stopo\cadtogdb_sample_gpserver\j44e42223599b4b449d24ae23e8abde1f\scratch\scratch.gdb\SDS_ToGDB

Could you please give me some hints why it is not working?

I am using Arcgis Server and Portal 1.5.1

0 Kudos
JonathanQuinn
Esri Notable Contributor

Can you run the tool, then using ArcCatalog or ArcMap, take a look in the scratch.gdb and check to see if the output data is in there? It may be failing to create it, but I would expect the GP task to fail if that's the case.

0 Kudos
NagorneacConstantin
Emerging Contributor

You are right. Script copies the data into scratch folder, but does not export data into scratch.gdb

Anyway, It is a nice start. I will try to replicate this functionality by myself.

0 Kudos
JonathanQuinn
Esri Notable Contributor

How are you defining the output paths for data? You can try to use the os module and the scratch GDB environment variable to construct the path for any output data:

outData = os.path.join(arcpy.env.scratchGDB,"outData")

0 Kudos
NagorneacConstantin
Emerging Contributor

Update: I made a mistake. The script works fine from Arcmap. it writes output to scratch.gdb.

Update 2: I also found out that none of my published models can write into scratchGDB. They are okay if they need to write into scratch folder. I tried "feature class to feature class" and it writes shapefile into scratch folder but refuses to write feature class in scratch GDB.

Update 3: wnen script tries to write into ScratchGDB it gives me the following error:

Error executing tool. Upload_and_Visualize_DWG Job ID: j9605b3b83e15414eaff7f14cd9b81833 : ERROR 000210: Cannot create output c:\arcgisserver\directories\arcgisjobs\stopo\upload_test_2_gpserver\j9605b3b83e15414eaff7f14cd9b81833\scratch\scratch.gdb\A44755_F1_C454_350_Polyline Failed to execute (Feature Class to Feature Class). Failed to execute (Model63). Failed to execute (Upload_and_Visualize_DWG).

So looks like it creates job folder where puts DWG file, then it tries to execute Feature class to feature class and fails to write output into scratch.gdb.

0 Kudos