0

I am looking to change versions of an .sde through Arcpy to then afterwards, run a few geoprocesses on it. I do not want it to automatically update after that.

So far I have managed to create a version through ArcPy, but I can't for the life of me figure out how to connect to it. The "Changeversion_management" only does this on 1 feature class and keeps throwing me errors such as the following:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Feature Layer or Table View: Dataset [email protected] does not exist or is not supported
Failed to execute (ChangeVersion).

And

ERROR 000800: The value is not a member of ZN_KGD.ExPimp_p9 | ZN_KGD.Tool_test
Failed to execute (ChangeVersion).

I would like to change the version of all the feature classes in the TOC, or at least connected to the same .sde. The script I am using to create and change the version is the following:

import arcpy

Project_number = arcpy.GetParameterAsText(0)

inWorkspace = "C:/Users/Lansr/AppData/Roaming/ESRI/Desktop10.3/ArcCatalog/[email protected]"
parentVersion = "ZN_KGD_DIENSTVERSIE"

# Execute CreateVersion
arcpy.CreateVersion_management(inWorkspace, parentVersion, "ExPimp_{}".format(Project_number), "PUBLIC")

arcpy.ChangeVersion_management('ZN_KGD.ZN_KGD_DIENSTVERSIE',
                               'TRANSACTIONAL',
                               "ExPimp_{}".format(Project_number),
                               '')

The feature layer and sde are not defined in the script, but are purely in the TOC.

It is important to note that the top error happens when I fill in the name of the .sde and the bottom error happens when I fill in the name of a feature layer. My knowledge of ArcPy is limited at best. I am using ArcGIS 10.3.1.

2
  • Please edit your code to show where you create your version and also how Deklaag_vlakken and [email protected] are defined.
    – Andy
    Commented Feb 26, 2019 at 15:32
  • My apologies, I have editted the question, hopefully this is enough information.
    – Remko
    Commented Feb 27, 2019 at 7:16

1 Answer 1

0

I have worked around this by doing the following:

import arcpy
import arcpy.mapping

Project_number = arcpy.GetParameterAsText(0)

arcpy.env.overwriteOutput = True
inWorkspace = "C:/Users/Lansr/AppData/Roaming/ESRI/Desktop10.3/ArcCatalog/[email protected]"
parentVersion = "ZN_KGD_DIENSTVERSIE"

# Execute CreateVersion
arcpy.CreateVersion_management(inWorkspace, parentVersion, "ExPimp_{}".format(Project_number), "PUBLIC")

mxd = arcpy.mapping.MapDocument("G:\\zn\\NM\\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\{}.mxd".format(Project_number, Project_number))  # Uses your currently open MXD
for df in arcpy.mapping.ListDataFrames(mxd, ''): # Loop through dataframes
    for lyr in arcpy.mapping.ListLayers(mxd, '', df): # Loop through layers


        arcpy.ChangeVersion_management  (lyr.name,
                                        "TRANSACTIONAL",
                                        "ZN_KGD.ExPimp_{}".format(Project_number),
                                        '')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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