When using the Distributed Database Tool Bar to create a Check Out replica, you are given the option to specify the extent of the data you have chosen to replicate. In the on line help (Create Replica—Help | ArcGIS Desktop ) it gives an indication that you can provide an extent as well:
Following the online help as a template, I have created a python script to create a check out replica. I'm developing it with just one feature class in the mxd, (the parent data) and I zoom to an area of interest to create a replica of just a few features.
However, if I include the parent geometry as the extent argument, no resulting feature class replica is created but the script runs just fine, no errors. If I leave that argument off, a resulting feature class and replica are created; only problem is it's the entire feature class which is not what I want.
Here is the code from on line help (formatted as python):
in_data = "Parks" # a feature dataset replica_type = "ONE_WAY_REPLICA" output_workspace = "C:\Data\MyTargetGDB.gdb" replica_name = "MyReplica" access_type = "FULL" initial_sender = "PARENT_DATA_SENDER" expand = "USE_DEFAULTS" reuse_schema = "DO_NOT_REUSE" get_related = "GET_RELATED" replica_geometry = "LA_County" archiving = "DO_NOT_USE_ARCHIVING" # Execute CreateReplica arcpy.CreateReplica_management(in_data, replica_type, output_workspace, replica_name, access_type, initial_sender, expand, reuse_schema, get_related, replica_geometry, archiving)
I don't set the archiving variable so mine is slightly different; I also create a directory and subsequent fileg dbd to write the replica feature class to. The idea here is once the edits are complete, a second script will fire off, syncing the replica back to the parent (and thus getting rid of the the replica itself) and then remove the directory and file gdb to be re-created next time:
path = r"C:\temp" os.mkdir(path) ### new directory will be deleted later arcpy.CreateFileGDB_management(path,"Replicas.gdb") ### new child geodatabase; gets deleted later... output_workspace = r"C:\temp\Replicas.gdb" in_data = "slcogis.GDB_ADD.MasterStreetNameFC" #sde point feature class replica_type = "CHECK_OUT" replica_name = "MyReplica" access_type = "FULL" initial_sender = "PARENT_DATA_SENDER" expand = "USE_DEFAULTS" reuse_schema = "DO_NOT_REUSE" get_related = "GET_RELATED" replica_geometry = "slcogis.GDB_ADD.MasterStreetNameFC" ### this is the parent, but zoomed in.... arcpy.CreateReplica_management(in_data, replica_type, output_workspace, replica_name, access_type, initial_sender, expand, reuse_schema, get_related,replica_geometry)
This is actually a script that an ArcPY addin will control with a button click, as will the the one that checks in the child and subsequently deletes the workspace. I'm not sure (and neither are any of my colleagues) why it's not honoring the preferred extent.
I came up with a solution for this: using an idea from jskinner-esristaff posted a few years ago (https://community.esri.com/message/226898?commentID=226898#comment-226898 ) I create an in_memory polygon feature based on the extent of (the zoomed in) view of my mxd. Big fun!
(Once again, thanks Jake!)