Behaviour module handling

Maya

from maya import cmds
cmds.loadPlugin("AtomsMaya")

from AtomsMaya.utils import agentgroup
from AtomsMaya.hostbridge.atomsgroup import MayaAtomsGroupHostBridge

cmds.tcAtoms(init=True)

agent_group = agentgroup.create_agent_group()
ag = MayaAtomsGroupHostBridge()
ag.set_app_obj(agent_group)
ag.add_module("gridLayout")
ag.add_module("stateMachine")

atoms_ag = ag.get_agent_group()
bm = atoms_ag.behaviourModule("gridLayout")
attributes = bm .attributes()
ag.set_metadata_value("gridLayout", "size", attributes["size"].typeStr(), [2, 1, 2])

bm = atoms_ag.behaviourModule("stateMachine")
attributes = bm.attributes()

for k in sorted(attributes.getKeys()):
    if k.endswith("_override"):
        continue
        
    attribute = attributes[k]
    print(k, ag.get_metadata_value("stateMachine", k, attribute.typeStr()))
    
ag.set_metadata_value("stateMachine", "state", attributes["state"].typeStr(), 1)

ag.set_override_at_index("stateMachine", "state", [0, 1], attributes["state"].typeId(), [0, 2], multi_value=True)

print("Override indices:", ag.get_override_agent_indices("stateMachine", "state"))

ag.remove_override_at_index("stateMachine", "state", 0)

print("Override indices after removing:", ag.get_override_agent_indices("stateMachine", "state"))

print(ag.get_override_value_at_index("stateMachine", "state", 1, attributes["state"].typeId()))











Houdini

from AtomsHoudini.utils import scenesetup
from AtomsHoudini.hostbridge.atomsgroup import HoudiniAtomsGroupHostBridge

scenesetup.initialize_atoms_scene()

agent_group = scenesetup.create_agent_group_node()
ag = HoudiniAtomsGroupHostBridge()
ag.set_app_obj(agent_group)
ag.add_module("gridLayout")
ag.add_module("stateMachine")

atoms_ag = ag.get_agent_group()
bm = atoms_ag.behaviourModule("gridLayout")
attributes = bm .attributes()
ag.set_metadata_value("gridLayout", "size", attributes["size"].typeStr(), [2, 1, 2])

bm = atoms_ag.behaviourModule("stateMachine")
attributes = bm.attributes()

for k in sorted(attributes.getKeys()):
    if k.endswith("_override"):
        continue
        
    attribute = attributes[k]
    print(k, ag.get_metadata_value("stateMachine", k, attribute.typeStr()))
    
ag.set_metadata_value("stateMachine", "state", attributes["state"].typeStr(), 1)

ag.set_override_at_index("stateMachine", "state", [0, 1], attributes["state"].typeId(), [0, 2], multi_value=True)

print("Override indices:", ag.get_override_agent_indices("stateMachine", "state"))

ag.remove_override_at_index("stateMachine", "state", 0)

print("Override indices after removing:", ag.get_override_agent_indices("stateMachine", "state"))

print(ag.get_override_value_at_index("stateMachine", "state", 1, attributes["state"].typeId()))

Copyright © 2017, Toolchefs LTD.