POST
|
Hello, I am trying to write a Python script to publish a hosted feature service from selected layers in a map, which is called from my .NET ArcGIS Pro add-in. If I do not specify any layers from the map to publish (publish all layers), then the service gets published successfully. However, if I do try to specify certain layers to get published, then I receive this error: Traceback (most recent call last): File "<string>", line 79, in execute File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\sharing.py", line 23, in exportToSDDraft return _convertArcObjectToPythonObject(self._arc_object.exportToSDDraft(out_sddraft, self)) ValueError: Project does not exist or is inaccessible. Failed to execute (PublishHostedFeatureService). Here is my code, which is failing on the last line: current_project = arcpy.mp.ArcGISProject("CURRENT")
current_map = current_project.activeMap
layer_list = []
# layer_names is the parameter passed to the tool
for layer_name in layer_names:
layers = current_map.listLayers(layer_name)
if len(layers) > 0:
layer_list.append(layers[0])
sharing_draft = current_map.getWebLayerSharingDraft("HOSTING_SERVER", "FEATURE", service_name, layer_list)
sharing_draft.exportToSDDraft(sddraft_output_filename) Am I doing something wrong with how I am passing the layer information to getWebLayerSharingDraft()?
... View more
11-05-2019
09:44 AM
|
2
|
0
|
677
|
POST
|
I need a color picker control for a dockpane in my ArcGIS Pro add-in, but I can't seem to find one in the SDK. Is there one somewhere that I am missing? If not, I can look into using a third-party control, but I wanted to confirm whether or not one is available in the SDK first. Thank you, Greg
... View more
10-07-2019
07:04 AM
|
0
|
1
|
960
|
POST
|
Uma, Thank you for looking into this! That is good news indeed, I will look forward to the Pro 2.4 release then .
... View more
05-29-2019
02:07 PM
|
0
|
0
|
1609
|
POST
|
Hi Uma, Thank you for your response. My apologies, I realize that I am very late on getting back to looking into this... So I tried something similar to what you suggested, with the following code: return QueuedTask.Run(() =>
{
var sf = SpatialReferenceBuilder.CreateSpatialReference(3419);
var point = MapPointBuilder.CreateMapPoint(2260034.44, 235444.97, sf);
var op = new EditOperation();
op.Create(layer, point);
if (!op.Execute())
{
errors = op.ErrorMessage;
}
}); And the EditOperation returns this error message: "Edit operation failed.". Additionally, I notice that if I try to create any features in my in-memory layer through the ArcGIS Pro editing UI, I get this error message: Here is a code snippet of how I am creating the layer in-memory: return QueuedTask.Run(() =>
{
errorMessages = string.Empty;
var parameters = Geoprocessing.MakeValueArray("memory", layerName, "POINT", "", "", "", 3419);
var result = Geoprocessing.ExecuteToolAsync("management.CreateFeatureClass", parameters, null, null, null, GPExecuteToolFlags.AddOutputsToMap);
if (result.Result.ErrorMessages.Count() > 0)
{
foreach (var item in result.Result.ErrorMessages)
{
errorMessages += $"{item.Text}{Environment.NewLine}";
}
errorMessages = errorMessages.TrimEnd();
}
}); Is it possible that I'm doing something wrong with how I am creating this layer? Thanks, Greg
... View more
05-22-2019
11:17 AM
|
0
|
2
|
1609
|
POST
|
Hello, I am writing functionality for my ArcGIS Pro add-in that generates a custom layer on the fly. I am trying to use the memory workspace (https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm) to avoid creating a geodatabase on the disk, as the results of my tool are meant to be temporary and I would like them to disappear upon application close. So far, I've been able to successfully create the feature class and its fields through the Geoprocessing API. However, I'm getting stuck when trying to populate the layer with data. My code appears to work, and upon completion, the attribute table is populated with rows. However, there is no geometry for any of the rows (no features exist in the map at all). Here is how I am populating my layer: string errorMessages = string.Empty;
using (FeatureClass layerAsFeatureClass = layer.GetTable() as FeatureClass)
{
EditOperation op = new EditOperation();
op.Callback(context =>
{
foreach (var feature in features)
{
using (RowBuffer rowBuffer = layerAsFeatureClass.CreateRowBuffer())
{
//Setting a bunch of attributes here...
//
//
if (feature.Geometry == null)
{
continue;
}
//Now set the geometry
rowBuffer[layerAsFeatureClass.GetDefinition().GetShapeField()] = feature.Geometry.ToEsriShape();
using (Row row = layerAsFeatureClass.CreateRow(rowBuffer))
{
context.Invalidate(row);
}
}
}
}, layerAsFeatureClass);
try
{
if (!op.Execute())
{
errorMessages = op.ErrorMessage;
}
}
catch (GeodatabaseException gEx)
{
errorMessages = gEx.Message;
}
catch (Exception ex)
{
errorMessages = ex.Message;
}
} "feature.Geometry" is a MapPoint. I found that setting the geometry without calling ".ToEsriShape()" resulted in errors. Is there another way that I should be setting the geometry for an in-memory feature class? I feel like I am missing something here. Any help would be appreciated.
... View more
03-26-2019
08:37 AM
|
0
|
4
|
2071
|
POST
|
Hello, I am currently writing functionality with the ArcGIS Pro SDK part of which will be used to split polygon features. To do the split, I am using an EditOperation and calling the method Split(Layer, ObjectID, Geometry). When attempting this on a polygon layer, I am seeing an exception thrown that says "Only polyline layers can be split". This is interesting, because polygon splits are possible through the ArcGIS Pro editing interface. Does the ArcGIS Pro SDK not support splitting polygon features? Or if it does, is there another way I would be able to do the split with the SDK? Thanks in advance, Greg
... View more
11-27-2018
12:34 PM
|
0
|
4
|
1650
|
POST
|
Hi, I am writing an ArcGIS Pro tool that performs a mass update of GIS values for one layer at a time. I followed the Geodatabase API snippet for modifying rows (ProSnippets Geodatabase · Esri/arcgis-pro-sdk Wiki · GitHub ) and it works fine/does exactly what I need it to do. However, the problem I am facing is the update could take a very long time to execute if I am updating thousands of rows at a time. I understand that when a task is running on the MCT, all the UI commands are disabled by default. Ideally, I'd like to keep the UI responsive and usable while the update runs in the background. Is there any way in the SDK to disable only the specific layer that is being processed, rather than everything in the UI (table of contents, ribbon, etc)? I see that using the Field Calculator in ArcGIS Pro works this way, so I am wondering if there's a way to implement similar behavior for my tool. Thanks in advance! Greg
... View more
03-28-2018
10:54 AM
|
0
|
2
|
836
|
POST
|
Micah, Thanks for your reply! I did consider just looping through all the feature layers like you mention, but I'd like to avoid that to save extra processing time, especially since I will already know the layer and OBJECTID beforehand (I was trying to use just the GLOBALID instead because it stores better in my database that is talking to my GIS server). Also, that is an excellent point about published services potentially coming from many different data sources (and the GLOBALID only being unique per data source); I had not considered that when I wrote this post. It seems that the best way to proceed with this for now is to just continue storing the layer and OBJECTID to return features, instead of the GLOBALID. Thanks again, Greg
... View more
09-06-2017
02:26 PM
|
0
|
0
|
1869
|
POST
|
Is there any way to return a feature from a published service layer using solely the GlobalID? I understand that the GlobalID is universally unique across a workspace, and what I'd like to do is return a feature from an ArcGIS Portal without providing a service or layer in my query to the ArcGIS REST API. From what I can tell, there is no way to query for a feature at the server level in the ArcGIS REST API (it looks like a layer in a service must be provided), but maybe I am missing something. Any insight would be appreciated!
... View more
08-31-2017
10:55 AM
|
0
|
2
|
2925
|
POST
|
I have ran into a strange issue with the Silverlight API editing widget. When attempting to edit a feature from a layer with a simple renderer, for the fields with domains applied, only the domain code displays in the field, and no dropdown list is available: However, if I change the symbology to a unique value renderer, replace the feature template for the layer to reflect this, and republish the service, then the domains appear correctly within the widget as a dropdown list: Has anybody else encountered this? If so, what was the solution (if any)? I feel like I'm missing something here. Thanks in advance!
... View more
05-05-2017
09:17 AM
|
0
|
0
|
1025
|
POST
|
Okay, so I have finally gotten to the bottom of this. Turns out that when parsing the xml document of the sddraft to enable feature access web capabilities, as enumerated in the Esri help guide for ArcPy (CreateMapSDDraft—Help | ArcGIS for Desktop ), grabbing the dom element by tag name 'Info' at index [0] returns the Mapping capabilities for the service (which are set to Data, Map, Query by default), and not the actual Feature Access capabilities for editing and syncing. The correct index (inside the portion of the following screenshot highlighted in red) should actually be [7]. That is, if you are doing your parsing with xml.minidom like the guide shows. I actually changed my code to use xml.etree instead of xml.minidom to parse the sddraft, so for me the index was [6], but I coded it to exclude the first instance of the tag 'Info' since it was not a child of the tags in the query. Not sure how many people will run into this again, but Esri may want to update their help guide . Kind regards, Greg Smith
... View more
08-18-2016
03:22 PM
|
4
|
0
|
985
|
POST
|
Jeff- Thank you for your response! I probably should have clarified- the services my tool handles are not being published to AGOL. Rather, the tool publishes to my organization's ArcGIS Server. Unfortunately, I cannot disable edits across the board because some of our services being published do need to have editing capabilities. My tool iterates through multiple map documents in a batch, so that is why I am trying to have the option to enable sync on specified ones, to avoid any additional configuration after the fact.
... View more
08-11-2016
09:59 AM
|
0
|
0
|
985
|
POST
|
I have written a Python script tool that publishes map services for my organization. It works great, except that I am trying to publish read-only feature services with the "Sync" capability for offline mobile use. After following examples from Esri/other forums, I set the capabilities in my script by parsing the service definition draft as an xml document, as shown here: # turn on feature access if service is editable if service.endswith("Editable") or service.endswith("Redlining") or allowSync: featAccessSettings = doc.getElementsByTagName("TypeName") for featAccessSetting in featAccessSettings: if featAccessSetting.firstChild.data == "FeatureServer": featAccessSetting.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "true" configProps = doc.getElementsByTagName("Info")[0] propArray = configProps.firstChild propSets = propArray.childNodes for propSet in propSets: keyValues = propSet.childNodes for keyValue in keyValues: if keyValue.tagName == "Key": if keyValue.firstChild.data == "WebCapabilities": if (service.endswith("Editable")) or (service.endswith("Redlining")): keyValue.nextSibling.firstChild.data == "Query,Create,Update,Delete,Uploads,Editing" else: keyValue.nextSibling.firstChild.data == "Query,Sync" On the last line, to create a read-only feature service (according to this guide: Prepare data for offline use—Documentation | ArcGIS for Server ), I set the web capabilities to only Query and Sync, but when the tool completes running, the publish service still has full editing capabilities and Sync disabled. If I try to publish the service with the user interface inside ArcMap or ArcCatalog, the web capability settings come across correctly. Is there another parameter that needs to be set programmatically, that I am missing here? I know the data has to be configured correctly to use Sync, but again, the data I've been testing with works fine when published though the UI. Thanks! Greg
... View more
08-09-2016
02:27 PM
|
0
|
3
|
2468
|
Title | Kudos | Posted |
---|---|---|
2 | 11-05-2019 09:44 AM | |
4 | 08-18-2016 03:22 PM |
Online Status |
Offline
|
Date Last Visited |
04-08-2021
07:07 PM
|