Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Get info on all timeline markers? [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 369 Views
    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.
    • H Offline
      Helper
      last edited by

      On 27/02/2015 at 01:31, xxxxxxxx wrote:

      Hi folks!

      I wan't to know if it's possible to get a list of all timeline markers. I only found this in the SDK:

      _<_dt id="c4d.s.getfirstmarker"_>_ c4d.documents.GetFirstMarker( doc )
      The first marker is nice, but I need to get to all of them. Any thoughts & ideas?

      TF

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 01/03/2015 at 18:50, xxxxxxxx wrote:

        Hi TechnoFeather,

        You have to use the GetNext() method to go through the list of markers in a loop.

        Pseudocode:

          
        Marker = c4d.documents.GetFirstMarker(doc)  
          
        while Marker:  
          
        Call marker related methods  
          
        Marker = Marker.GetNext()  
          
        end of loop  
        

        Let me know if you need more help.

        Joey Gaspe
        SDK Support Engineer

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 03/03/2015 at 12:56, xxxxxxxx wrote:

          Here's a working script that prints all marker names to the console:

            
          """Name-US: Print All Markers   
          Description-US: Prints a list of all markers, sorted by time, to the console.   
            
          LICENSE   
          -------   
            
          The MIT License (MIT)   
            
          Copyright (c) 2015 Donovan Keith <[email protected]>   
            
          Permission is hereby granted, free of charge, to any person obtaining a copy   
          of this software and associated documentation files (the "Software"), to deal   
          in the Software without restriction, including without limitation the rights   
          to use, copy, modify, merge, publish, distribute, sublicense, and/or sell   
          copies of the Software, and to permit persons to whom the Software is   
          furnished to do so, subject to the following conditions:   
            
          The above copyright notice and this permission notice shall be included in all   
          copies or substantial portions of the Software.   
            
          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   
          IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   
          FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE   
          AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER   
          LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,   
          OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE   
          SOFTWARE.   
            
            
          USAGE INSTRUCTIONS   
          ------------------   
            
          Simply execute this script to see a list of all markers printed to the console.   
          """   
            
          #====== IMPORTS ======#   
            
          import c4d   
            
          #====== UTILS ======#   
            
          def GetMarkerSecond(marker) :   
              """Returns marker time."""   
                 
              if marker is None:   
                  return None   
                 
              return marker[c4d.TLMARKER_TIME].Get()   
            
          def GetMarkers(doc=c4d.documents.GetActiveDocument(), sort=True) :   
              """Returns a list of all markers in doc, or an empty list if no markers are found.   
              Sorted by time by default.   
              """   
            
              markers = []   
              if (doc is None) or (not doc.IsAlive()) :   
                  return markers   
                 
              cur_marker = c4d.documents.GetFirstMarker(doc)   
                 
              while cur_marker is not None:   
                  markers.append(cur_marker)   
                  cur_marker = cur_marker.GetNext()   
                 
              if sort:   
                  markers.sort(key=GetMarkerSecond)   
                 
              return markers   
            
          def GetMarkerData(marker) :   
              """Returns a tuple of the form: name, layer, time, note, task, done   
              Usage:   
              marker_name, marker_layer, marker_time, marker_note, marker_task, marker_done = GetMarkerData(marker)   
              """   
                 
              if (marker is None) or (not marker.IsAlive()) :   
                  return None, None, None, None, None, None   
                 
              name = marker.GetName()   
              layer = marker[c4d.ID_LAYER_LINK]   
              time = marker[c4d.TLMARKER_TIME]   
              task = marker[c4d.TLMARKER_TASK]   
              done = marker[c4d.TLMARKER_DONE]   
              note = marker[c4d.TLMARKER_TEXT]   
                 
              return name, layer, time, note, task, done   
            
          #====== MAIN ======#   
            
          def main() :   
                 
              #Print Header   
              doc_name = doc.GetDocumentName()   
                 
              print " "   
              print " "   
              print "Markers in Document:", doc.GetDocumentName()   
              print "====================" + "=" * len(doc_name)   
                 
              #Print each marker's name   
              markers = GetMarkers(doc)   
              for marker in markers:   
                      marker_name, marker_layer, marker_time, marker_note, marker_task, marker_done = GetMarkerData(marker)   
            
                      print str(marker_time.GetFrame(doc.GetFps())) + ": " + marker_name   
            
          if __name__=='__main__':   
              main()   
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 13/03/2015 at 08:53, xxxxxxxx wrote:

            Since Donovan gave a more elaborate answer than I did, and this topic has been dormant for quite some time, I will close it as solved.

            Joey Gaspe
            SDK Support Engineer

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 07/04/2015 at 03:40, xxxxxxxx wrote:

              Thanks alot for the help Joey and Donovan! Really appreciate it. 🙂 *thumbsup*

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