matthew driscoll & Thomas Stanley-Jones
Gentlemen, thank you both for your posts. You've pushed me along toward that dubious nirvana of labeling features with relates. I'm Python-deficient at present, and have a need to label a point feature based on a table that is two relates away: Facility (point) has Space (table) has Tenant (table). Your code fired right off after I shortened my table path, so I have Facility (point) has Space (table) no worries.
Is there an awesome Python reference that you know of that has examples of traversing multiple relates?
thanks again,
tim
Edit: I'm stunned. I believe I just hacked my way into some nested cursors that did the trick. I'm quite positive it's not optimized, but it works. Now I'm just into the joy of retrieving domain descriptions so I'm not labeling my points with useful info like "3, 8, 2, 6"
So, thanks for the kick start, guys. I hope you're off enjoying your weekends early. On that note, I'd best lean back on some laurels and maybe slide on out of here.
def FindLabel( [GlobalID] ):
strSpaceTable = "C:\Facility.gdb\Space"
strTenantTable = "C:\Facility.gdb\Tenant"
strSpaceWhereClause = '"FacilityID" = \'{0}\''.format([GlobalID])
spacecursor = arcpy.da.SearchCursor(strSpaceTable, "GlobalID", strSpaceWhereClause)
for row in spacecursor:
spaceGlobalID = str(row[0])
strTenantWhereClause = '"SpaceID" = \'{0}\''.format(spaceGlobalID)
tenantcursor = arcpy.da.SearchCursor(strTenantTable, "Org3Acronym", strTenantWhereClause)
tenantresult = ""
for row in tenantcursor:
strLabel = str(row[0])
tenantresult += strLabel + "\n"
return tenantresult
return tenantresult.rstrip()