Select Related Data in Model Builder

1794
2
06-25-2019 10:10 AM
GinaBrewer-Mills
New Contributor II

I would like to automate a select by attributes and then select the related data and export that related data as it's own feature class.

So I need to input a feature class, iterate through that feature class to select certain features by a field name, then take the related data from that feature class, and export it to a new feature class. I know how to do this manually in ArcPro, but want to use model builder to iterate through the feature class, so I don't have to manually do this 375 times!

I am having trouble getting the related data part? 

Any help would be greatly appreciated.

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

I think this has always been a weakness presumably due to some technical issue that you can't run a relate to pass the selection from one layer to another in modelbuilder. Happy to be proven wrong if this functionality really does exist? In ArcPro they have now added a tool that Adds a Relate but this is not the same as running a relate, so not sure why you would ever use this tool in modelbuilder as you can't use the result of it within modelbuilder...

So in my eyes this leaves only one option, use a bit of python may be in the Calculate Value tool to read the selection and then build a SQL expression to select the rows in the "related" table.

0 Kudos
curtvprice
MVP Esteemed Contributor

I agree I do not believe relates are supported in geoprocessing. The best way to do one to many relates is either to build a long query expression as Duncan suggests using arcpy, or, add a join from the 'many' table to the 'one' table and use a sql expression use a query find the records that match in an unambiguous many to one join. For example, run this select on manytable with the active join to onetable:

onetable.OBJECT IS NOT NULL and onetable.RECTYPE = 'BEST'

0 Kudos