I used python add in to make a tool bar in Arcmap that edits features on a map. It works on a file geodatabase, but not on an ArcSDE version one. I've been getting an FDO error: 0. The solutions that I've found all involve opening a workspace, but I'm getting an error doing that as well. Here is the relevant portion of my code:
outFolderPath = r"U:\tempStuff"
outName = "Stuff.sde"
databasePlatform = "SQL_Server"
instance = "SQL Server"
arcpy.CreateDatabaseConnection_management(outFolderPath, outName,
databasePlatform,
instance)
print "Centroid of buidling:(%r,%r) Side length: %r" % (xCoordinate,
yCoordinate,
bob)
print "workspace is %r" % outName #outName is workspace
#Start edit session with an undo/redo stack then start
#edit operation
print "Starting editing"
edit = arcpy.da.Editor(outName) #outName is workspace Line 86
edit.startEditing(True, True)
edit.startOperation()
#stuff happens
cursor = arcpy.da.InsertCursor( fc, ["SHAPE@"])
cursor.insertRow([stuff])
#stop the edit operation and then save changes
edit.stopOperation()
edit.stopEditing(True)
del cursor
print "Building should be drawn"
This is the exact error I've been getting:
Traceback (most recent call last):
File "C:\Users\153289\AppData\Local\ESRI\Desktop10.3\AssemblyCache\{0BEF4E61-6332-4BCA-A908-959CA3C0B4E7}\leetScripts_addin.py", line 86, in onClick
edit = arcpy.da.Editor(outName)#outName is workspace
RuntimeError: cannot open workspace
What's am I doing wrong in my code?
Answer
Looks like you are not referencing the full path to your newly created SDE connection. Try this:
edit = arcpy.da.Editor(os.path.join(outFolderPath, outName))
No comments:
Post a Comment