Error using select and copyfeatures from SDE to personal geodatabase

437
3
08-29-2012 08:09 AM
JeremyLuymes
New Contributor III
Hi,

I get the following error message:

<class 'arcgisscripting.ExecuteError'>: ERROR 000210: Cannot create output WAT_ControlValve
Failed to execute (Select)

The same thing happens when I try using copy features.

I'm trying to copy a selection from the SDE to a new personal geodatabase I created if there is a selection. I didn't include all the code but wtrue is a list of layers I want to check to copy over. I have checked and the script correctly creates the pgdb.

Is this a projection issue or some other environment setting problem?

if extype == "Personal Geodatabase":
    try:
        gp.CreatePersonalGDB(outfolder,gdbname)
    except:
        pass
    gp.WorkSpace = outfolder + os.sep + gdbname
    gp.addmessage(gp.Workspace)
elif extype == "Shapefiles":
    gp.Workspace = outfolder

for layer in wtrue:
    gp.makefeaturelayer(layer,"layer")
    selcount = int(gp.GetCount_management("layer").getoutput(0))
    totcount = int(gp.GetCount_management(gp.describe("layer").catalogpath).getoutput(0))
    if totcount <> selcount:
        gp.addmessage(layer + " has " + str(selcount) + " features selected")
        gp.select("layer",layer)
    else:
        gp.addmessage(layer + " has no selection")
Tags (2)
0 Kudos
3 Replies
ChristopherThompson
Occasional Contributor III
Perhaps I'm missing something, but I don't see the code you are using to actually copy features into the PGDB you create.  I see where you create the PGDB, and where you check to see if there is a selection on a given layer, but not the code that copies from one place to another.  Can you show that bit?
0 Kudos
JeremyLuymes
New Contributor III
It would the gp.select line. Since I set the workspace, it should select them and copy the features into the pgdb.

I have tried gp.copyfeatures as well, and tried changing the output (ie. using the actual path to the pgdb, but I still can't get it to work)

The script always fails at the select.
0 Kudos
ChristopherThompson
Occasional Contributor III
ah, are you at a version older than 10.0?  I'm not familiar with gp.select but is this what you are looking for?
SelectData_management (in_dataelement, out_dataelement)
see http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Select%20Data%20(Data%20Management) for more information, but if that is the tool you are intending to use, the help says its not for use in scripting.  I honestly think this tool is only for selecting data (and within the context of modelbuilder) but it doesn't actually "do" anything with them.

I think what you are wanting to use in any case are the tools intended to copy things from one to another place, that could be any one of the following I think:

  • FeatureclassToFeatureclass_conversion (in_Features, out_path, out_name, where_clause, field_mapping, config_keyword)

  • FeatureClassToGeodatabase_conversion <Input_Feature_class; Input_Feature_class...> <Output_Geodatabase>

  • CopyFeatures_management <in_features> <out_feature_class> {config_keyword} {spatial_grid_1} {spatial_grid_2} {spatial_grid_3}

The first and last of those are probably more what you are looking for rather than the 2nd which i think is dealing with feature classes on-disk rather than features in a layer.
0 Kudos