vcTeachContext

vcTeachContext is the context of the application for robot programming.

Inherits: vcContext

Properties

Name Type Access Description
ActiveRobot vcComponent RW Defines the active robot in context.
ActiveRoutine vcRoutine R Gets the active routine in the ActiveRobot program.
ActiveScope vcScope R Gets the active routine or scope of statement in ActiveRobot program.
ActiveStatement <Type> R Gets the active statement in ActiveRobot program.
ActiveStatementIndex Integer R Gets the index of active statement in ActiveRobot program.

Methods

Name Return Type Parameters Description
setActiveStatement None vcScope scope, Integer index Sets the statement at the given index in the given scope to be ActiveStatement.

 

Events

Name Parameters Description
ActiveRobotChanged None Triggered when a different robot becomes the active robot in context.

Examples

Example. Get active robot and routine in 3D world

from vcScript import *
 
##Option 1
def getActiveRoutine():
  routine = getApplication().TeachContext.ActiveScope
  if routine:
    if routine.ParentStatement:
      routine = routine.ParentStatement.Routine
  return routine
 
##Option 2
app = getApplication()
teach = app.TeachContext
robot = teach.ActiveRobot
if robot:
  executor = robot.findBehavioursByType( VC_ROBOTEXECUTOR )[0]
  main = executor.Program.MainRoutine
  scope = teach.ActiveScope
  if teach.ActiveStatementIndex < 0:
    print "No statements exist within the scope"
  else:
    print "Index of the currently selected statement in the scope is : ", teach.ActiveStatementIndex
  if type(scope) == type(main):
    print "Current Routine is: ", scope
  else:
    print "Current Routine is (read from scope statement): ", scope.ParentStatement.Routine