def onClick(self): global editor editor.get_current() workspace = getworkspace(geomtype=u'Polygon') if workspace[u'data'] is not None: for data in workspace[u'data']: if data[u'gdb'] == editor.path: # create dummy settings_dict with 'Align to Roads' set to 1 temp_settings = { key: value for key, value in settings_dict.items() } temp_settings[u'Align to Roads'] = 1 rectifybuildings(layer=data[u'lyr'], roads=data[u'tline'], extent=workspace[u'extent'], settings=temp_settings, force=True, editor_object=editor) arcpy.RefreshActiveView() elif editor.path is None: # Fire a tool from toolbox if layer isn't in an edit session layer = data[u'lyr'] title = u'Warning' message = u'{0} layer is not in edit session\nWould you run a geoprocessing tool?'.format( layer.name) mb_type = 1 answer = pythonaddins.MessageBox(message, title, mb_type) if answer == u'OK': relpath = os.path.dirname(__file__) toolbox = os.path.join(relpath, u'scripts', u'toolbox', u'geometry_tools.pyt') pythonaddins.GPToolDialog(toolbox, u'OrthogonalizeBuildings') else: if editor.path is None: # Fire a tool from toolbox if there is no selection in a layer and no edit session title = u'Warning' message = u'{0}\nWould you run a geoprocessing tool?'.format( workspace[u'message']) mb_type = 1 answer = pythonaddins.MessageBox(message, title, mb_type) if answer == u'OK': relpath = os.path.dirname(__file__) toolbox = os.path.join(relpath, u'scripts', u'toolbox', u'geometry_tools.pyt') pythonaddins.GPToolDialog(toolbox, u'OrthogonalizeBuildings') else: title = u'Warning' message = u'{0}'.format(workspace[u'message']) mb_type = 0 pythonaddins.MessageBox(message, title, mb_type)
def onClick(self): # name of tool to be executed toolName = "OffsetScript" # call geoprocessing tool pythonaddins.GPToolDialog(toolboxPath, toolName) time.sleep(.2)
def onClick(self): arcpy.AddToolbox(r'c:\Pfafstetter\AddIn\Install\Otto_Pfafstetter.tbx') toolboxName = 'Otto_Pfafstetter' toolName = 'Pfafstetter' toolboxPath = r'c:\Pfafstetter\AddIn\Install\Otto_Pfafstetter.tbx' pythonaddins.GPToolDialog(toolboxPath, toolName) pass
def onClick(self): portalLogin = pythonaddins.GPToolDialog(tbxpath + "\\Toolbox.tbx", "SignIn") #Write to HTML filehandle = urllib.urlopen(list_services_path1 + ESS_org_ID + list_services_path2) for lines in filehandle.readlines(): list_services_org.append(lines)
def onClick(self): portalLogin = pythonaddins.GPToolDialog(tbxpath + "\\Toolbox.tbx", "SignIn") #2/16 Ash: List of services for the organization: # http://services.arcgis.com/Wl7Y1m92PbjtJs5n/ArcGIS/rest/services # Is it possible to extract organization ID from portalpy? filehandle = urllib.urlopen(list_services_path1 + ESS_org_ID + list_services_path2) for lines in filehandle.readlines(): list_services_org.append(lines) FILE = open(output_html, "w") for i in list_services_org: FILE.write(i) FILE.close() print "Check your output folder for a list of services in your organization." #This is used to select datasets which is a possibility #value = pythonaddins.OpenDialog('Credentials', True, r'C:\'', 'Add') #I am thinking of just creating tools to do all of this then prompting #the button with: pythonaddins.GPToolDialog(toolbox, tool_name) if portalLogin == "True": #ButtonClass2.enabled = True print "True" else: print "False"
def onClick(self): object = pythonaddins.GPToolDialog("C:\Users\University\Dropbox\University\Advanced_programming\practicals\prac1_modelBuilder\models.tbx", "explosionscript2") Input_Features = arcpy.GetParameterAsText(0) Distance__value_or_field_ = arcpy.GetParameterAsText(1) Layer = arcpy.GetParameterAsText(2) Intersect__3_ = arcpy.GetParameterAsText(3) if Intersect__3_ == '#' or not Intersect__3_: Intersect__3_ = "C:\\Users\\University\\Dropbox\\University\\Advanced_programming\\practicals\\advPrg.gdb\\Intersect" # provide a default value if unspecified Output_Feature_Class = arcpy.GetParameterAsText(4) try: try: arcpy.ImportToolbox("C:/Users/University/Dropbox/University/Advanced_programming/practicals/prac1_modelBuilder/models.tbx", "models") except arcpy.ExecuteError as e: print("Import toolbox error", e) try: arcpy.Explosion_models(Input_Features, Distance__value_or_field_, Layer, Intersect__3_, Output_Feature_Class) # don't forget to remove the " " when changing to parameter based inputs except arcpy.ExecuteError as e: print("Model run error", e) except Exception as e: print(e)
def onClick(self): global portalLogin """ While the GPToolDialog runs asynchronously from the tool, it does have the option to import the global variable and then reassign the variable to the portal object. This allows our users to access the portal object in other classes that we create from this. """ pythonaddins.GPToolDialog(r"C:\Users\AlexanderN\Documents\GitHub\PortalPy-AddIn\102version\test\Install\Tools\Toolbox.tbx", "SignOn")
def onClick(self): fs_location = EDIT_Block_ToolBoxLocation + "\\" + EDIT_Block_ToolBox # pythonaddins.MessageBox("Vk",fs_location,0) try: pythonaddins.GPToolDialog(fs_location, EDIT_BLOCK_CompileBlock_Tool) except: pass
def onClick(self): try: urllib2.urlopen("https://www.google.com/") except Exception as e: pythonaddins.MessageBox("Sorry, there is no internet connection.", "Connection error") else: pythonaddins.GPToolDialog(toolbox_path, "WPDownload")
def onClick(self): toolboxName = "Geocoding Tools" # name of tool to be executed toolName = "GeocodeAddresses" # call geoprocessing tool pythonaddins.GPToolDialog(toolboxName, toolName) time.sleep(.2)
def tool_dialog(toolbox, tool=None): """Error-handling wrapper around pythonaddins.GPToolDialog.""" # FIXME: either have to supress stderr here or always get an error. # Contacted internal resources to figure out what's going on. # This is NIM089253 / CR245605 try: err_default = sys.stderr sys.stderr = DevNull() if not tool: # assume that we're calling into a standard namespaced tool pythonaddins.GPToolDialog(toolbox) else: pythonaddins.GPToolDialog(toolbox, tool) sys.stderr = err_default except: print("recieved exception when trying to run GPToolDialog(" "{toolbox}, {tool}))".format(toolbox=toolbox, tool=tool)) return None
def onClick(self): if arcpy.Exists("m:/Documents/Programming2/Prac1/TEST.shp"): arcpy.Delete_management("m:/Documents/Programming2/Prac1/TEST.shp") pythonaddins.MessageBox("Deleting Test File", "Clean Up") object = pythonaddins.GPToolDialog( "m:/Documents/Programming2/Prac1/Models.tbx", "ExplosionScript") combobox.items = ["Test Box"]
class Runoff(object): """Implementation for Runoff_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): try: pythonaddins.GPToolDialog("WatershedImprovementPlanningTools.pyt", "Runoff") except TypeError: pass
def onClick(self): try: pythonaddins.GPToolDialog(get_toolbox(), "AddCoreLayersTool") except Exception as e: pythonaddins.MessageBox("Error: {}".format(e), "Add Core Layers") return
def onClick(self): workDir = os.path.dirname(__file__) Tbx = workDir + "\\Tools\\Toolbox.tbx" print Tbx global portalLogin """ While the GPToolDialog runs asynchronously from the tool, it does have the option to import the global variable and then reassign the variable to the portal object. This allows our users to access the portal object in other classes that we create from this. """ pythonaddins.GPToolDialog(Tbx, "SignOn")
def toolDialog(toolbox, tool): """Error-handling wrapper around pythonaddins.GPToolDialog.""" result = None try: result = pythonaddins.GPToolDialog(toolbox, tool) # FIXME: this is a hack to prevent: # TypeError: GPToolDialog() takes at most 1 argument (2 given) print '', except TypeError: print "recieved TypeError when trying to run GPToolDialog(" + \ "{toolbox}, {tool}))".format(toolbox=toolbox, tool=tool) # don't return anything. this prevents: # TypeError: GPToolDialog() takes at most 1 argument (2 given) return result
def tool_dialog(toolbox, tool): """Error-handling wrapper around pythonaddins.GPToolDialog.""" # FIXME: either have to supress stderr here or always get an error. # Contacted internal resources to figure out what's going on. # This is NIM089253 / CR245605 try: err_default = sys.stderr sys.stderr = DevNull() pythonaddins.GPToolDialog(toolbox, tool) sys.stderr = err_default except: print "recieved exception when trying to run GPToolDialog(" + \ "{toolbox}, {tool}))".format(toolbox=toolbox, tool=tool) return None
def onClick(self): # name of toolbox without tbx extension toolboxName = "HerramientasG" # name of tool to be executed toolName = "CalcularGradiente" # create string with path to toolbox toolboxPath = os.path.join(os.path.dirname(__file__), toolboxName + ".tbx") # call geoprocessing tool pythonaddins.GPToolDialog(toolboxPath, toolName) pass
def onClick(self): """ Defines what actions/events occur when the button is clicked by the user """ # Lookup the directory to where this file is located on the local system and # append to the end of that result, the directory, 'TBX' followed by the name # of the Toolbox File, 'GeoWhiz.pyt' as store this result as 'ToolboxPath' ToolboxPath = os.path.dirname(__file__) + r"\TBX\retop.pyt" # Establish the 'ToolName' as the name of the tool within the toolbox to be # called ToolName = "ODTA" # Raise the Dialog of the given Tool ('ToolName') hosted within the given # Toolbox ('ToolboxPath') try: pythonaddins.GPToolDialog(ToolboxPath, ToolName) except Exception as e: pythonaddins.MessageBox(e.message) pass
def onClick(self): #Ash: I messed up this button because I wanted to see a sign on/ put something on git. portalLogin = pythonaddins.GPToolDialog(tbxpath + "\\Server Tools.tbx", "SignInToPortal") #This is used to select datasets which is a possibility #value = pythonaddins.OpenDialog('Credentials', True, r'C:\'', 'Add') #I am thinking of just creating tools to do all of this then prompting #the button with: pythonaddins.GPToolDialog(toolbox, tool_name) if portalLogin == "True": #ButtonClass2.enabled = True print "True" else: print "False"
def onClick(self): print "CLICK" global portalLogin """ While the GPToolDialog runs asynchronously from the tool, it does have the option to import the global variable and then reassign the variable to the portal object. This allows our users to access the portal object in other classes that we create from this. """ pythonaddins.GPToolDialog(TBXPATH, "SignOn") fs = portalLogin.search(q='type:Feature Service', sort_field='title', sort_order='asc') #Ash 2/17: Creates output.txt that contains names of all services in the organization. FILE = open(output, "w") for i in fs: FILE.write(i.get('title') + "\n") FILE.close() print "Check test\\Install\\Output"
def open(self): # validate active project self.tbx.set_active_project() valid, msg = self.tbx.validate_project_folder() if not valid: pythonaddins.MessageBox(msg, 'Fehler', 0) return valid, msg = self.tbx.validate_active_project() if not valid: pythonaddins.MessageBox(msg, 'Fehler', 0) return # call toolbox valid, msg = self.tbx.validate_inputs() if not valid: pythonaddins.MessageBox(msg, 'Fehler', 0) return # let the GUI build an instance of the toolbox to show it # (regular call of updateParameters etc. included) if self._do_show: pythonaddins.GPToolDialog(self.path, self._toolbox_name) # execute main function of Tool only (no updates etc. possible) else: self.tbx.execute()
def onClick(self): pythonaddins.GPToolDialog(r'\\192.168.201.115\cpv2017\SegmentacionRural_Procesamiento\TBX\ToolbarSegmRuralV3.tbx', 'CargarInfo')
def onClick(self): pythonaddins.GPToolDialog(r'\\192.168.201.115\cpv2017\SegmentacionRural_Procesamiento\TBX\ToolbarSegmRuralV3.tbx', 'GenerarTablasFinales')
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "ApplySymbology")
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "SplitShpmask")
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "GenerateMidline")
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "CalibrateDTM")
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "CalculateRMSE")
def onClick(self): pythonaddins.GPToolDialog("C:/LiDAR1_Plugin_1.4/LiDAR1_Toolbox.tbx", "LoadIndices")