Is it possible to Iterate Create Relationship Class?

1459
5
Jump to solution
04-03-2019 09:17 AM
AbrahamDowner1
New Contributor III

I have a model that Iterates Field Values from one table containing a list of table names and another that contains a template schema to create a collection of tables for a vertical asset registry. The next step is that I need to add relationship classes. Each table has a naming convention of Water_FieldValue with a corresponding table of Water_FieldValue_Comp. Is it possible to use the same tables and process to iterate create relationship class?

ArcGIS 10.3.1

Thanks 

0 Kudos
1 Solution

Accepted Solutions
AbrahamDowner1
New Contributor III

Figured it out. Had to provide the directory for the destination table in the Calculate value tool. Also, had to switch backslashes to forward slashes for the python syntax to be correct. I used String as the data type in the tool. So,

  • "%Origin_Table%"[:6]+"3"+"%Origin_Table%"[7:]+"_Comp"

needed to be:

  • "Some_Directory/TEST_Water_Cityworks.gdb/"+"%Origin_Table%"[:6]+"3"+"%Origin_Table%"[7:]+"_Comp"

View solution in original post

0 Kudos
5 Replies
AbrahamDowner1
New Contributor III

This is sort of what I have in mind. 

0 Kudos
ColeAndrews
Occasional Contributor III

Abraham  Downer‌, since a model can only have 1 iterator, your step 1 to create tables is its own model (or submodel). When you get to the relationship class step, the tables are already created. Instead of iterating again over the "Tables to Create" table, you could try iterating over the GDB that already has the tables in existence. Since the tables to be used for the relationship class end in "_Comp", then the destination table is %Name%_Comp.

Not sure how it will handle iterating over the "_comp" tables, since you only need the ones without comp at the inputs. Pro has a wildcard setting for the table iteration tool to limit which tables it iterates over. I don't have 10.3.1 so I'm not sure if those settings are there as well.

AbrahamDowner1
New Contributor III

Going to try and resurrect this thread after coming back to this project. I am now able to make my model work for the first and second level of my gdb asset hierarchy (buildings to rooms, and rooms to assets) because of the fact that the top level of each has one feature class (buildings) or one table (rooms). However when I try to iterate relationship classes for many assets tables with many component tables the model fails. I am utilizing a calculated value as an substituted inline variable to create the relationship class destination table from the original table (as well as the forward label). the python portion of the calculated value tool works, but for some reason the destination table portion of the create relationship class tool does not like that value. 

Any ideas? ArcGIS version 10.6

Failed to execute (Create Relationship Class).
Failed at Mon Apr 13 14:30:23 2020 (Elapsed Time: 0.39 seconds)
Executing (Iterate Tables): IterateTables "Some_directory\TEST_Water_Cityworks.gdb" *2* # NOT_RECURSIVE
Start Time: Mon Apr 13 14:30:23 2020
Succeeded at Mon Apr 13 14:30:24 2020 (Elapsed Time: 0.32 seconds)
Executing (Calculate Value): CalculateValue "WATER_2_Pumps"[:6]+"3"+"WATER_2_Pumps"[7:]+"_Comp" # Variant
Start Time: Mon Apr 13 14:30:24 2020
Value = WATER_3_Pumps_Comp
Succeeded at Mon Apr 13 14:30:24 2020 (Elapsed Time: 0.00 seconds)
Executing (Create Relationship Class): CreateRelationshipClass "Some_directory\TEST_Water_Cityworks.gdb\WATER_2_Pumps" WATER_3_Pumps_Comp "Some_directory\TEST_Water_Cityworks.gdb\WATER_2_Pumps_has_WATER_3_Pumps_Comp" SIMPLE WATER_3_Pumps_Comp WATER_2_Pumps BOTH ONE_TO_MANY NONE FacilityID ParentID # #
Start Time: Mon Apr 13 14:30:24 2020
ERROR 000622: Failed to execute (CreateRelationshipClass). Parameters are not valid.

ERROR 000732: Destination Table: Dataset WATER_3_Pumps_Comp does not exist or is not supported

0 Kudos
AbrahamDowner1
New Contributor III

Figured it out. Had to provide the directory for the destination table in the Calculate value tool. Also, had to switch backslashes to forward slashes for the python syntax to be correct. I used String as the data type in the tool. So,

  • "%Origin_Table%"[:6]+"3"+"%Origin_Table%"[7:]+"_Comp"

needed to be:

  • "Some_Directory/TEST_Water_Cityworks.gdb/"+"%Origin_Table%"[:6]+"3"+"%Origin_Table%"[7:]+"_Comp"
0 Kudos
curtvprice
MVP Esteemed Contributor

I highly recommend using string formatting, a lot less painful

"Some_Directory/Test_Water_Cityworks.gdb/{}3{}_Comp".format("%Origin_Table%"[:6], "%Origin_Table%"[7:])