Hi everyone, I've got a similar situation... I've tried the above mentioned feature selection detection scripts but they do not work on my ArcMap 10.2. Or maybe I'm not puting them in right?
I've got a button that when pressed performs two field calculations - one on a polygon layer then another on a arc layer.
However I want to put in a failsafe so it will not do anything if nothing is selected since this morning I accidentally had a polygon selected and there was no arc selected so it field calc'ed the entire Kerb_Channel arc feature class with one value!!!
Basically they're polygon traffic islands with arc kerb lines around them, however the prefab traffic islands must not have a kerb line because there is no seperate kerb. I've used the ArcGIS AddIn Assistant to make the button with this Arcpy script which I copied and pasted from an exported to Python Model Builder model:
import arcpy
import pythonaddins
# Local variables:
Traffic_Islands = "Island+Kerb Topology\\Traffic_Islands"
Kerb_Channel = "Island+Kerb Topology\\Kerb_Channel"
class ButtonClass1(object):
"""Implementation for SetKerbType_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
# Some kind of selection detection code here for the Kerb_Channel layer since a polygon will always be selected
arcpy.CalculateField_management(Traffic_Islands, "KERB_TYPE", "\"SM3\"", "VB", "")
arcpy.CalculateField_management(Kerb_Channel, "KERBTYPE", "\"SM3\"", "VB", "")
Also, is there a PDF or site somewhere that has the Arcpy procedures and functions and what they do etc like there is for normal Python? I've googled it and I can't find anything with a list of Arcpy procedures/functions with what they do and how to use them. Something like SharpDev's inline help would be awesome.
Thank you,
Gregg