Python Add In for abandoned feature class

503
6
Jump to solution
05-25-2018 01:11 AM
JAY_PRAKASHKUMAR
New Contributor III

Hey everyone!

I want to create a Python Add-In tool that will perform the following sequence of tasks:

1. Read a specific feature layer in Table of Content (let's call it X)

2. Check the version for the layer [Working on SDE only]

3. Read the selected features from the layer X

4. Copy the selected features from layer X to another layer Abandoned_X and delete them from X.

5. Search layers (say Y, Z, ...) related to layer X, copy the related features to layers Abandoned_Y, Abandoned_Z, ... and delete them from Y, Z, ...

 

Requirements:

  • The tool should work as an extension of the editor Toolbar
  • The python Add-In button should be greyed-out when not in use and usable only after editing is turned on
  • If the edits are not saved, then the tool should revert back all the changes made to say, X, Y, Z, ...

I have written logic until step 5. Following are the questions:

  1. How to grey-out the Add-in (render is useless) when ArcMap starts? 

Thank you for your time!

0 Kudos
1 Solution

Accepted Solutions
JAY_PRAKASHKUMAR
New Contributor III

Hi Dan,

I was able to complete my requirement.

The below link helped me to solve my issue when I tried my add In creation freshly 

Checking via ArcPy if ArcMap is in edit session? - Geographic Information Systems Stack Exchange 

Thanks for your time

Jay

View solution in original post

6 Replies
DanPatterson_Retired
MVP Esteemed Contributor

which proposed solution?

did it just not work? or did you get errors?

0 Kudos
JAY_PRAKASHKUMAR
New Contributor III

Hello Dan,

I am adding the code from the link:

Checking via ArcPy if ArcMap is in edit session? - Geographic Information Systems Stack Exchange 

The part of the code I am trying to implement 

class Active_Edit_Session(object):"""Implementation for NEZ_EDITS_addin.Listen_for_Edit_Session (Extension)"""def __init__(self):    self.enabled = Truedef onStartEditing(self):    button_3100.enabled=True    def onStopEditing(self, save_changes):    button_3100.enabled=Falseclass LFM_3100(object):    """Implementation for LFM_3100.button_3100 (Button)"""    def __init__(self):        self.enabled = False        self.checked = False    def onClick(self):        ......


This does not help me to gray out the python addin button with start of arcmap(it am not getting any error, It just simply do not work)
But I am able to gary out onces the editor is started and stoped. 

Even I have tried 

startup(self) function from below link

Extension class—Help | ArcGIS Desktop 

where I kept 

startup(self)

button. enable = False 

does not work for me

Thanks for your time

Jay

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

you did edit the code you were trying to follow?  button_3100.enabled=True obviously isn't in yours

JAY_PRAKASHKUMAR
New Contributor III

yes edited as per my requirement

def onStartEditing(self):

   button.enabled = True
def onStopEditing(self, save_changes):
   button.enabled = False 

0 Kudos
JAY_PRAKASHKUMAR
New Contributor III

I have just taken the concept.

The above logic works fine once the editor is started. The button does not gray out with the start of ArcMap.

0 Kudos
JAY_PRAKASHKUMAR
New Contributor III

Hi Dan,

I was able to complete my requirement.

The below link helped me to solve my issue when I tried my add In creation freshly 

Checking via ArcPy if ArcMap is in edit session? - Geographic Information Systems Stack Exchange 

Thanks for your time

Jay

View solution in original post