Check if an agent is in a transition

Maya

import Atoms

smi = Atoms.StateMachines.instance()

from AtomsMaya.hostbridge.atomsgroup import MayaAtomsGroupHostBridge
from AtomsMaya.hostbridge.commands import MayaCommandsHostBridge

nh = MayaAtomsGroupHostBridge()
nh.set_app_obj("tcAgentGroupNodeShape1")

ag = nh.get_agent_group()

ids = ag.agentLocalIds()

for agent_id in ids:
    agent = ag.agent(agent_id)
    sm = smi.stateMachine(agent.agentType().metadata()["stateMachine"].value())
    if not  sm:
        continue

    state = agent.metadata()["state"].value()
    current_state = agent.metadata()["currentState"].value()

    if current_state != state:
        print(sm.connections()[(current_state, state)].name())

Houdini

import Atoms

smi = Atoms.StateMachines.instance()

from AtomsHoudini.hostbridge.atomsgroup import HoudiniAtomsGroupHostBridge
from AtomsHoudini.hostbridge.commands import HoudiniCommandsHostBridge

nh = HoudiniAtomsGroupHostBridge()
nh.set_app_obj("/obj/AgentGroupName")

ag = nh.get_agent_group()

ids = ag.agentLocalIds()

for agent_id in ids:
    agent = ag.agent(agent_id)
    sm = smi.stateMachine(agent.agentType().metadata()["stateMachine"].value())
    if not  sm:
        continue

    state = agent.metadata()["state"].value()
    current_state = agent.metadata()["currentState"].value()

    if current_state != state:
        print(sm.connections()[(current_state, state)].name())

Copyright © 2017, Toolchefs LTD.