Copying exact record in another feature class while creating the record in a feature class using ArcPy....

2769
12
10-15-2020 06:23 PM
ShahriarRahman
New Contributor III

Hi All,

I am trying to create a feature in a feature class, and want to automate the same record creation at the same time in another feature class using ArcPy scripting. Is there any way to do it? I can do it manually using "Paste Special", but it does not help when you have thousands of records. Great to have your expert suggestion. Please share any sample (Python or Arcade) script if you have faced this challenge, and solved it. Thank you in advance.

0 Kudos
12 Replies
XanderBakker
Esri Esteemed Contributor

Hi Shahriar Rahman ,

If the process is that you have another source featureclass and you need to append it to two output featureclasses, you can simply use modelbuilder and append the single source featureclass to the two output featureclasses and use it in a single tool. 

If you update featureclass one by manual editing and want the changes to be reflected in the Roads_All, this would require the new features to be identified and add the selection to the Roads_All featureclass. In case you also want to account for updates of deletes of existing features and have those changes reflected in the Roads_All featureclass, it will become more complicated. 

ShahriarRahman
New Contributor III

Hi @XanderBakker ,

I have come up with a solution to the task I wanted to accomplish, but the script is taking around 5 minutes to do perform the task(s). I need to minimise the time of processing, great to have your expert suggestion if I can reduce the processing time,

......................................................................

for m in aprx.listMaps():
    for layer in aprx.activeMap.listLayers():
        if(layer.name[0:12]=="CGD.PARCELS_" and layer.getSelectionSet()):
           arcpy.management.Append(layer, "BASEDATA", "NO_TEST")
           arcpy.SelectLayerByLocation_management("BASEDATA","ARE_IDENTICAL_TO",layer)

........................................................................

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @ShahriarRahman ,

 

The first thing I see, is the outer loop where you loop through each map in your project (how many do you have) and for each map take the same active map.

I keep thinking that the cleanest solution would be to use an attribute rule that is triggered when a new feature is inserted and copies it to the other featureclass. However, you should also take care of any deletes and updates so that these changes are reflected in the other featureclass.

0 Kudos