I'm currently trying to wrap my head around relationship classes and there seems to be a dearth of information on interacting with them beyond the ability to create them or describe them. Is reading from/writing to RCs not exposed in the arcpy API? Even in the GUI the RC object doesn't give me any ways to introspect it; I can't open it as a table to see *what* is in it, if anything.
Can I add relationships to it by providing the key pair? Is it an SQLite database like .stylx files are and I'd have to interact with it via the SQL python module? I can find a dozen example on *creating* a relationship class with arcpy but nothing beyond that--even finding the RC in the database in convoluted and only returns the describe object as opposed to the actual RC object itself.
If I can't interact with it meaningfully with arcpy, is it exposed in another API I can stumble my way through to modify it?
Solved! Go to Solution.
I was initially not, no. Which would explain the inability to see any of the relationships. Why attribution is disabled by default when creating a relationship class, I do not know but at the same time I haven't really wrapped my head around all there is to be aware of with relationship classes.
Once I got the RC regenerated as attributed, I was able to get access to the intermediate table. Using a regular InsertCursor seems to have updated the table as a test without complaint, so hopefully that should satisfy my original question.
I am a little perplexed, though. If it were as simple as running the typical cursors on the intermediate table, why was I not finding any discussion about that? I had run into a road-block with programmatically affecting relationship classes at a previous job where there seemed to be no answer outside of possibly doing it through the C# SDK for ArcPro (if I recollect). Maybe the lack of attribution was the cause, as I don't remember being able to access the relationships as easily as opening up an intermediate table of the relationship class. 🤔 Our M.O. at the time was to manually select and create the relationship through the context menu, over and over again, across thousands of features--easily the worst part of our workflow. I did just try this now with a 1:M relationship type; maybe the M:N relationship class was what we were using and may prove to be an issue. Something I'll have to test later...
I am not entirely sure I am following.... But the following technical article outlines how to add additional fields to a relationship - https://pro.arcgis.com/en/pro-app/latest/help/data/relationships/modify-a-relationship-class.htm.
That link also provides some other guides and a table of available functions. Does this not cover what you need? Or?
Unless I'm not seeing it, this all pertains to the properties of the relationship class and not the data it holds. I essentially need the Search/Update/Insert cursor equivalent for the table/file/whatever that holds the actual key entries that dictate "this feature is related to that feature"
Are you working with an attributed relationship class? If so, the article details how to add fields and has a link to the info on populating the relationship class table.
If you aren't working with an attributed relationship class, then I don't believe there is any modifications you can do...
I was initially not, no. Which would explain the inability to see any of the relationships. Why attribution is disabled by default when creating a relationship class, I do not know but at the same time I haven't really wrapped my head around all there is to be aware of with relationship classes.
Once I got the RC regenerated as attributed, I was able to get access to the intermediate table. Using a regular InsertCursor seems to have updated the table as a test without complaint, so hopefully that should satisfy my original question.
I am a little perplexed, though. If it were as simple as running the typical cursors on the intermediate table, why was I not finding any discussion about that? I had run into a road-block with programmatically affecting relationship classes at a previous job where there seemed to be no answer outside of possibly doing it through the C# SDK for ArcPro (if I recollect). Maybe the lack of attribution was the cause, as I don't remember being able to access the relationships as easily as opening up an intermediate table of the relationship class. 🤔 Our M.O. at the time was to manually select and create the relationship through the context menu, over and over again, across thousands of features--easily the worst part of our workflow. I did just try this now with a 1:M relationship type; maybe the M:N relationship class was what we were using and may prove to be an issue. Something I'll have to test later...
Defintiely report back your findings! Even as popular as Python has become there are still a lot of things that aren't documented well in discussions when it comes to the various ESRI python libraries. I find myself often digging through the documentation for things when using the API for Python library because people seem to have not had very extensive discussion about a lot of the extended functionalities!