SHARE
TWEET

Untitled

a guest Jun 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import arcpy
  2.  
  3.  
  4. class Toolbox(object):
  5.     def __init__(self):
  6.         """Define the toolbox (the name of the toolbox is the name of the
  7.         .pyt file)."""
  8.         self.label = "Toolbox"
  9.         self.alias = ""
  10.  
  11.         # List of tool classes associated with this toolbox
  12.         self.tools = [Slide1,Slide2]
  13.  
  14.  
  15. class Slide1(object):
  16.     def __init__(self):
  17.         """Define the tool (tool name is the name of the class)."""
  18.         self.label = "Chile"
  19.         self.description = ""
  20.         self.canRunInBackground = False
  21.  
  22.     def getParameterInfo(self):
  23.         """Define parameter definitions"""
  24.         params = None
  25.         return params
  26.  
  27.     def isLicensed(self):
  28.         """Set whether tool is licensed to execute."""
  29.         return True
  30.  
  31.     def updateParameters(self, parameters):
  32.         """Modify the values and properties of parameters before internal
  33.         validation is performed.  This method is called whenever a parameter
  34.         has been changed."""
  35.         return
  36.  
  37.     def updateMessages(self, parameters):
  38.         """Modify the messages created by internal validation for each tool
  39.         parameter.  This method is called after internal validation."""
  40.         return
  41.  
  42.     def execute(self, parameters, messages):
  43.         """The source code of the tool."""
  44.         aprx = arcpy.mp.ArcGISProject("CURRENT")
  45.         mapx = aprx.listMaps()[0]
  46.         lyt = aprx.listLayouts()[0]
  47.         lyr = mapx.listLayers("ne_10m_admin_0_countries")[0]
  48.         lyr.definitionQuery = '"ADMIN" = ' + "'Chile'"
  49.         mFrame = lyt.listElements("MAPFRAME_ELEMENT")[0]
  50.         mFrame.camera.setExtent(mFrame.getLayerExtent(lyr, False, True))
  51.         lyr.definitionQuery = ""
  52.         return
  53.  
  54. class Slide2(object):
  55.     def __init__(self):
  56.         """Define the tool (tool name is the name of the class)."""
  57.         self.label = "Switzerland"
  58.         self.description = ""
  59.         self.canRunInBackground = False
  60.  
  61.     def getParameterInfo(self):
  62.         """Define parameter definitions"""
  63.         params = None
  64.         return params
  65.  
  66.     def isLicensed(self):
  67.         """Set whether tool is licensed to execute."""
  68.         return True
  69.  
  70.     def updateParameters(self, parameters):
  71.         """Modify the values and properties of parameters before internal
  72.         validation is performed.  This method is called whenever a parameter
  73.         has been changed."""
  74.         return
  75.  
  76.     def updateMessages(self, parameters):
  77.         """Modify the messages created by internal validation for each tool
  78.         parameter.  This method is called after internal validation."""
  79.         return
  80.  
  81.     def execute(self, parameters, messages):
  82.         """The source code of the tool."""
  83.         aprx = arcpy.mp.ArcGISProject("CURRENT")
  84.         mapx = aprx.listMaps()[0]
  85.         lyt = aprx.listLayouts()[0]
  86.         lyr = mapx.listLayers("ne_10m_admin_0_countries")[0]
  87.         lyr.definitionQuery = '"ADMIN" = ' + "'Switzerland'"
  88.         mFrame = lyt.listElements("MAPFRAME_ELEMENT")[0]
  89.         mFrame.camera.setExtent(mFrame.getLayerExtent(lyr, False, True))
  90.         lyr.definitionQuery = ""
  91.         return
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top