How to call GP Service Task "CAD To Geodatabase" from Javascript

413
10
12-12-2021 02:02 AM
Labels (1)
MichaelLev
Occasional Contributor III

I'm developing custom widgets, using ArcGIS Web AppBuilder V2.20

In our company, we used ArcGIS Pro to create a "CAD To Geodatabase" Service Task in our portal.

I need to address this service task from a web app javascript.

I wish to know how exactly do I call it - How to prepare the parameters? how to call it? and how to get the output results?

Do I also need to use the "Create File Geodatabase" service Task?

Help will be appreciated.

Michael

0 Kudos
10 Replies
Kishore
Occasional Contributor

@MichaelLev , As per my understanding from the details, you need to prepared a widget in WAB to invoke a GP service and display the result. If you have the GP service already existing or you can use the "CAD To Geodatabase" result and create a GP service. Then, Configure the WAB application "Geoprocessing widget". This will create the user interface dynamically based on your service. Please read the help document for more details:

widget-geoprocessing 

 

Regards,
Kishore
0 Kudos
MichaelLev
Occasional Contributor III

@Kishore , Thank you very much for your answer. I'll learn it. Only I work on 3D Scenes, so I use the 4.* WAB, (folder stemapp3d instead of folder stemapp) and esri have not yet supplied a 3D version of that widget. Indeed "Cad to Geodatabase" operates on 2D, but I need to use the Geoprocessing on 3D environment (API 4.*). So I'll have to rewrite what I need. I assume their 2D widget is "general" while I need some specific task. If you can help me more specifically due to my specific needs, I'll appreciate it. Anyway, I'll see what I can learn from the widget you pointed to.

Thanks,

Michael

0 Kudos
MichaelLev
Occasional Contributor III

@Kishore , in addition to me reply,

I saw some ESRi 3D example in https://developers.arcgis.com/javascript/latest/sample-code/geoprocessing-viewshed/ 

and what I need is to adapt it to the "CAD to Geodatabase" Service.

Michael

0 Kudos
Kishore
Occasional Contributor

@MichaelLev , The WAB 3D template widgets are limited. however, you can build your own using 4.x API. If you look at the Hotspot analysis example geoprocessing-hotspot the interface will also let you know the current progress and results. In your case prepare a toolbox in ArcGIS Pro:

the Tools will execute "CAD to Geodatabase" tool however the parameters for this tool must be defines as:

  1. Input CAD Datasets - Input type File
  2. Output Geodatabase -  This is not a parameter. manage with temp db or scratch db / if required you can use your Enterprise geodatabse (must be registered with your ArcGIS server) 
  3. Dataset - String input parameter
  4. Reference scale - Double input parameter
  5. Output Feature Dataset - type Derived as output feature set

 Execute the tool and publish the result as GP service to the ArcGIS server.  The output from the service will be available for you as JSON. You have all required elements here, start building the 4.x widget as it is showcased in the hotspot analysis example.  

You can also plan to update the existing feature class in geodatabase. make sure the feature class published as service and using in your webmap. This will allow user to view the data with a simple map refresh.

Regards,
Kishore
0 Kudos
MichaelLev
Occasional Contributor III

@Kishore ,

Our  "CAD to Geodatabase" service does not request an input file...

Using my Web AppBuilder Developer Edition, I also created 2D WAB application and inserted the original ESRI "Geoprocessing" widget, configuring the URL to our  "CAD to Geodatabase" service. Then I ran the WAB app and opened the "Geoprocessing" widget, and to my astonishment, also here it has not have had any means to input CAD file.

Maybe they had here a mistake when they created the "CAD to Geodatabase" service?

In short, the "CAD to Geodatabase" service does not present any means how to input CAD file...

Do you know how to help?

With appreciation,

Michael

0 Kudos
MichaelLev
Occasional Contributor III

@Kishore ,

In addition to what I just wrote, it seems you know how to create the service, so maybe you can describe, step by step, how to publish the correct  "Cad to Geodatabase" service. By "correct" I mean that it should have an API to enter input file. Should we create it using "ArcGIS Pro" desktop? I am WAB Custom Widgets programmer, so I am less familiar with ArcGIS Pro and ArcGIS Server (portal). I assume there has been a mistake here in creating the   "Cad to Geodatabase" service task.

WIth appreciation,

Michael

0 Kudos
Kishore
Occasional Contributor

Hi @MichaelLev , 

First you need to create a script tool in ArcGIS Desktop using ArcMap / Pro. As mentioned in the previous post add following parameters to the tool: publishing-geoprocessing-services-in-a-python-script 

inputs-and-outputs-for-geoprocessing-services 

  1. Input CAD Datasets - Input type File
  2. Output Geodatabase -  This is not a parameter. manage with temp db or scratch db / if required you can use your Enterprise geodatabse (must be registered with your ArcGIS server) 
  3. Dataset - String input parameter
  4. Reference scale - Double input parameter
  5. Output Feature Dataset - type Derived as output feature set

Next Run the tool on desktop validate all your results. Once you are ok with results

Go to Geoprocessing History tab in Pro / GP result window in ArcMap right click the result and share as service.geoprocessing-services-settings 

This will allow you to get the rest URL with required parameters.

Thank you.

Regards,
Kishore
0 Kudos
MichaelLev
Occasional Contributor III

@Kishore ,

I understand that I can't "bypass" the need to use python and arcpy.

However, I am just starting to learn how to do it.

Can you please show me a very simple solution how to do it in arcpy+python for a very simple tool: "Buffer"?

I mean how to create a service in 2D that will enable to insert the URL to the ESRI Web AppBuilder 2D widget "geoprocessing" so that I will be able to operate it to create a buffer around some polygons layer in my WAB web app? I need that when I am in my web app, the "input" will enable me to select the proper polygons layer in my web app.

I'll explain a little more: When I right click on the "Buffer" tool to get its python code, I see:

arcpy.analysis.Buffer("poly01", r"C:\_ArcGisPro\proj\geoProcessing\01\01.gdb\poly01_Buffer", "2 Kilometers", "FULL", "ROUND", "ALL", None, "PLANAR")

Now, I need thet the service will have a "dynamic" input - i.e. that the the input will NOT be "hardcoded" to the layers that were in the ArcGIS Pro at the time I ran to Buffer tool.

When I created service from the Buffer tool, then when I activated the service in the 2D "geoprocessing" widget, it worked on the layers that were in the ArcGIS Pro... but I want it to work on new layers that will be in the web app.

 

With appreciation,

Michael    

0 Kudos
Kishore
Occasional Contributor

@MichaelLev 

Please watch the ESRI training videos below:

building-geoprocessing-tools-with-python-getting-started 

Publishing GP Service 

Regards,
Kishore
0 Kudos