Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SetLayer(object):
- """Implementation for leetScripts_addin.button2 (Button)"""
- def __init__(self):
- self.enabled = True
- self.checked = False
- def onClick(self):
- self.a = pythonaddins.GetSelectedCatalogWindowPath()
- self.a = self.a.encode('mbcs')
- print self.a
- self.b = os.path.split((self.a))
- self.c = self.b[0]
- self.d = os.path.split(self.c)
- self.e = (self.b[1]) #feature class
- self.f = (self.d[1]) #feature dataset
- self.g = (self.d[0]) #workspace
- print "Feature class: %r" % self.e
- print "Feature dataset: %r" % self.f
- print "Workspace: %r" % self.g
- connProp = arcpy.Describe(self.g).connectionProperties
- self.h = connProp.instance.split(":", 2)
- self.k = self.h[2].encode('mbcs') #instanceX
- self.i = connProp.database.encode('mbcs') #databaseX
- print "Instance is %r" % self.k
- print "Database is %r" % self.i
- print "Availible Versions:"
- self.List = arcpy.da.ListVersions(self.g)
- self.nameList = []
- for version in self.List:
- self.nameList.append(version.name)
- print self.nameList
- print "Tool finished"
- pass
- #working on editing this to provide dropdown
- class setVersion(object):
- """Implementation for leetScripts_addin.combobox2 (ComboBox)"""
- def __init__(self):
- self.editable = True
- self.enabled = True
- self.width = 'WWWWWW'*3
- self.dropdownWidth = 'WWWWW'*3
- def onEnter(self):
- self.items = button2.nameList
- def onSelChange(self, selection):
- #self.items.append(button2.nameList)
- self.version = selection#change this
- print self.version
- pass
- if sde != -1 and desc.isVersioned:
- #Check to see if this connection file exists
- path = r"U:tempStuffactualName.sde"
- if not os.path.isfile(path):
- #Creates connection file if it doesn't already exist
- os.makedirs(r"U:tempStuff")
- outFolderPath = r"U:tempStuff"
- outName = r"actualName.sde"
- databasePlatform = "SQL_Server"
- instance = button2.k
- database = button2.i
- username = "username"
- password = "password"
- version = combobox2.version
- #Make sure you change between OPERATING_SYSTEM_AUTH and DATABASE_AUTH
- arcpy.CreateDatabaseConnection_management(outFolderPath, outName,
- databasePlatform,
- instance,
- 'OPERATING_SYSTEM_AUTH',
- username, password,
- 'DO_NOT_SAVE_USERNAME',
- database,
- '','TRANSACTIONAL',
- version,'')
- workspace = r"U:tempStuffactualName.sde"#change to current workspace
- fc = os.path.join(workspace, featureDataset, fcName)
- print workspace
- print "Feature class is %r" % fc
- #Start editing
- print "initiating editing"
- arcpy.ChangeVersion_management(fcName, "TRANSACTIONAL",
- combobox2.version, '')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement