How to identify and access a CTrack using it's ID "CTsound"
mafster last edited by
I'm wondering if there is a way to get the CTrack on an object specified by its type, specifically an audio track?
Currently i just grab the first CTrack which doesnt help if there is a keyframe or some other track also on the object.
from c4d import document doc = documents.GetActiveDocument() obj = doc.SearchObject('sound') # A convention used in studio to get the object by name sound_track = obj.GetFirstCTrack() sound_track[c4d.CID_SOUND_START] # This will return NoneType if sound_track is actually something else, therefore doesnt carry this property.
Anyone have any idea how to do this without using GetFirstCTrack()? Im guessing it will somehow need to use the ID for special CTrack "CTsound" but im not really sure how to use it.
Thanks in advance!
Cairyn last edited by
BaseList2Dso you can iterate through the list by
Then you just need to check the
DescIDfor the proper Id of a
import c4d def main() : obj = doc.GetActiveObject() if obj : track = obj.GetFirstCTrack() while track != None : descID = track.GetDescriptionID() if descID.__getitem__(0) == c4d.DescLevel(c4d.CTsound) : print "Hooray! Found a sound track!" track = track.GetNext() if __name__=='__main__': main()
One of these days I'm going to understand these DescLevels too, maybe...
s_bach last edited by