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()