tyFlow Forum
[MAXScript] Get Event by index or key - Printable Version

+- tyFlow Forum (https://forum.tyflow.com)
+-- Forum: tyFlow Discussion (https://forum.tyflow.com/forum-1.html)
+--- Forum: Feature Requests (https://forum.tyflow.com/forum-4.html)
+--- Thread: [MAXScript] Get Event by index or key (/thread-2445.html)



[MAXScript] Get Event by index or key - obeyfx27 - 06-11-2021

Hi there,

I'm trying to get some attributes from a tyFlow event with maxscript.
Before reaching these attributes, I have to get the event itself, and the only way I found is to use the event's name in tyFlow object's attributes. For instance, to get an Export Particles tyCache Filename :


Code:
myEvent = $tyFlow001.Event_006
myFilename = myEvent.Export_Particles.tycacheFilename

This method supposes that I know the event's name, which is not always the case.
Is there any way to get an array of all the events and use an index or key to get the wanted event ? It would be useful for iterating over the events without having to know there names.

For example with the array's usage, to get the Bend modifier from Box001 object :
Code:
boxModifiers = $Box001.modifiers
bendModifierByKey = boxModifiers ["Bend"]
bendModifierByIndex = boxModifiers [1] -- if the Bend modifier is in first position

The equivalent of this feature in tyFlow would be :
Code:
myEvents = $tyFlow001.events
n = $tyFlow001.numEvents
eventByKey = myEvents["Global Export"]
latestEvent = myEvents [n]

The feature could help a lot for iterating over events proceduraly.

Cheers.


RE: [MAXScript] Get Event by index or key - tyFlow - 06-14-2021

Iterating through events can be done with subanim methods:

Code:
obj = $tyFlow001.baseobject

names = getsubanimnames obj

for name in names do
(
    anim = getsubanim obj name
    
    if (iskindof anim tyEvent) then --check if subanim is 'tyEvent' class member
    (
        print (anim.name) --it is, so print it's name. We can then either access by name, or directly through the subanim
    )
)



RE: [MAXScript] Get Event by index or key - obeyfx27 - 06-15-2021

Nice to know, thanks !