Select to view content in your preferred language

listLayer randomly can't find any names

04-07-2023 05:14 AM
New Contributor III


                        lyrList = map.listLayers()
                        for lyr in lyrList:
                            if  lyr.supports("NAME"):
                                if "Hillshade" in or == "temp":
                                # if == "Lift Stations":
                                #     insertrows(map, lyr, ski_run_query_lyr)
                                #     insertrows(map, "ski_run_query", lift_query_lyr)
                                if =="Building Centroid":
                                    insertrows(map, resort_feature_query_lyr)
                                    insertrows(map, resort_feature_resort_lyr)
                                    insertrows(map, building_lyr)
                                    insertrows(map, building_other_lyr)


Screenshot 2023-04-07 at 7.08.50 AM.pngThe first run of my script every time comes up with attribute "name" not supported on the layers. They make it through the name check but then fail. Has anyone else seen this. 

Tags (3)
0 Kudos
1 Reply
MVP Frequent Contributor

It seems like supports() is giving a false positive.  I would try and catch the specific layer causing the issue in a try except block initially as that might help you figure out the cause.
I'd also avoid using map as an object name as it could cause confusion, but that's just my opinion. 

0 Kudos