How to identify and access a CTrack using it's ID "CTsound"
-
Hi there,
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!
-
CTrack
is aBaseList2D
so you can iterate through the list byGetNext()
.
Then you just need to check theDescID
for the proper Id of aCTsound
.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...
-
Hello,
just for your information: you find more about CTracks in the CTrack Manual and more information on DescIDs and DescLevels in the DescID Manual.
best wishes,
Sebastian