Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to identify and access a CTrack using it's ID "CTsound"

    Cinema 4D SDK
    python r20
    3
    3
    599
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mafster
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        CTrack is a BaseList2D so you can iterate through the list by GetNext().
        Then you just need to check the DescID for the proper Id of a CTsound.

        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...

        1 Reply Last reply Reply Quote 2
        • S
          s_bach
          last edited by

          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

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • First post
            Last post