Add selected to relationship programmatically

09-24-2020 02:27 AM
New Contributor II

Say I have (1) a polygon feature layer and (2) a point feature layer and a relationship class between the two. The points that lie in each polygon are related to that polygon.

For existing features, the standard way of creating the relationship is to select the polygon and points, right-click on the layer in the attributes pane and select "Add selected to relationship".

Is there a way to do this programatically? For example in Arcpy? Maybe using a point in polygon selection/query followed by something else?

There doesnt seem to be a way to add selected features to the relationship without having to physically click buttons which is time consuming and inefficient. The only way I can think to do it would be to run a point-in-polygon selection/query for each polygon, get the polygon key and then update the key for each feature in the points layer. Not very elegant but is this the only way?

Tags (1)
1 Reply
New Contributor

I hate to ping you as I don't have an answer, but I actually have the same question and I'm hoping this will bring it around again for someone to finally answer.

0 Kudos