FAQ: 为什么有时候使用dispatch对象的方法python会被挂起

文章编号 : 27045
软件: ArcGIS - ArcEditor 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 9.0, 9.1, 9.2, 9.3, 9.3.1
操作系统: N/A
已邀请:

易智瑞技术支持

赞同来自:

问题: 为什么有时候使用dispatch对象的方法python会被挂起?
回答: 许多情况下这是许可冲突导致的。Python假设用户拥有ArcInfo许可,如果不是则会挂起。甚至用户只是使用那些用于他们特定许可的工具时也会发生这种状况。
为了解决这个问题,需要总是确认python知道正在使用的许可,这可以通过dispatch对象的SetProduct方法来实现。下面代码段是一个例子。


import win32com.client

gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")

gp.SetProduct("ArcView")

使用dispatch对象的CheckProduct方法来确认哪一个许可是可用的,下面代码段是一个例子。


import win32com.client

gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1")


print "ArcView license is " + gp.CheckProduct("ArcView")

print "ArcEditor license is " + gp.CheckProduct("ArcEditor")

print "ArcInfo license is " + gp.CheckProduct("ArcInfo")




创建时间:2004-06-23
最近更新: 2011-05-03


原文链接
http://support.esrichina.com.c ... .html

要回复问题请先登录注册