ArcGIS Pro version: 2.5
I have created a filegeodatabase with 2 Feature Classes and 1 Relationship Class with a Table (AttributedRelationshipClass).
The AttributedRelationshipClass defines the link between those two featurelayers using GUIDs and a few properties for the relation.
I used the ArcGis Pro sdk (c#) to add the feature classes to the map:
var map = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(e => e.Name == name);
var lyrDocFromLyrxFile = new LayerDocument(layerFile);
var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument();
var lcp = new LayerCreationParams(cimLyrDoc);
LayerFactory.Instance.CreateLayer<FeatureLayer>(lcp, map, LayerPosition.AutoArrange);
I tried to add the table with:
using (var table = geodatabase.OpenDataset<Table>(relationshipName))
{
StandaloneTableFactory.Instance.CreateStandaloneTable(table, map, table.GetName());
}
The datatype is then: esriDatasetType.esriDTTable.
This resulted in these warnings:
When I right click on the warning I get the option to add the table to the map. Then the table is added in the correct way with the datatype: esriDatasetType.esriDTRelationshipClass.
Is it possible to do this with the ArcGIS Pro .NET sdk?
Thanks,
Tim
Solved! Go to Solution.
Tim,
I haven't found a way to do this via the Pro SDK. We'll try to add support for this in a future ArcGIS Pro release.
--Rich
Hi Tim,
While i can't find a way to make this relationship class work yet, there may be an alternative.
Instead of an attributed relationship class. create the table first and add 2 relationships with the other two featureclasses. and see if that works for you.
Gr,
Maarten
Hi Maarten van Hulzen ,
Thanks for the suggestion.
I added the table with the StandAloneTableFactory, which added the table to the map.
I tried adding the relationships with the "table.RelateTo()" method, but this only adds a virtual relationship and doesn't work for me. It states that this method is only used to create a Join object.
Do you have a code snippet to actually add a relationship?
Thanks,
Tim
Tim,
I haven't found a way to do this via the Pro SDK. We'll try to add support for this in a future ArcGIS Pro release.
--Rich
Thanks for the reaction.
Tim