The DocFeatureLayer.ShareAsync method creates a hosted feature layer from one or more valid specified document feature layers. The specified document feature layer definitions and features are removed from the drawing, and the resulting features in the current project area are added to the drawing on the appropriate AutoCAD layers of the new web feature layers.
The following are the usage requirements and behaviors:
- The user must be signed in to the specified organization and have a sufficient user role to create or publish data.
- A single hosted feature layer item containing one or more feature layers is created from the specified document feature layers.
- If successful, each document feature layer is replaced by a web feature layer from the new hosted feature layer.
- As with all web feature layers, only feature entities included in the current project area are redrawn in the drawing session.
- The resulting feature geometry is limited to the capabilities of the hosted feature layer, which may alter geometry such as tessellating curves.
- If you are not signed in to an organization, you are prompted to enter your username and password.
Declaration
public async Task<(bool Success, IEnumerable<string> Responses)> Esri.ArcGISForAutoCAD.DocFeatureLayer.ShareAsync(Document doc, string serviceName, IEnumerable<string> flNames, string url, string sharingSettings, Dictionary<string, object> hostSettings = null)
Parameters
| Type | Name | Description | Required |
|---|---|---|---|
Document | doc | The AutoCAD document to act on. | Required |
string | serviceName | The new hosted feature layer name. The name will be truncated to 90 characters. | Required |
IEnumerable<string> | flNames | A collection of the document feature layer names to be shared. | Required |
string | url | The URL of the ArcGIS Online or ArcGIS Enterprise organization where the hosted feature layer item will be created. | Required |
string | sharingSettings | The sharing level of the hosted feature layer. The options are "Public", "Private", and "Organization". | Required |
Dictionary<string, object> | hostSettings | A dictionary of optional settings to limit fields and return appropriate default values. The keys and values are described in the table below. | Optional |
| Key | Type | Value Description | Required |
|---|---|---|---|
"Tags" | List<string> | Descriptive tags for the new feature layer as a list of strings. Unless tags are set by the user, the "ArcGIS for AutoCAD" tag will be assigned by default. | Optional |
"Description" | string | The description of the new hosted feature layer being created. | Optional |
"Folder" | string | The name of folder where the new hosted feature layer will be created. | Optional |
"DisableEditorTracking" | bool | Specifies whether editor tracking will be disabled on the new feature layer. The default is false. | Optional |
"GroupsToShareWith" | List<string> | The names of the organization's groups to share with. | Optional |
"AddGPSFields" | bool | Specifies whether GPS metadata fields will be added on the new feature layer. The default is false. | Optional |
"CreateWebFeatureLayerTemplate" | bool | Specifies whether the AutoCAD layer set in the document feature layer query will be maintained as the symbol layer on the newly created web feature layer. This only works if a layer has a layer-only query and the query only has one layer defined. The default is false. | Optional |
"EnableM" | bool | Specifies whether m-values will be enabled on the new feature layer. The default is false. | Optional |
"DefaultZ" | double | The default z-value for new features in editing applications that do not support the editing of z-values. This value does not apply when editing in ArcGIS for AutoCAD, which does support editing of z-values. | Optional |
Returns
| Type | Description |
|---|---|
(bool Success, IEnumerable<string> Responses) | A named tuple in which the first value is the Success value and the second value is the Responses value. The Success value is a Boolean value that specifies whether the document feature layers were shared successfully, and will return true in cases of partial success. When Success is true, the Responses value is a collection containing the published portal item URL as a string. When Success is false, the Responses value is a collection of string error messages, including error messages from the portal. |
Remarks on error conditions
This method may throw an exception or return null if a parameter is invalid.
Example
Print the portal item URL created from sharing the Utility_Points and Service_Lines document feature layers as hosted feature layers within a new hosted feature layer item named New_Construction. // Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var serviceName = "New_Construction";
var flNames = new List<string> { "Utility_Points", "Service_Lines" };
var url = "https://arcgis.com/";
var hostSettings = new Dictionary<string, object>
{
{ "Description", "New construction." },
{ "Tags", new List<string> { "Construction", "CADwork" } },
{ "Folder", "CADwork" },
{ "GroupsToShareWith", new List<string> { "Group1", "Group2" } },
{ "CreateWebFeatureLayerTemplate", true },
};
// Share the document feature layers
var success = await Esri.ArcGISForAutoCAD.DocFeatureLayer.ShareAsync(doc, serviceName, flNames, url, "Private", hostSettings);
// Print the portal item url
if (success.Success == true)
{
foreach (var response in success.Responses)
{
doc.Editor.WriteMessage("\nURL: " + response);
}
}
else
{
foreach (var response in success.Responses)
{
doc.Editor.WriteMessage("\nError: " + response);
}
}
/* Example output
URL: https://arcgis.com//home/item.html?id=12345abcde54321abcde12345abcde54
*/
See also
esri_featurelayer_share—An AutoLISP function that creates a hosted feature layer from one or more valid specified document feature layers.