0

Is it possible in Python to apply the legend from a template layer file to a SDE based feature layer with a GDB table joined to it where the value field being used for the unique values symbology is in the joined table? The script I have worked in ArcGIS 10.2 but since we moved to 10.4.1 the 'arcpy.mapping.UpdateLayers' tool is no longer functioning as it did before.

The problem I see is with the field name after the join has taken place. For example, the template layer and respective GDB table both have the field "GDE_Code", but once the table is joined to the feature class this field becomes something like "Building.GDE_Code". So when I run the 'arcpy.mapping.UpdateLayers' tool in the script it will apply the legend from the template but no features will be displayed.

If I were to export the Building join to its own template layer and then use that one in the script on the joined Building feature layer everything works perfectly; however, is it possible to make the template generic so that it will work on other feature classes?

I've also tried using the 'arcpy.ApplySymbologyFromLayer_management' tool but it doesn't do anything.

This has been attempted as both a stand-alone geoprocessing tool and within the Python window of a Current ArcMap session.

One resolution I have seen is to export the joined feature layer to its own feature class so that the field name is just "GDE_Code", but ideally the goal is to perform this operation on a feature layer that is linking a SDE feature class to a file geodatabase table.

Here is the offending portion of script:

layers = arcpy.mapping.ListLayers(mxd, "*", df)
for layer in layers:
    layer2update = arcpy.mapping.ListLayers(mxd,layer,df)[0]
    layer2update.visible = False
    layerName = layer2update.name
    if layerName in FTRTables:              
        GDBtable = os.path.join(FTRepGDB,layerName)
        arcpy.AddJoin_management(layer2update,"facilityIDFK",GDBtable,"facilityIDFK","KEEP_ALL")
        desc = arcpy.Describe(layer2update)
        geometryType = desc.shapeType
        if geometryType == 'Polygon':
            arcpy.mapping.UpdateLayer(df,layer2update,Polygon,True)
        elif geometryType == 'Point':
            arcpy.mapping.UpdateLayer(df,layer2update,Point,True)
        elif geometryType == 'Polyline':
            arcpy.mapping.UpdateLayer(df,layer2update,Line,True)
        else:
            pass
    else:
        pass
1

After consulting with Esri reps this is now a logged bug, they were able to verify that the process did work in 10.2 but no longer does in 10.4 or 10.5. Perhaps future releases will resolve the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.