2

I am trying to find a more efficient way to select features from a polygon feature class and copy over their GUIDs to a separate table in ArcMap. I have a layer of pavement polygons and I would like to select all the sections of pavement that are receiving maintenance treatment, and then copy over their values into another separate table. The separate table has a 1-Many relationship with the pavement polygon layer.

Is there a tool in ArcMap or a scripting option to achieve this?

Here is a visual representation of my problem: enter image description here

These are the selected polygon features and their attribute table. I want to copy the GUID values over to this table: enter image description here

Note how this allows there to be a 1 Pavement Polygon to Many treatment records in the table possible. Right now I just do them one by one, but I was hoping for another solution where I could copy/paste over many polygon GUIDS into the table at the same time.

  • For scripting help we will need you to include a code snippet of your effort so far so perhaps you should exhaust looking for a tool first. – PolyGeo Nov 2 '16 at 21:32
  • Understood. I am working on a script right now. Haven't been able to find a tool yet. Wondering if anyone else has achieved this. – cbunn Nov 2 '16 at 22:21
  • What I think is unclear in your question is how you can achieve a 1-many between a polygon attribute table and the separate table when you are copying one field (GUID) from that polygon attribute table to create the separate table. I think you should include a picture of some sample feature attributes and table rows. – PolyGeo Nov 2 '16 at 22:50
  • 1
    It sounds like you simply need to [relate][ desktop.arcgis.com/en/arcmap/10.3/manage-data/tables/… – fatih_dur Nov 2 '16 at 23:20
  • This link is broken. I don't understand, I have a relationship established at the geodatabase level. – cbunn Nov 3 '16 at 13:34
2

Using two cursors should accomplish what you want. You should be able to do your selection and run something like this in arc map python console:

with arcpy.da.SearchCursor(pavementPolys, ['GUID']) as pavement:
  with arcpy.da.InsertCursor(treatmentTable, ['GUID']) as treatments:
    for street in pavement:
      treatments.insertRow([street[0]])

This will insert a single new treatment row with that GUID for each selected pavement feature. If you've got a list of treatments elsewhere, you could work that into the code too to insert multiple rows representing multiple treatments done on a single pavement feature. Or you could make this into a toolbox script that will accept a selection and a treatment, and have it insert the treatment value into the table for each row. This would give you a more interactive way to approach the problem.

  • I think this is running but nothing prints when it succeeds. It seems to be just continuously running. No error appears and the new record doesn't appear yet in my Treatments Table. – cbunn Nov 4 '16 at 15:32
  • You can add print statements to the skeleton code above if you want a more verbose representation of what it's doing (eg: print each row it inserts, print when it finished, etc.), otherwise you can tell it's done running when the triple arrow (>>>) comes back to the beginning of the line on your console. Make sure you replace the table and field names with your own tables/fields. If you have the table open while it runs, you need to close and reopen before your new rows will be visible. – roms Nov 4 '16 at 18:39
  • When I run this code it never finishes running. The >>> never reappear. I have a pavement polygon selected and I am using my correct table/field names. The feature classes are on SDE if that affects it somehow. Still though this code does not work for me. – cbunn Nov 7 '16 at 23:48
1

It looks like the Production Mapping Toolbar would be able to do this. Unfortunately it is not free or cheap. http://desktop.arcgis.com/en/arcmap/10.3/guide-books/extensions/production-mapping/adding-a-related-table-record.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.