示例#1
0
 def onClick(self):
     if os.path.exists(Conexion().path):
         if loadCode.load:
             savepath = pythonaddins.SaveDialog(
                 nls().mapGeo().titleDialog,
                 '{}.mxd'.format(loadCode.codhoja), "", lambda x: x,
                 'Map Document(MXD)')
             if savepath:
                 evalue = os.path.basename(savepath).split(".")
                 if len(evalue) >= 2:
                     if evalue[-1] != "mxd":
                         pythonaddins.MessageBox(nls().mapGeo().errorFormat,
                                                 nls().titleError)
                 else:
                     savepath = '{}.mxd'.format(savepath)
                 try:
                     self.runProcess(savepath)
                     pythonaddins.MessageBox(nls().suscefull, nls().title)
                 except Exception as e:
                     pythonaddins.MessageBox(e, nls().titleError)
             else:
                 pass
         else:
             pythonaddins.MessageBox(nls().error, nls().titleError)
     else:
         pythonaddins.MessageBox(nls().failedConn, nls().titleError)
示例#2
0
 def onClick(self):
     arcpy.MakeXYEventLayer_management("FabricInvestigation\\Points", "X",
                                       "Y", "TruePointLocations", SR)
     (arcpy.mapping.ListLayers(mxd,
                               "TruePointLocations")[0]).visible = False
     arcpy.SelectLayerByLocation_management("FabricInvestigation\\Points",
                                            "ARE_IDENTICAL_TO",
                                            "TruePointLocations",
                                            selection_type="NEW_SELECTION")
     arcpy.SelectLayerByLocation_management(
         "FabricInvestigation\\Points", selection_type="SWITCH_SELECTION")
     box = pythonaddins.MessageBox(
         "Done selecting points that are in the wrong location. You will not see any selected points if there is a visible scale range set and you are not in that range. Click Yes if you would like to save as a feature class. Click No to return to map.",
         "Finished Process", 4)
     if box == "Yes":
         newFC = pythonaddins.SaveDialog("Save Bad Parcels")
         if newFC != "Cancel":
             arcpy.CopyFeatures_management("FabricInvestigation\\Points",
                                           newFC)
     else:
         pass
     newPath, newLayer = os.path.split(newFC)
     arcpy.mapping.MoveLayer(
         df,
         arcpy.mapping.ListLayers(mxd, "FabricInvestigation")[0],
         arcpy.mapping.ListLayers(mxd, newLayer)[0], "BEFORE")
     Point.checked = False
 def onClick(self):
     # Splits path from user input, creates output path
     saveDataPath = pythonaddins.SaveDialog()
     self.mxd = arcpy.mapping.MapDocument("CURRENT")
     crimeInsetFrame = arcpy.mapping.ListDataFrames(self.mxd,
                                                    "Crime_Inset")[0]
     # Creates a pdf from user input. PDF has control variable of only printing the Crime_Inset.
     arcpy.mapping.ExportToPDF(self.mxd, saveDataPath, crimeInsetFrame)
示例#4
0
 def onClick(self):
     global plik_z_krawedziami
     plik_z_krawedziami = pythonaddins.OpenDialog("Open", False, "")
     global plik_z_werteksami
     plik_z_werteksami = pythonaddins.SaveDialog(
         "Save", "werteksy.shp", "",
         lambda x: x and x.lower().endswith('.shp'), "Shapefile")
     lab1.wczytaj_dane(plik_z_krawedziami, plik_z_werteksami)
     global graf
     graf = lab2.stworz_graf(plik_z_werteksami, plik_z_krawedziami)
     tool1.enabled = True
 def onRectangle(self, rectangle_geometry):
     #save the parameters for the domain
     file_loc = pythonaddins.SaveDialog("Save your file","", "")
     file_loc = os.path.split(file_loc) 
     out_path = file_loc[0]
     out_name = file_loc[1]
     resolution = setRes.text
     #and actually captures the extent used (onRectangle saves rectangle_geometry as an extent object)
     extent = rectangle_geometry
     #create temporary raster, then get unique cell values
     raster = ap.CreateRandomRaster_management(out_path, out_name, "NORMAL", extent, resolution)
     return raster #these rasters should generally 
示例#6
0
 def onLine(self, line_geometry):
     self.line_geometry = line_geometry
     try:
         arcpy.CheckOutExtension('SPATIAL')
     except Exception as e:
         arcpy.AddError('Spatial Extension required.\r\n' + str(e))
     raster_layer = raster_layer_menu.raster_layer
     poly = self.line_geometry
     use_units = meas_units.units
     poly_length = poly.getLength(units='{}'.format(use_units))
     dens_distance = int(poly_length / 400)
     arcpy.env.overwriteOutput = True
     arcpy.CopyFeatures_management(poly, 'in_memory\\Route')
     arcpy.Densify_edit(r'in_memory\Route', 'DISTANCE',
                        str(dens_distance) + ' {}'.format(use_units))
     arcpy.FeatureVerticesToPoints_management('in_memory\\Route',
                                              'in_memory\\poly_feature',
                                              'ALL')
     pts = [
         list(i[0]) for i in arcpy.da.SearchCursor(
             'in_memory\\poly_feature', 'SHAPE@XY')
     ]
     #Derive elevation values from DEM specified.
     arcpy.sa.ExtractMultiValuesToPoints('in_memory\\poly_feature',
                                         [[raster_layer, 'Z']])
     arcpy.CheckInExtension('SPATIAL')
     elev = [
         i[0] for i in arcpy.da.SearchCursor('in_memory\\poly_feature', 'Z')
     ]
     seg_length = int(poly_length / len(elev))
     splits = []
     for i in range(len(elev)):
         splits.append(i * seg_length)
     arcpy.Delete_management('poly_feature')
     #Produce and export elevation profile.
     fig, ax = plt.subplots()
     fig.canvas.set_window_title('Elevation Profile')
     ax.plot(splits, elev, linewidth=2, color='g')
     fig.add_axes(ax)
     plt.xlabel('Feet Along Route')
     plt.ylabel('Elevation')
     try:
         plt.savefig(
             pythonaddins.SaveDialog(
                 'Save Elevation Profile', 'Profile.png',
                 os.path.dirname(
                     arcpy.mapping.MapDocument("CURRENT").filePath)))
     except:
         pythonaddins.MessageBox(
             'Error during save. Click reset and re-run process.', 'Alert')
示例#7
0
 def onClick(self):
     #with open("c:\\log\\genegis-export-srgd.csv", 'w') as f:
     #    f.write("onclick Called! trying to get layer combo value...\n")
     fc = config.selected_layer
     if fc is None:
         msg = "Nothing selected. Please enter a valid layer into the geneGIS selection box."
         title = "Export SRGD: ComboBox value"
         #f.write("writing message box...\n")
         pythonaddins.MessageBox(msg, title)
     else:
         #f.write("have a valid layer selected, %s\n" % fc)
         output_path = pythonaddins.SaveDialog("Output SRGD file name",
                                               "{}.csv".format(fc))
         from scripts import ExportToSRGD
         ExportToSRGD.main(fc, output_path)
示例#8
0
    def onClick(self):
        message1 = "Have you saved a text file report from the Check Fabric tool for the setup fabric?\n\n If yes, click OK and navigate to the location.\n\n If not, click Cancel. Please run the Check Fabric tool by right clicking on the parcel fabric. Next save the report as a text file."
        box1 = pythonaddins.MessageBox(message1, "Find Check Fabric Text File",
                                       1)
        if box1 == 'OK':
            textFile = pythonaddins.OpenDialog("Find Check Fabric Text File")
            #print textFile
            F1 = open(textFile, 'rb')
            parcelId1 = []
            for line in F1:
                if "Parcel with ID =" in line:
                    pID = line[17:-28]
                    parcelId1.append(pID)
            pfl = arcpy.mapping.ListLayers(mxd, "*Parcels")
            for layer in pfl:
                if layer.name == "Tax Parcels":
                    polygons = "FabricInvestigation\\Tax Parcels"
                elif layer.name == "Parcels":
                    polygons = "FabricInvestigation\\Parcels"
                else:
                    # Adding a message box here will cause tool to fail due to
                    # the looping of the layers when it finds layers not
                    # containing the Parcels or Tax Parcels.
                    pass
            for ID in parcelId1:
                if ID == parcelId1[0]:
                    where = '"OBJECTID" =' + str(ID)
                else:
                    where = where + 'OR "OBJECTID" = ' + str(ID)

            arcpy.SelectLayerByAttribute_management(polygons, "NEW_SELECTION",
                                                    where)

            box3 = pythonaddins.MessageBox(
                "Done selecting bad parcels. Click Yes if you would like to save as a feature class. Click No to return to map.",
                "Finished Process", 4)
            if box3 == "Yes":
                newFC = pythonaddins.SaveDialog("Save Bad Parcels")
                if newFC != "Cancel":
                    arcpy.CopyFeatures_management(polygons, newFC)
            else:
                pass
        newPath, newLayer = os.path.split(newFC)
        arcpy.mapping.MoveLayer(
            df,
            arcpy.mapping.ListLayers(mxd, "FabricInvestigation")[0],
            arcpy.mapping.ListLayers(mxd, newLayer)[0], "BEFORE")
        Parcel.checked = False
示例#9
0
 def onClick(self):
     workspace, PFname = os.path.split(parcelFabric)
     ParcelPoints = "FabricInvestigation\\Points"
     DuplicatePointsTable = os.path.join("in_memory",
                                         PFname + "_IdenticalPoints")
     arcpy.FindIdentical_management(ParcelPoints, DuplicatePointsTable,
                                    "X;Y", "#", "0", "ONLY_DUPLICATES")
     arcpy.AddJoin_management(ParcelPoints, "OBJECTID",
                              DuplicatePointsTable, "IN_FID", "KEEP_COMMON")
     saveDuplicates = pythonaddins.SaveDialog("Save Duplicate Points")
     arcpy.CopyFeatures_management(ParcelPoints, saveDuplicates)
     newPath, newLayer = os.path.split(saveDuplicates)
     arcpy.mapping.MoveLayer(
         df,
         arcpy.mapping.ListLayers(mxd, "FabricInvestigation")[0],
         arcpy.mapping.ListLayers(mxd, newLayer)[0], "BEFORE")
     DupPoints.checked = False
示例#10
0
def savePath():
    try:
        path = pa.SaveDialog(msgDict["SaveDialog"], "", "~/")
        if path is None: return None

        # trying to add ".shp" to the end of the path if it is not included
        path = path.strip()
        if path.rfind(".shp") != (len(path) - len(".shp")):
            if path.rfind(".") != (len(path) - 1): path += ".shp"
            else: path += "shp"

        if path.count(".") > 1:
            pa.MessageBox(msgDict["FileNameErr"], "Error")
            return None
        return path

    except Exception as e:
        printErrorMessage(e)
        return None