python的灵活性不言而喻,因此一直想尝试用python快速访问geodatabase。
开发环境:ArcGIS 9.3 + python 2.5
# -*- coding: cp936 -*-
def GetAoModule(moduleName):
import comtypes
from comtypes.client import GetModule
GetModule('C:\\Program Files (x86)\\ArcGIS\\com\\'+moduleName)
def AoObj(MyClass,MyInterface):
from comtypes.client import CreateObject
try:
obj = CreateObject(MyClass,None,None,MyInterface,False)
return obj
except Exception,ex:
print ex.message
return None
def InitialAo():
GetAoModule('esriSystem.olb')
import comtypes.gen.esriSystem as esriSystem
aoInit = AoObj(esriSystem.AoInitialize,esriSystem.IAoInitialize)
if(aoInit):
pCode = esriSystem.esriLicenseProductCodeArcInfo
status = aoInit.IsProductCodeAvailable(pCode)
if status==esriSystem.esriLicenseAvailable:
aoInit.Initialize(p