POST
|
Good Afternoon, So I currently have a button that adds a FeatureLayer to my map and redirects the .lyr data source to a featureclass via an SDE connection file. I would like to be able to redirect the data source directly to the Enterprise GDB since i have the necessary login credentials. What would i have to change in the example below to include the login credentials and server name to the connection info? internal class Menu1_button4 : Button
{
protected override void OnClick()
{
if (MapView.Active?.Map == null) return;
QueuedTask.Run(() =>
{
// add lyr/lyrx to map: This portion contains the Symbology of the added FeatureClass
var featureLayer = (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(@"FeatureLayer File"), MapView.Active.Map, 0, "Displayed Name");
CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();
CIMStandardDataConnection updatedDataConnection = null;
WorkspaceFactory wf = WorkspaceFactory.SDE;
var dbGdbConnection = new DatabaseConnectionFile(new Uri(@"sde connection file path"));
// provide a replacement data connection method
updatedDataConnection = new CIMStandardDataConnection()
{
WorkspaceConnectionString = new Geodatabase(dbGdbConnection).GetConnectionString(),
WorkspaceFactory = wf,
Dataset = "Exact FeatureClass",
DatasetType = esriDatasetType.esriDTFeatureClass
};
featureLayer.SetDataConnection(updatedDataConnection);
featureLayer.ClearDisplayCache();
});
}
}
... View more
a week ago
|
0
|
1
|
156
|
POST
|
Good Afternoon Gin! Thanks so much for getting back to be so quick. That example worked out wonderfully! I did have to make a few edits to the code, as seen below. if (MapView.Active?.Map == null) return;
QueuedTask.Run(() =>
{
// add lyr/lyrx to map
var featureLayer = (FeatureLayer)LayerFactory.Instance.CreateLayer(new
Uri(@"layerpath"), MapView.Active.Map, 0, "TOC Name");
CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();
CIMStandardDataConnection updatedDataConnection = null;
WorkspaceFactory wf = WorkspaceFactory.FileGDB;
// FileGeodatabaseConnectionPath does not contain a constructor that takes two arguments
var dbGdbConnection = new FileGeodatabaseConnectionPath(new Uri(@"gdb
Path"));
// provide a replace data connection method
updatedDataConnection = new CIMStandardDataConnection()
{
WorkspaceConnectionString = new
Geodatabase(dbGdbConnection).GetConnectionString(),
WorkspaceFactory = wf,
Dataset = "FeatureClassName",
DatasetType = esriDatasetType.esriDTFeatureClass
};
featureLayer.SetDataConnection(updatedDataConnection);
featureLayer.ClearDisplayCache();
}); The main correction was that FileGeodatabaseConnectionPath does not need to have a Uri type to be determined as it does not allow for more than one argument, which is the actual connection path. Maybe something different should be used there instead, but this seems to work all the same. Once again, thank you for your help. It is very much appreciated. -Derek Salinas
... View more
11-18-2020
12:31 PM
|
0
|
0
|
341
|
POST
|
Good Evening Gin, So in reply to your suggestion: " Another way is to create layer from lyrx file and change data connection (CIMDataConnection) to you featureclass source. You can find in Esri Pro samples." Would that just mean I change my existing code above to add the lyr or lyrx file to the map via the button instead of a feature class?
... View more
11-17-2020
06:44 PM
|
0
|
2
|
352
|
POST
|
Good Afternoon Everyone, So I have a button created and it is adding a feature class to my map via a FileGeodatabaseConnectionPath. As seen below. // Add this in your OnClick code-behind for the button
if (MapView.Active?.Map == null) return;
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// using the community sample dataset
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"U:\environmental\envgist.gdb"))))
{
using (FeatureClass addFeatureClass = geodatabase.OpenDataset<FeatureClass>("counties"))
{
LayerFactory.Instance.CreateFeatureLayer(addFeatureClass, MapView.Active.Map, 0, "Counties");
}
}
}); What information do I need to add to apply symbology from a lyr/lyrx file to this feature class? The layer files are in a folder stored on the same location as the gdb. Any help in the right direction is much appreciated. Thank You, Derek Salinas
... View more
11-16-2020
01:13 PM
|
0
|
4
|
388
|
POST
|
I have created a custom addin that I would like to house in a custom group the "esri_mapping_homeTab" to the right of the "Offline" group. I know i need to be able to update the "esri_mapping" module, but do I need to have the module added first? Thanks any help you can provide! -Derek Salinas
... View more
11-09-2020
10:36 AM
|
0
|
1
|
171
|
POST
|
Wow! That was all a major help and it worked out perfectly. Thank you so much for taking the time. Regards, Derek
... View more
11-06-2020
06:14 PM
|
0
|
0
|
123
|
POST
|
Awesome Narelle! Thanks so much for getting me this! I did have a couple questions though. In your "group" section, you have "insertButtonPallet" as the call but im pretty sure it is supposed to be "buttonPallet", correct? Also, the path for the menu goes to a slightly different item than the rest of your menus (task & tasks), and im wondering if you have to add the detail for the buttonPallet you insert in the groups into a different item? Forgive me for my crap nomenclature, I hope im conveying my questions adequately. Thanks! Derek
... View more
11-06-2020
03:26 PM
|
0
|
2
|
690
|
POST
|
Good Morning Gintautas, Its strange though, there is a section in the 'Insert' Tab that makes me think you can do a split button in a split button. Within 'Insert,' you will see the button 'Task' in the 'Projects' group is a split button that drops down to a regular button and another split button. I'm just not sure how to organize that properly within the code.
... View more
10-29-2020
09:36 AM
|
0
|
5
|
690
|
POST
|
Thanks for the suggestions Uma! Although I think with the amount of data that there is to organize and the subcategories needed a simple menu structure like the previous ArcMap python example i have above would be best. Galleries just seem too invasive from a UX standpoint. Currently I just have the simple button pallet with drop down that contains a few feature class buttons. I read somewhere that it is not possible to contain several button_pallets or splits within one but im hoping that is wrong.
... View more
10-28-2020
03:25 PM
|
0
|
0
|
690
|
POST
|
Good Morning Gintautas, Thanks for your timely reply. It was very helpful for a base case addin. Im curious, if i had too many button elements in a split button and they needed further organization, is there a way I can "subgroup" a list of split buttons in an existing split button? Would that just require inserting split buttons in the parent? Regards, Derek
... View more
10-28-2020
10:37 AM
|
0
|
9
|
690
|
Online Status |
Offline
|
Date Last Visited |
a week ago
|