• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

arcpy获得工具箱工具的个数

import  arcpy
import  string
##多少个工具箱
toolboxes = arcpy.ListToolboxes()
for toolbox in toolboxes:
    #截取工具箱的别名
    #arcpy.AddMessage("=====" + toolbox)

    first=toolbox.index("(") ##第一个'('的索引值
    #arcpy.AddMessage("first=" + str(first))
    end = toolbox.index(")")    ##最后一个')'的索引值
    #arcpy.AddMessage("end=" + str(end))
    toolboxAlias=toolbox[first+1:end] ##工具箱的别名
    #arcpy.AddMessage("toolboxAlias=" + toolboxAlias)
    i = 0
    tools = arcpy.ListTools()
    for tool in tools:
        f=tool.index("_") ##"_"的索引值
        #arcpy.AddMessage(tool+":"+str(f))
        alias=tool[f+1:]
        #arcpy.AddMessage(tool + ":" + alias)
        if alias==toolboxAlias:
            arcpy.AddMessage(tool)
            i=i+1
    arcpy.AddMessage(  "====="+toolbox+"'s count:"+str(i))
arcpy.AddMessage( "the tool count:"+str( len(tools))) 
arcpy.AddMessage(  "the toolbox count:"+str(len(toolboxes)))

 

posted on 2020-05-17 11:39  gisai  阅读(419)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3