Is it possible to add an AttributedRelationshipClass Table to the map with esriDatasetType.esriDTRelationshipClass?

960
4
Jump to solution
09-18-2020 05:48 AM
TimNagelkerke
New Contributor

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

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

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

View solution in original post

0 Kudos
4 Replies
Maartenvan_Hulzen
Esri Contributor

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

0 Kudos
TimNagelkerke
New Contributor

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

0 Kudos
RichRuh
Esri Regular Contributor

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

0 Kudos
TimNagelkerke
New Contributor

Thanks for the reaction. 

Tim

0 Kudos