Get info on all timeline markers? [SOLVED]
On 27/02/2015 at 01:31, xxxxxxxx wrote:
I wan't to know if it's possible to get a list of all timeline markers. I only found this in the SDK:
c4d.documents.GetFirstMarker( doc )
The first marker is nice, but I need to get to all of them. Any thoughts & ideas?
On 01/03/2015 at 18:50, xxxxxxxx wrote:
You have to use the GetNext() method to go through the list of markers in a loop.
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.
SDK Support Engineer
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 <firstname.lastname@example.org> 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()
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.
SDK Support Engineer
On 07/04/2015 at 03:40, xxxxxxxx wrote:
Thanks alot for the help Joey and Donovan! Really appreciate it. :-) *thumbsup*