网淘巴来吧,欢迎您!

返回首页 微信
微信
手机版
手机版

robot 脚本解析

2021-04-06 新闻来源:网淘巴 围观:3517
''

from vcScript import *

 

comp=getComponent()#先要获得组件也就是拖入布局的模型

 

robotExecutor=comp.findBehavioursByType("rRobotExecutor")[0]#获得程序里的子程序集合

 

robotProgram=robotExecutor.Program#获得程序里的子程序集合

 

mainRoutine=robotProgram.MainRoutine#获得程序里的子程序集合中的Main

 

 

subroutines=robotProgram.Routines#获得程序里的子程序集合中所有子程序

 

for property in mainRoutine.Properties:#获得程序里的子程序Main中的属性,如变量名

  print(property.Name)

statements=mainRoutine.Statements

print(statements)

for statement in statements:

  if statement.Scopes:

    print(statement.Scopes)

 

def getAllStatementsInRoutine(scope,statements=None):

   if not statements:

      statements=[]

   for statement in scope.Statements:

       statements.append(statement)

       if statement.Scopes:

          for scope in statement.Scopes:

              getAllStatementsInRoutine(scope,statements)#递归

   return statements

  

print(len(getAllStatementsInRoutine(mainRoutine)))#mainRoutine中包含scope和statements,python是门神奇的语言

 

#print(len(getAllStatementsInRoutine(subroutines[1])))获得了不含main的子程序程序语句数量

 

#遍历了主程序包含的所有子程序

def getAllStatementsInRobotProgram(program):

  statements=getAllStatementsInRoutine(program.MainRoutine)

  for statement in statements:

      subroutine=statement.getProperty("Routine")

      if subroutine:

         getAllStatementsInRoutine(subroutine.Value,statements) 

  return statements

  

print len(getAllStatementsInRobotProgram(robotProgram))

#获取第一个子程序下所有程序片段statement

positions=[]

for statement in subroutines[0].Statements:

  print(statement)

 

#获取第一个子程序下所有程序片段位置

positions=[]

for statement in subroutines[0].Statements:

  try:

    print(statement.Positions)

  except:

    continue

#获取所有子程序下的位置

def getAllPositionsInRoutine(scope):

    statements=getAllStatementsInRoutine(scope)

    positions=[]

    for statement in statements:

        try:

            for position in statement.Positions:

                positions.append(position)

        except:

                pass

    return positions

for subroutine in subroutines:

    print(getAllPositionsInRoutine(subroutine))

转载必须标明出处robot脚本解析_visual Component_网淘巴 (wtao8.com) 

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏
上一篇:没有了 下一篇:恒顺醋业-醋业智能制造标杆企业

相关文章

遇到问题?请给我们留言

请填写您的电话号码,我们将回复您电话

欢迎
光临