Drag and Drop from Content Pane

815
5
Jump to solution
11-12-2019 12:01 AM
VictorTey
Esri Contributor

Hi,

Following Uma Harano‌ code on Drag & Drop into a DockPane , I am attempting to get the name and catalogue path of the payload that have been drag from the content pane.

if it possible to get the full catalogue path to the item selected?

Thanks

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi Victor

To get the underlying featureclass path from a feature layer you'll have to concatenate the datastore path and the featureclass name.  A code snippet like this worked for me:

  var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
            QueuedTask.Run( () => {
                //get the underlying featureclass path for the layer
                var fc = lyr.GetFeatureClass();

                //get the datastore for the featureclass
                var datastore = fc.GetDatastore();

                //concat hydrant path (datastore and featureclass name)
                var hydPath = datastore.GetPath().AbsolutePath + @"/" + fc.GetName();
            });

Thanks

Uma

View solution in original post

0 Kudos
5 Replies
UmaHarano
Esri Regular Contributor

Hi,

The property to use is "CatalogPath".

The Drag and Drop sample is available here in the community sample repo: Drag and Drop sample

Thanks

Uma

0 Kudos
VictorTey
Esri Contributor

Hi Uma,

thats great if 

dropInfo.Data is List<ClipboardItem> clipboardItems

however what if if it is a mapMember or layer?

var mm = dropInfo.GetTOCContent();//extension method - returns all MapMembers being dropped
        //get just feature layers, for example
        var layers = dropInfo.GetTOCContentOfType<FeatureLayer>()

I tried with the following: 

layers[0].getFeatureClass().getDataStore().getPath() however I get a funny temporary sde connection in my temp folder.

Thanks in advance

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Victor

To get the underlying featureclass path from a feature layer you'll have to concatenate the datastore path and the featureclass name.  A code snippet like this worked for me:

  var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
            QueuedTask.Run( () => {
                //get the underlying featureclass path for the layer
                var fc = lyr.GetFeatureClass();

                //get the datastore for the featureclass
                var datastore = fc.GetDatastore();

                //concat hydrant path (datastore and featureclass name)
                var hydPath = datastore.GetPath().AbsolutePath + @"/" + fc.GetName();
            });

Thanks

Uma

0 Kudos
VictorTey
Esri Contributor

Thanks Uma,

Might be the environment I am working on. There must be something funky going on in the background as my sde connection seem to point to a temporary sde conn as I am positive that is not the right sde connection.

NameValueType
layer.GetFeatureClass().GetDatastore().GetPath().AbsolutePath"C:/Users/XXXXX/AppData/Local/Temp/5/ArcGISPro22300/f169296daa50ef0d20200577ae327cf5.sde"string
0 Kudos
UmaHarano
Esri Regular Contributor

Hi Victor,

Here are the exact steps to use to get the fully qualified path:

1. Get the Datastore from the Dataset using Dataset.GetDatastore()
2. Get the path to the Datastore using Datastore.GetPath()
3. Append a \ character
4. Append the name of the dataset (Dataset.GetName())

Thanks!

Uma

0 Kudos