Python访问ArcObjects
来源:互联网 发布:陈意涵长相知乎 编辑:程序博客网 时间:2024/05/18 15:03
# -*- coding:UTF-8 -*-# 读取与导入ArcObjects模块def GetLibPath(): """Return location ArcGIS type libraries as string""" #This will still work on 64-bit machines because Python runs in 32 bit mode import _winreg keyESRI=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\\ESRI\\Desktop10.0") return _winreg.QueryValueEx(keyESRI,"InstallDir")[0]+"com\\" #u'C:\\Program Files\\ArcGIS\\Desktop10.0\\com\\'def GetModule(sModuleName): """Import ArcGIS module""" from comtypes.client import GetModule sLibPath=GetLibPath() GetModule(sLibPath+sModuleName)def GetStandaloneModules(): """"Import commonly used ArcGIS libraries for standalone scripts""" GetModule("esriSystem.olb") GetModule("esriGeometry.olb") GetModule("esriCarto.olb") GetModule("esriDisplay.olb") GetModule("esriGeoDatabase.olb") GetModule("esriDataSourcesGDB.olb") GetModule("esriDataSourcesFile.olb") GetModule("esriOutput.olb")#调用GetStandaloneModules执行模块的一次性导入# 以后调用只要 import comtypes.gen.esriGeometry as esriGeometry 这种方式导入模块即可GetStandaloneModules()#绑定产品注册ArcGIS Version的类库文件(C:\Program Files\Common Files\ArcGIS\bin\ArcGISVersion.dll)from comtypes.client import GetModuleagsversion=comtypes.GUID("{6FCCEDE0-179D-4D12-B586-58C88D26CA78}")GetModule((agsversion,1,0))
导入前后如下目录如图示:
# 创建与转换对象类型def NewObj(MyClass,MyInterface): from comtypes.client import CreateObject try: ptr=CreateObject(MyClass,interface=MyInterface) return ptr except: return Nonedef CType(obj,interface): try: newobj=obj.QueryInterface(interface) return newobj except: return Nonedef CLSID(MyClass): return str(MyClass._reg_clsid)# 注册运行许可def InitLicenseState(): import comtypes.gen.ArcGISVersionLib as esriVersion import comtypes.gen.esriSystem as esriSystem pVM=NewObj(esriVersion.VersionManager,esriVersion.IArcGISVersion) if not pVM.LoadVersion(esriVersion.esriArcGISDesktop,"10.0"): return False pInit=NewObj(esriSystem.AoInitialize,esriSystem.IAoInitialize) ProductList=[esriSystem.esriLicenseProductCodeArcInfo,\ esriSystem.esriLicenseProductCodeArcEditor, \ esriSystem.esriLicenseProductCodeArcView] for eProduct in ProductList: licenseStatus=pInit.IsProductCodeAvailable(eProduct) if licenseStatus!=esriSystem.esriLicenseAvailable: continue licenseStatus=pInit.Initialize(eProduct) return (licenseStatus==esriSystem.esriLicenseCheckedOut) return False
ESRI的支持人员博客
http://blog.csdn.net/warrenwyf/article/details/6040311
- Python访问ArcObjects
- [python]使用ArcObjects访问要素类
- 在 Python 中使用 ArcObjects
- 在 Python 中使用 ArcObjects
- ArcObjects
- 在Python中使用ArcObjects对象
- 小菜的ArcObjects学习之路------如果通过MapDocument访问地图和图层
- 小菜的ArcObjects学习之路------如何通过MxDocument访问地图和图层
- 了解ArcObjects
- 了解ArcObjects
- ArcObjects学习
- ArcObjects基础
- Exploring ArcObjects的下载
- ArcObjects培训概要
- arcobjects api(二)
- ArcObjects:添加图例代码
- Java ArcObjects Developer Guide
- ArcObjects与ArcGIS Engine
- 微软的COM中GUID和UUID、CLSID、IID
- 一个0123456789的测试,大家来玩一把!
- LLServer1.0及C#客户端正式发布并开源
- win7IIS安装和 端口80http 开启
- the different between call and apply in javascript
- Python访问ArcObjects
- VC启动窗口画面制作方法研究
- 手机网站的脆弱性测试插件: FireMobileSimulator (对应日本的几家厂商)
- The Future
- jquery随记(效果)-----用回调函数处理单元素和多元素的排队
- 数据库知识记录
- CStdioFile写汉字
- ubuntu下arm-linux-gcc的问题
- VC无闪烁刷屏技术的实现