Ecco un approccio ArcObjects, basato su questo esempio , per enumerare tutti i join su un livello ed elencare i nomi delle tabelle di destinazione e di origine e le chiavi primarie ed esterne:
- Ottieni un riferimento a uno
ILayerche ha uno o più join
- Lancia il
ILayertoIDisplayTable
- Trasmetti la
IDisplayTable.DisplayTableproprietà aIRelQueryTable
- Mentre la tabella corrente è una
IRelQueryTable:
- Ispezionare le
RelQueryTable's DestinationTablee SourceTableproprietà
- Ispeziona le proprietà
OriginPrimaryKeye OriginForeignKeydella IRelQueryTable.RelationshipClassproprietà.
- Impostare la tabella corrente
RelQueryTablesulla SourceTableproprietà corrente
Questo script Python (utilizzando i comtype e questo modulo helper ) esaminerà tutti i join, dal più recente al meno recente, e stamperà i nomi delle tabelle di destinazione e di origine, la chiave primaria di origine e la chiave esterna di origine per ciascun join:
from ESRICOMHelpers import * # helper module from https://gis.stackexchange.com/a/5082/753
esriArcMapUI = GetESRIModule("esriArcMapUI")
esriCarto = GetESRIModule("esriCarto")
esriGeoDatabase = GetESRIModule("esriGeoDatabase")
def listJoins(table):
while CType(table, esriGeoDatabase.IRelQueryTable):
relQueryTable = CType(table, esriGeoDatabase.IRelQueryTable)
destTable = relQueryTable.DestinationTable
sourceTable = relQueryTable.SourceTable
destDataset = CType(destTable, esriGeoDatabase.IDataset)
sourceDataset = CType(sourceTable, esriGeoDatabase.IDataset)
relClass = relQueryTable.RelationshipClass
print destDataset.Name, sourceDataset.Name, relClass.OriginPrimaryKey, relClass.OriginForeignKey
table = sourceTable
if __name__ == "__main__":
#app = GetCurrentApp() # Use if run in-process
app = GetApp("ArcMap") # Use if run in a standalone script
mxd = CType(app.Document, esriArcMapUI.IMxDocument)
# Gets the first layer in the active data frame
map = mxd.FocusMap
lyr = map.Layer[0]
# Need to get the "display table" to access the joins
displayTable = CType(lyr, esriCarto.IDisplayTable).DisplayTable
# List the layer's joined tables
listJoins(displayTable)
Esempio di output, dato un livello sorgente con tre join:
join_table_3 master_fc_join_table_1_join_table_2 JOIN_ID_3 master_fc.MASTER_ID
join_table_2 master_fc_join_table_1 JOIN_ID_2 master_fc.MASTER_ID
join_table_1 master_fc JOIN_ID_1 MASTER_ID
Per altre info, vedi Come posso accedere ad ArcObjects da Python?