Reading field values and editing field values

770
7
06-17-2021 01:37 PM
BensonColeC
New Contributor

I'm trying to read the data from one field and use it to perform calculations in order to find the data for another field. I know how to change the data of a field using the inspector tool, but how would I make that data based off of the calculations of another field.

For example, if I wanted to have Field3 = (Field1+ Field2) / 2.

0 Kudos
7 Replies
RichRuh
Esri Regular Contributor

Hello,

You might want to take a look at attribute rules.  While not part of the Pro SDK, attribute rules run Arcade scripts when edits take place.  You can assign a calculation rule to Field3 that computes the value of (Field1 + Field2)/2 just as you have written above.

I hope this helps,

--Rich

0 Kudos
BensonColeC
New Contributor

I don't think that will work because I need to do it as part of an add-in that uses lots if if-else statements. The add-in will take input data and then read certain fields and calculate another field based on the field it reads and the input data.

0 Kudos
RichRuh
Esri Regular Contributor

OK, you'd have to do it manually then.  Read the values of Field1 and Field2, do the calculation and then write out the result to Field3.

0 Kudos
BensonColeC
New Contributor

What would be the best way to do this for thousands of rows. I tried using a table search and using while(rowCursor.MoveNext()) and I read and updated within the while loop, but this took about 15 minutes to run. How could I do this faster?

0 Kudos
RichRuh
Esri Regular Contributor

The Calculate Fields geoprocessing tool is the fastest way to mass update data. We are planning on adding faster update cursors to the C# SDK in a future release of Pro.

0 Kudos
BensonColeC
New Contributor

Is there a way to use the Calculate Field geoprocessing tool through my C# script? I've tried to look for a way but don't see anything about it.

0 Kudos
RichRuh
Esri Regular Contributor
0 Kudos