POST
|
Hello, I am new to using attribute assistant and need some help. I need to be able to populate a field on the fly called Total Activations (field name TotalActivations) based on Activation1, Activation2, Activation3, Activation4, Activation5, and Activation6. I can create a script in Python to do this, but not sure how to do it in Attribute Assistant. The reason why i would like to use Attribute Assistant is so that an user does not have to run a script tool every time an update is made. Here is what my table looks like: If the value is 'Yes' in any of the activation numbered fields, that takes the value of 1, any 'No' or <Null> values takes a value of 0. So the first line item would total 1. My python script is the following: import arcpy
poles = 'Test2'
fieldList = ("Activation1", "Activation2", "Activation3", "Activation4", "Activation5", "Activation6", "TotalActivations")
with arcpy.da.UpdateCursor(poles, fieldList) as cursor:
for row in cursor:
n = 0
if row[0] == 'Yes':
a = 1
elif row[0] == 'No' or row[0] is None:
a = 0
if row[1] == 'Yes':
b = 1
elif row[1] == 'No' or row[1] is None:
b = 0
if row[2] == 'Yes':
c = 1
elif row[2] == 'No' or row[2] is None:
c = 0
if row[3] == 'Yes':
d = 1
elif row[3] == 'No' or row[3] is None:
d = 0
if row[4] == 'Yes':
e = 1
elif row[4] == 'No' or row[4] is None:
e = 0
if row[5] == 'Yes':
f = 1
elif row[5] == 'No' or row[5] is None:
f = 0
n = a + b + c + d + e + f
row[6] = n
cursor.updateRow(row)
How do I translate this into Attribute Assistant?
... View more
04-25-2019
06:33 AM
|
0
|
1
|
657
|
POST
|
Hi Dan, I've updated my post with a view of my table that I am using for testing with some further steps as to what I had in mind. My current method I can script out using python but I was hoping to find a faster method if possible. I will try your way out in the mean time. Thank you!
... View more
04-08-2019
07:20 AM
|
0
|
1
|
3092
|
POST
|
Hi Joshua, I've updated my post with a screenshot of the table I have for testing.
... View more
04-08-2019
07:19 AM
|
0
|
0
|
3092
|
POST
|
Currently I'm using SUMIFs in Excel to calculate some values in a spreadsheet and then having to make the updates manually in my attribute tables or reloading all of my data into the feature class. Is there a way to do SUMIFs using Python in ArcMap? One method I came up with was using Summary Statistics. For my current workflow, I'd need to do it three different times and then either join the tables or use cursors to populate the information. I need to get the sum of a field based on the address for another field's values. Another calculation is a max value based on address for another field, and then lastly need a count for an address for another field. My original thought process was to create a basic python tool using arcpy.Statistics_analysis (Summary Statistics) where my sum fields would be [[EquipmentCount, SUM], [EquipmentLocation, MAX], [Address, COUNT]] and my case field would be Address. The output would ideally be In Memory where I can use search cursor to build a dictionary where Address is my Key and the rest of the values would be the values. Using Update Cursor, I would populate the TotalCount field (using value of EquipmentCount - SUM), UniqueCount field (using EquipmentLocation - MAX), and Cutomers field (using Address - COUNT). However I am trying to find another way to do this without having to go down the summary statistics route. I was hoping to use Field Calculator if possible or another alternative. I do not have any experience using the Pro-Logic in Field Calculators or numpy for that matter.
... View more
04-05-2019
01:23 PM
|
0
|
5
|
6030
|
POST
|
Are you referring which parameter the user would need to fill in first? If so, it wouldn't matter. Every parameter would have their own values and the user can enter in any order they'd like. Unless that isn't an option?
... View more
09-19-2018
12:35 PM
|
0
|
0
|
966
|
POST
|
The Project ID would be unique, but I'm not going for making a selection based on an unique entry. When the user opens the tool, I'd want them to have blank parameters and when they hit any drop down menu, it'll give them all of the entries within the table for the associated column. This is so that the user does not have to go in order to drill down or anything. Hopefully that made a bit more sense. Sometimes the user won't have the information for one of the parameters and so with that, they'd have to leave that parameter blank.
... View more
09-19-2018
11:22 AM
|
0
|
2
|
966
|
POST
|
Randy, While the drill selection would be nice, ideally, I'd like to provide all options in the column. So even if you select Type 1 in Document Type, the user would still get Company 1-4 in Document Company. The catch is this, this table will grow and there will be several entries that are the same in some fields. Can they be summed up in the validation of the script tool and then presented in the drop down menu?
... View more
09-19-2018
10:34 AM
|
0
|
4
|
966
|
POST
|
The Document Creation Date would be left blank for the user to input the date that can be found on the document they have. I don't think they'd have a selection. The idea is to point each parameter to a field in the table. So with Document Type parameter pointing to the AsBuildType field, when the user hit's the drop down menu, they'd be presented with the options of Type 1, Type 2, and Type 3. That's because those are the only options. But say the table has over a 1,000 entries with a total of 5 different types. That's pretty easy to manage. AsBuiltCompany could be in the 100s for an option. I'd like for the drop down list for Document Company to auto populate with the values within the AsBuiltCompany field. Once all the parameters are entered and the user hits Ok, these will populate the appropriate fields within each feature class (10 to be exact right now, may grow). Hopefully that helped clarify any confusions or questions you may have had.
... View more
09-14-2018
12:52 PM
|
0
|
0
|
3201
|
POST
|
Randy, I do like how you actually used the Selection field to auto populate the other 4 parameters. Using that logic, do those 4 parameters have to be visible then? I would assume that if they get auto populated from a table, then that should be the correct input and the user wouldn't have to make any corrections. So something like this User selects One in the Selection parameter and then the other 4 parameters (not visible to the user), get populated with A1, A2, A3, and A4 respectively? And then used in the script tool. As for my workflow that I originally intended for, there would only be 4 parameters. So the tool window will look like this: Then there would be the following table in the database: The idea is to get the tool (using validation) to link the table and the 3 fields (AsBuiltType, AsBuilt Company, and ConstCompany; AsBuiltDate will be a manual entry) to be linked to Document Type, Document Company, and Construction Company. So this is the order they'd be paired (field name - Parameter): AsBuiltType - Document Type, AsBuiltCompany - Document Company, and ConstCompany - Construction Company. The idea is that the drop down menu (value list) will get populated with the values in that field. This is so that when a new company's name is added to the table, the drop down menu doesn't have to be manually updated, it'll get auto populated through tool validation. Is this possible? Just a disclaimer, I have never worked with tool validation so I'm new to it and any insight is greatly appreciated.
... View more
09-14-2018
10:21 AM
|
0
|
0
|
3201
|
POST
|
The error that I get is that in line 14, the attribute column is not found. I'm assuming because there is no field with that name. What would I substitute 'Selection' out with?
... View more
09-12-2018
12:04 PM
|
0
|
0
|
3201
|
POST
|
Hi Randy, I tried to mimic your code but added in my field names in the def updateParameters(self): portion of the script but got an error. The field names in the table that I was to use are AsBuiltSource, AsBuiltCompany, and ConstructionCompany. The other field I need to update is a date field and thus do not need to include that bit in the Validation. As for how the parameters are laid out in my script, they are in this order: AsBuiltSource, AsBuiltCompany, AsBuiltDate, and ConstructionCompany. How would you set this up in the validation? Sorry about the delay in responding, I was out on vacation for a good bit and then swamped with some work.
... View more
09-12-2018
12:02 PM
|
0
|
1
|
3201
|
POST
|
Hello, I am working on putting together a custom tool that helps populate information into four fields within each feature class in the database. The script is pretty straight forward and has no issues. My issue is I have to create 22 tools to do the same thing by each feature class and creating a value list in the parameters section of the script tool would be too cumbersome. Is it possible to have one table that can be automatically pulled right into a drop-down and the only thing I'd have to do is update that table whenever it needs to be updated?
... View more
07-26-2018
09:12 AM
|
1
|
16
|
5244
|
POST
|
What exactly seems to be your problem? Post the script here and what your script tool parameters look like.
... View more
07-26-2018
09:07 AM
|
0
|
0
|
1447
|
POST
|
Ah...I get where you were coming from. For the code snippets, here is the overall picture: for hub in hubDict:
valueHub = dict.get(hubDict, hub)
hubQuery = "HubName = " + "'" + str(valueHub) + "'"
nodeQuery = "ProjectHub = " + "'" + str(valueHub) + "'"
hubLayer.definitionQuery = hubQuery
nodeLayer.definitionQuery = nodeQuery
if hubDict[0]:
in_rows = 'table'
out_path = folderPath + '/' + 'Results.gdb'
out_name = 'Results'
arcpy.TableToTable_conversion(in_rows, out_path, out_name)
else:
inputs = 'table'
target = folderPath + '/' + 'Results.gdb' + '/' + 'Results'
arcpy.Append_management(inputs, target, "NO_TEST")
I've never worked with dict.iteritems() or next(). How would you put that together with the code snippet I have?
... View more
05-16-2018
07:39 AM
|
0
|
2
|
530
|
Title | Kudos | Posted |
---|---|---|
1 | 07-26-2018 09:12 AM | |
1 | 07-18-2017 01:12 PM | |
1 | 03-09-2017 09:57 AM | |
2 | 03-22-2018 09:49 AM | |
1 | 09-19-2017 01:18 PM |