Skip to main content
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Source Link
GISI
  • 1.2k
  • 1
  • 9
  • 30

Arcpy Pythonaddins Equivalent of arcpy.GetParameterAsText

I've build a neat little search arcpy script. The user opens any mxd, zooms to a location, chooses a corporate fGDB, and runs the tool. The user gets a list of all the populated feature class that intersects the current extent. Later I aim to write a process that the user can choose which layers they want to add. However I digress. I'm looking at embedding the arcpy into an addin, my first issue is learning what the equivalent of a arcpy.GetParameterAsText is, as I want the user to specify the work-space they need to interrogate.

import arcpy
import pythonaddins
class ButtonClass1(object):
"""Implementation for AddIn_Test4_addin.button (Button)"""
def __init__(self):
    self.enabled = True
    self.checked = False
def onClick(self):
    ################## MAP DOCUMENT DATA FRAME EXTENT
    
    StagingGDB = arcpy.GetParameterAsText(0)
    #StagingGDB = "C:\\Data\\Projects\\SearchTool\\CorpData1.gdb"
    arcpy.env.workspace = StagingGDB
    ExtentFC = StagingGDB +"\\ExtentFC"
    
    ############ Clean Up & Pre Check
    if arcpy.Exists(ExtentFC):
        arcpy.Delete_management(ExtentFC)
    
    ################## MAP DOCUMENT DATA FRAME EXTENT
    mxd = arcpy.mapping.MapDocument("current")
    df = arcpy.mapping.ListDataFrames(mxd)[0]
    currentExtent = df.extent

    ################## EXTENT FC
    pnt1 = arcpy.Point(currentExtent.XMin , currentExtent.YMin)
    pnt2 = arcpy.Point(currentExtent.XMax , currentExtent.YMin)
    pnt3 = arcpy.Point(currentExtent.XMax , currentExtent.YMax)
    pnt4 = arcpy.Point(currentExtent.XMin , currentExtent.YMax)
    array = arcpy.Array()
    array.add(pnt1)
    array.add(pnt2)
    array.add(pnt3)
    array.add(pnt4)
    array.add(pnt1)
    DisplayExtent = arcpy.Polygon(array)
    arcpy.FeatureClassToFeatureClass_conversion(DisplayExtent , StagingGDB ,"ExtentFC", "", "", "")
    pass

Any ideas?