Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. ExecuteError: Failed to execute. Parameters are not valid.
  2. ERROR 000800: The value is not a member of [list of values]
  3.  
  4. class SetLayer(object):
  5. """Implementation for leetScripts_addin.button2 (Button)"""
  6. def __init__(self):
  7. self.enabled = True
  8. self.checked = False
  9. def onClick(self):
  10. self.a = pythonaddins.GetSelectedCatalogWindowPath()
  11. self.a = self.a.encode('mbcs')
  12. print self.a
  13. self.b = os.path.split((self.a))
  14. self.c = self.b[0]
  15. self.d = os.path.split(self.c)
  16. self.e = (self.b[1]) #feature class
  17. self.f = (self.d[1]) #feature dataset
  18. self.g = (self.d[0]) #workspace
  19. print "Feature class: %r" % self.e
  20. print "Feature dataset: %r" % self.f
  21. print "Workspace: %r" % self.g
  22. connProp = arcpy.Describe(self.g).connectionProperties
  23. self.h = connProp.instance.split(":", 2)
  24. self.k = self.h[2].encode('mbcs') #instanceX
  25. self.i = connProp.database.encode('mbcs') #databaseX
  26. print "Instance is %r" % self.k
  27. print "Database is %r" % self.i
  28. print "Availible Versions:"
  29. self.List = arcpy.da.ListVersions(self.g)
  30. self.nameList = []
  31. for version in self.List:
  32. self.nameList.append(version.name)
  33.  
  34. print self.nameList
  35. print "Tool finished"
  36. pass
  37.  
  38. #working on editing this to provide dropdown
  39. class setVersion(object):
  40. """Implementation for leetScripts_addin.combobox2 (ComboBox)"""
  41. def __init__(self):
  42. self.editable = True
  43. self.enabled = True
  44. self.width = 'WWWWWW'*3
  45. self.dropdownWidth = 'WWWWW'*3
  46. def onEnter(self):
  47. self.items = button2.nameList
  48. def onSelChange(self, selection):
  49. #self.items.append(button2.nameList)
  50. self.version = selection#change this
  51. print self.version
  52. pass
  53.  
  54. if sde != -1 and desc.isVersioned:
  55.  
  56. #Check to see if this connection file exists
  57. path = r"U:tempStuffactualName.sde"
  58. if not os.path.isfile(path):
  59. #Creates connection file if it doesn't already exist
  60. os.makedirs(r"U:tempStuff")
  61. outFolderPath = r"U:tempStuff"
  62. outName = r"actualName.sde"
  63. databasePlatform = "SQL_Server"
  64. instance = button2.k
  65. database = button2.i
  66. username = "username"
  67. password = "password"
  68. version = combobox2.version
  69. #Make sure you change between OPERATING_SYSTEM_AUTH and DATABASE_AUTH
  70. arcpy.CreateDatabaseConnection_management(outFolderPath, outName,
  71. databasePlatform,
  72. instance,
  73. 'OPERATING_SYSTEM_AUTH',
  74. username, password,
  75. 'DO_NOT_SAVE_USERNAME',
  76. database,
  77. '','TRANSACTIONAL',
  78. version,'')
  79.  
  80. workspace = r"U:tempStuffactualName.sde"#change to current workspace
  81. fc = os.path.join(workspace, featureDataset, fcName)
  82. print workspace
  83. print "Feature class is %r" % fc
  84. #Start editing
  85. print "initiating editing"
  86. arcpy.ChangeVersion_management(fcName, "TRANSACTIONAL",
  87. combobox2.version, '')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement