|
POST
|
I attached a sample that creates a feature class, adds that feature class as a layer to the map, and then copies some data. To delete the content of a whole table or feature class you can use the DeleteRows method for the Table or FeatureClass.
... View more
08-17-2023
11:20 AM
|
0
|
1
|
1312
|
|
POST
|
Like @GIS_Fox i don't have enough Arcade background either, however, i am not sure what exactly the bug is. That the feature layer name is updated in Arcade after you change the name of the feature layer that seems to me like a desirable 'feature' (no pun intended). If the system would not make the Arcade updates for you, you would have to manually check each attribute rule and update the feature layer name there. Also you are saying that this is 'dangerous' in your question title and i don't see why this is dangerous, can you explain?
... View more
08-17-2023
10:21 AM
|
1
|
1
|
1240
|
|
POST
|
Your business login in the implementation of DrawCompleteEvent is causing the selection in the TOC to change. In order to help you we need to know what your code does. Try to eliminate sections of your code to try to pinpoint the cause of the problem.
... View more
08-17-2023
08:54 AM
|
0
|
1
|
816
|
|
POST
|
You are correct, those classes that you need are only available through ArcGIS Pro API assemblies that are accessible via Add-ins. When you create a Pro SDK console standalone application (referred to as a CoreHost application) the assemblies you need are not accessible. Corehost applications only have access to the ArcGIS.Core and ArcGIS.CoreHost assemblies.
... View more
08-08-2023
11:49 AM
|
1
|
0
|
1519
|
|
POST
|
I just worked on an example (slated for 3.2 release) which is using a Memory geodatabase to store log information. My add-in creates a memory geodatabase and then creates a 'log' table (to track changes) in that memory geodatabase (under certain conditions). The 'log' table was then added to the map as a 'standalone' table (so that i could use a TableControl to display its content). If the project was saved at any time the project file on reopening showed the 'log' standalone table entry in the table of content with an error explanation mark. To solve my problem my add-in listened to the usual events (i.e., ActiveMapViewChangedEvent) and re-created the memory geodatabase and table. This fixed the problem for me. Needless to say, if one opens such a project file without my add-in installed the orphaned entry would stay in the table of content.
... View more
08-08-2023
09:01 AM
|
0
|
1
|
2198
|
|
POST
|
As the last parameter for ExecuteToolAsync call you can try 'GPExecuteToolFlags.GPThread'
... View more
08-07-2023
12:09 PM
|
0
|
2
|
1469
|
|
POST
|
@GKmieliauskas is correct, you have to call the export method from the MCT. Your example code worked fine for after i made a few correction and added some error checking: protected override async void OnClick()
{
try
{
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout")) ?? throw new Exception("Layout not found");
Layout layout = await QueuedTask.Run(() => layoutItem.GetLayout());
String filePath = @"c:\temp\map.pdf";
//Create a PDF export format
PDFFormat pdf = new()
{
OutputFileName = filePath,
Resolution = 300,
DoCompressVectorGraphics = true,
DoEmbedFonts = true,
HasGeoRefInfo = true,
ImageCompression = ImageCompression.Adaptive,
ImageQuality = ImageQuality.Best,
LayersAndAttributes = LayersAndAttributes.LayersAndAttributes
};
//Check to see if the path is valid and export
if (!pdf.ValidateOutputFilePath())
throw new Exception($@"Invalid path: {filePath}");
await QueuedTask.Run(() => layout.Export(pdf)); //Export the PDF
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.ToString());
}
} Running the sample code above results in a c:\temp\map.pdf file: I fixed the ProSnippet so that the Export method is now called from within QueuedTask.Run. Thanks for pointing this out.
... View more
08-07-2023
05:56 AM
|
1
|
1
|
1570
|
|
POST
|
Is the UI that you are using in a dockpane or on the ribbon? If you use a custom locator on a dockpane then you can use MVVM as shown in this sample: arcgis-pro-sdk-community-samples/Map-Authoring/GeocodingTools at master · Esri/arcgis-pro-sdk-community-samples (github.com) if you use MVVM you don't have to rely on any events, instead you can use the setter of the 'SelectedItem' dependency property to drive your enable/disable logic.
... View more
07-23-2023
11:58 PM
|
0
|
0
|
655
|
|
POST
|
My sample code above is for release 3.0 and newer, if you are using ArcGIS Pro 2.x then the API is bit different. Below is the snippet that works with 2.9, note the change in the copyOperation.Create line required by the 2.x API (the parameters are different): protected override async void OnClick()
{
var originalLayerName = "TestPolygons";
var newLayerName = "NewLayer";
var originalLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains(originalLayerName)).FirstOrDefault();
var isOk = await QueuedTask.Run<bool>(() =>
{
var LayerDef = originalLayer.GetFeatureClass().GetDefinition();
bool success = false;
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))))
{
// Creating the attribute fields
ArcGIS.Core.Data.DDL.FieldDescription objectIDFieldDescription = ArcGIS.Core.Data.DDL.FieldDescription.CreateObjectIDField();
ArcGIS.Core.Data.DDL.FieldDescription field1 = new ArcGIS.Core.Data.DDL.FieldDescription("field1", FieldType.Double);
ArcGIS.Core.Data.DDL.FieldDescription field2 = new ArcGIS.Core.Data.DDL.FieldDescription("field2", FieldType.Double);
List<ArcGIS.Core.Data.DDL.FieldDescription> fieldDescriptions = new List<ArcGIS.Core.Data.DDL.FieldDescription>()
{
objectIDFieldDescription,
field1,
field2
};
FeatureClassDefinition originalFeatureClassDefinition = originalLayer.GetFeatureClass().GetDefinition();
FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition);
FeatureClassDescription LayerDescription = new FeatureClassDescription(newLayerName, fieldDescriptions, originalFeatureClassDescription.ShapeDescription);
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
schemaBuilder.Create(LayerDescription);
success = schemaBuilder.Build();
}
return success;
});
if (!isOk)
{
MessageBox.Show($@"Failed to create {newLayerName}");
return;
}
// add the new FeatureClass to the map
var newLyr = await QueuedTask.Run(() =>
{
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))))
{
var newFc = geodatabase.OpenDataset<FeatureClass>(newLayerName);
return LayerFactory.Instance.CreateLayer<FeatureLayer>(new FeatureLayerCreationParams(newFc) { Name = $@"New: {newLayerName}" }, MapView.Active.Map);
}
});
// copy some data
await QueuedTask.Run(() =>
{
// create an edit operation
EditOperation copyOperation = new EditOperation()
{
Name = "Copy Data",
ProgressMessage = "Working...",
CancelMessage = "Operation canceled.",
ErrorMessage = "Error copying polygons",
SelectModifiedFeatures = false,
SelectNewFeatures = false
};
using (var rowCursor = originalLayer.Search())
{
while (rowCursor.MoveNext())
{
using (var row = rowCursor.Current as Feature)
{
var geom = row.GetShape().Clone();
if (geom == null)
continue;
var newAttributes = new Dictionary<string, object>
{
{ newLyr.GetFeatureClass().GetDefinition().GetShapeField(), geom },
{ "field1", 1.0 },
{ "field2", 2.0 }
};
copyOperation.Create(newLyr, newAttributes);
}
}
}
// execute the operation
if (!copyOperation.Execute())
{
MessageBox.Show($@"Copy operation failed {copyOperation.ErrorMessage}");
return;
}
});
} In order to save all edits you can use: _ = Project.Current.SaveEditsAsync();
... View more
07-23-2023
08:25 AM
|
0
|
0
|
1468
|
|
POST
|
I think this ProGuide explains the issue: ProGuide Content and Image Resources · Esri/arcgis-pro-sdk Wiki (github.com) There is a difference when referencing images from DAML versus referencing images from XAML. The previous posts were DAML references, your example is XAML. So, when you tried to apply the DAML solution to your XAML it didn't work, because the references and build actions are different for DAML and XAML.
... View more
07-20-2023
11:06 AM
|
0
|
0
|
835
|
|
POST
|
Sorry for the delay but as of ArcGIS Pro 3.0 the build action 'AddInContent' is obsolete. ProGuide Content and Image Resources · Esri/arcgis-pro-sdk Wiki (github.com) The replacement is build action 'Content'
... View more
07-20-2023
10:54 AM
|
0
|
0
|
6099
|
|
POST
|
It is working for me. The following snippet will create a new FeatureClass class "NewLayer" from an existing "TestPolygons" feature layer using the same shape definition but with two new fields. Then it adds the new FeatureClass to the map as "New: NewLayer" and finally copies all existing features from "TestPolygons" to "New: NewLayer". protected override async void OnClick()
{
var originalLayerName = "TestPolygons";
var newLayerName = "NewLayer";
var originalLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains(originalLayerName)).FirstOrDefault();
var isOk = await QueuedTask.Run<bool>(() =>
{
var LayerDef = originalLayer.GetFeatureClass().GetDefinition();
using Geodatabase geodatabase = new(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)));
// Creating the attribute fields
FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
FieldDescription field1 = new("field1", FieldType.Double);
FieldDescription field2 = new("field2", FieldType.Double);
List<FieldDescription> fieldDescriptions = new()
{
objectIDFieldDescription, field1, field2
};
FeatureClassDefinition originalFeatureClassDefinition = originalLayer.GetFeatureClass().GetDefinition();
FeatureClassDescription originalFeatureClassDescription = new(originalFeatureClassDefinition);
FeatureClassDescription LayerDescription = new(newLayerName, fieldDescriptions, originalFeatureClassDescription.ShapeDescription);
SchemaBuilder schemaBuilder = new(geodatabase);
schemaBuilder.Create(LayerDescription);
bool success = schemaBuilder.Build();
return success;
});
if (!isOk)
{
MessageBox.Show($@"Failed to create {newLayerName}");
return;
}
// add the new FeatureClass to the map
var newLyr = await QueuedTask.Run(() =>
{
using Geodatabase geodatabase = new(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)));
var newFc = geodatabase.OpenDataset<FeatureClass>(newLayerName);
return LayerFactory.Instance.CreateLayer<FeatureLayer>(new FeatureLayerCreationParams(newFc) { Name = $@"New: {newLayerName}" }, MapView.Active.Map);
});
// copy some data
await QueuedTask.Run(() =>
{
// create an edit operation
EditOperation copyOperation = new EditOperation()
{
Name = "Copy Data",
ProgressMessage = "Working...",
CancelMessage = "Operation canceled.",
ErrorMessage = "Error copying polygons",
SelectModifiedFeatures = false,
SelectNewFeatures = false
};
using var rowCursor = originalLayer.Search();
while (rowCursor.MoveNext())
{
using (var row = rowCursor.Current as Feature)
{
var geom = row.GetShape().Clone();
if (geom == null)
continue;
var newAttributes = new Dictionary<string, object>();
newAttributes.Add("field1", 1.0);
newAttributes.Add("field2", 2.0);
copyOperation.Create(newLyr, geom, newAttributes);
}
}
// execute the operation
if (!copyOperation.Execute())
{
MessageBox.Show($@"Copy operation failed {copyOperation.ErrorMessage}");
return;
}
});
}
... View more
07-05-2023
06:01 PM
|
0
|
1
|
1579
|
|
POST
|
i haven't tried this but i think these lines have an issue: ShapeDescription shapeDescription = new ShapeDescription(IntersectSort.GetFeatureClass().GetDefinition());FeatureClassDescription LayerDescription = new FeatureClassDescription("Layer_Name", fieldDescriptions, shapeDescription); maybe try this instead: FeatureClassDefinition originalFeatureClassDefinition = IntersectSort.GetFeatureClass().GetDefinition();
FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition);
FeatureClassDescription LayerDescription = new FeatureClassDescription("Layer_Name", fieldDescriptions, originalFeatureClassDescription.ShapeDescription);
... View more
07-05-2023
04:40 PM
|
0
|
1
|
1590
|
|
POST
|
i would recommend using ClosedXML: NuGet Gallery | ClosedXML 0.102.0 ClosedXML/ClosedXML: ClosedXML is a .NET library for reading, manipulating and writing Excel 2007+ (.xlsx, .xlsm) files. It aims to provide an intuitive and user-friendly interface to dealing with the underlying OpenXML API. (github.com)
... View more
07-05-2023
10:29 AM
|
1
|
0
|
1110
|
|
POST
|
i don't think you need a license on a build server. See details on configuration options here: ProConcepts Advanced Topics · Esri/arcgis-pro-sdk Wiki (github.com)
... View more
07-03-2023
03:29 PM
|
0
|
1
|
2035
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Monday | |
| 1 | 07-30-2025 12:03 PM | |
| 1 | 10-06-2025 01:19 PM | |
| 1 | 10-06-2025 10:37 AM | |
| 1 | 09-24-2025 09:12 AM |
| Online Status |
Online
|
| Date Last Visited |
14 hours ago
|