AnsweredAssumed Answered

Copy extent to clipboard

Question asked by on Mar 24, 2017
Latest reply on Jun 6, 2017 by

I am not a developer, but I want to use a python script from a former colleague. Parts of the script clip the current extent in ArcMap to the clipboard. It works well iwthhin in Addin on my Virtual Machine. If I use the same script/addin on my notebook (with a differnt user though) in the companies network, it doesn´t work. Any ideas? How do I have to modify the script?


import arcpy
import pythonaddins
from Tkinter import Tk
import os



class XY_Kopieren(object):
    """Implementation for ToeB_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        mxd = arcpy.mapping.MapDocument('current')
        activeDataFrame = mxd.activeView
        df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
        xmin = df.extent.XMin
        xmax = df.extent.XMax
        ymin = df.extent.YMin
        ymax = df.extent.YMax
        r = Tk()
        r.clipboard_append(str(xmin)[0:6] + ',' + str(ymin)[0:7] + ',' + str(xmax)[0:6] + ',' + str(ymax)[0:7])
        pythonaddins.MessageBox('Die Koordinaten des aktuellen Raumausschnittes wurden in die Zwischenablage kopiert.', 'INFO', 0)


@Jake Skinner () published a similar Add-In called Extent Python Add-In. It works well my has blank spaces between the coordinates and decimals in it. I would need the coordinates copied like 334736,5658853,417290,57118 to the clipboard to use it in a second application. Can I change an Add-In? If not. Can you @jskinner_CountySandbox help?

#python copy results to clipboard #clipboard #copy extent