POST
|
I am trying to using this in a Calculate Value tool. I am still seeing the datasets in there with Pro and I do see a bunch of files in the FGDB through Windows explorer. The odd thing that I noticed is if I select the Calculate Value Tool in the Model Builder View window, right click and select run, its runs fine, everything gets deleted. If I right click on the Scheduled Model with this Calculate Value Tool in the Scheduled Tools window and selecting run, I get a warning that, "PI_Taxp" already exists in the C:/Temp/BoardPI.gdb". So it's not being deleted. So it appears that if it's scheduled in a Pro project, it doesn't run...?
... View more
01-19-2023
12:42 PM
|
0
|
1
|
700
|
POST
|
I am trying to delete all feature classes, tables and datasets from a file database and the issue is sometimes it works and sometimes it doesn't. I trying the following but none of them works consistently. My thought is that, os.path.exists would be more reliable. import arcpy, os
def deletePI():
try:
arcpy.env.workspace = "C:/Temp/DashboardPI.gdb"
fc_list = arcpy.ListFeatureClasses()
tables = arcpy.ListTables()
ds_list = arcpy.ListDatasets()
#feature classes
for fc in fc_list:
arcpy.Delete_management(fc)
#tables
for table in tables:
arcpy.Delete_management(table)
#data sets
for ds in ds_list:
arcpy.Delete_management(ds)
except:
pass import arcpy, os
def deletePI():
try:
arcpy.env.workspace = "C:/Temp/DashboardPI.gdb"
if os.path.exists("C:/Temp/BoardPI.gdb/PI_Taxp") == True:
arcpy.Delete_management(r"C:/Temp/boardPI.gdb/PI_Taxp")
... View more
01-19-2023
09:48 AM
|
0
|
9
|
712
|
POST
|
The ValDict and the where do have values, I was just trying to post quickly and didn't include them. I did try the exception as e: but no message gets printed.
... View more
01-06-2023
12:57 PM
|
0
|
0
|
498
|
POST
|
I am trying the following but I only get 25 in the progress field on features that have something in "Field5". It seems to stop if it encounters a blank record in Field5. What am i doing wrong? valDict{}
with arcpy.da.UpdateCursor(table2, ["OBJECTID","Field1","Field2","Field3","Field4","Field5","Field6", "Field7", "Field8","Progress"],
where) as cursor:
for row in cursor:
try:
if row[5] is None: #if row[5] not in (None, "", " "):
continue
if row[5] in list1:
print ("{} is in list".format(row[0]))
row[9] = valDict.get(row[5]) if row[6] == "Pass" else valDict.get(row[5], 25) - 25
cursor.updateRow(row)
except:
continue
... View more
01-06-2023
12:15 PM
|
0
|
5
|
526
|
POST
|
Jeffk, I was trying to impalement your suggestion but I am having trouble getting the code to work. Hopefully I can explain it correctly, I would really appreciate the help to understand dictionaries in this type of situations. If reviews 1-4 equal approved then, progress filed = 15%, if three out of the four review are pass then Progress field = 0% If Reviews1-4 fields = Approved & Event field = Foundation or Setback or Shear Panel 1 & EventRes1 field = Pass, then Progress field = 15%, if if Reviews1-4 = Approved & Event field = Foundation or Setback or Shear Panel 1 & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress field = 15% if If Reviews1-4 fields = Approved & Event field = Framing or BC- Framing & EventRes1 field = Pass, then Progress field = 50%, if If Reviews1-4 fields = Approved & Event field = Framing or BC- Framing & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 25% if If Reviews1-4 fields = Approved & Event field = Insulation or Stucco & EventRes1 field = Pass, then Progress field = 75%, if If Reviews1-4 fields = Approved & Event field = Insulation & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 50% if If Reviews1-4 fields = Approved & Event field = Final & EventRes1 field = Pass, then Progress field = 100%, if If Reviews1-4 fields = Approved & Event field = Final & EventRes1 field = Needs corrections or In progress or partial Pass or Cancelled, then progress, then progress field = 75% If both fields "Certif", "CertifDate" are populated , then Progress = 100% Some fields are blank.
... View more
01-04-2023
03:07 PM
|
0
|
2
|
904
|
POST
|
Interesting, I will have to try to use the dictionary option.
... View more
12-12-2022
09:27 AM
|
0
|
0
|
958
|
POST
|
Thank you for the visual of formatting the if, elf and else. Line 24 would just be "Pass", so i can continue.
... View more
12-12-2022
09:25 AM
|
0
|
0
|
958
|
POST
|
I have a table that I need to do multiple nested if else it appears that only the last if else is used and field only gets populated with 15, there are some that meet the 25,35 and 45 but they don't get updated. what am I doing wrong? where = "AppType = 'SFR Active'"
with arcpy.da.UpdateCursor(table1, ["Field1","Field12","Field3","Field4","Field5", "Field6", "Field7","Field8"], where) as cursor:
for row in cursor:
#if row[0] is None:
#continue
if row[0] == "Approved" and row[1] == "Approved" and row[2] == "Approved" and row[3] is not None and row[4] == "Pass":
row[7] = 15
else:
row[7] = 0
if row[3] == "In_1" and row[4] == "Pass":
row[7] = 25
else:
row[7] = 15
if row[3] == "In_2" and row[4] == "Pass":
row[7] = 35
else:
row[7] = 25
if row[3] == "In_3" and row[4] == "Pass":
row[7] = 45
else:
row[7] = 35
cursor.updateRow(row)
... View more
12-09-2022
03:01 PM
|
0
|
9
|
1083
|
POST
|
I have had this issue with almost every model I have created and "tried" to schedule. I have done what you stated multiple times, over and over and still some scheduled models don't work. In my opinion Pro is so JUNKY it has so much flaws. Its hard to get any work done.
... View more
10-27-2022
11:37 AM
|
1
|
0
|
923
|
POST
|
Trying to delete feature classes by name if they exist.
... View more
10-25-2022
09:26 AM
|
0
|
0
|
452
|
POST
|
That is what I figured. So if I had to do this in model builder how would I go about it? I've tried creating a model using a "If data Exists" and Iterate Feature class but was unsuccessful.
... View more
10-25-2022
09:26 AM
|
0
|
0
|
452
|
POST
|
I have a SDE feature data set with certain feature class I need to delete. I need to be able to delete them by name, because there are other feature class in there that I do not need to delete. I have the following, it runs but it doesn't delete anything. I get no error either. I am using this in a Calculate Value model. Expression FEMA1() Code block import arcpy, os
def FEMA1():
arcpy.env.workspace = r"C:/Users/***/AppData/Roaming/Esri/ArcGISPro/Favorites/***.sde/CCDS.CCDS.TempLyrs"
cws = arcpy.env.workspace
fc_Delete = ["CCDS.CCDS.FEMA_FLOOD_ZONES_Temp","CCDS.CCDS.FLOODWAY_Temp","CCDS.CCDS.LOMAs_Temp","CCDS.CCDS.LOMRs_Temp","CCDS.CCDS.FEMA_Cross_Sections_Temp","CCDS.CCDS.FEMA_Base_Flood_Elevations_Temp", "CCDS.CCDS.FEMA_PANELS_Temp"]
for fc in fc_Delete:
fc_path = os.path.join(cws, fc)
if arcpy.Exists(fc_path):
arcpy.Delete_management(fc_path)
else:
return ("Feature classes do not exist")
... View more
10-21-2022
10:30 AM
|
0
|
8
|
536
|
Title | Kudos | Posted |
---|---|---|
1 | 10-27-2022 11:37 AM | |
1 | 10-31-2023 10:16 AM | |
1 | 02-16-2023 01:50 PM | |
1 | 08-11-2021 11:13 AM | |
1 | 01-06-2021 10:45 AM |
Online Status |
Offline
|
Date Last Visited |
01-23-2024
11:04 AM
|