Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Exemple for add / get marker inside c4d through python
Exemple for add / get marker inside c4d through python.
More informations =>
import c4d
def get_all_marker(doc):
markers_list = list()
marker = c4d.documents.GetFirstMarker(doc)
while marker:
marker = marker.GetNext() #Since a marker is a BaseList2D we can use GetNext for iterate
return markers_list
def get_marker_frame(markers_list, frame):
marker_list = list()
for marker in markers_list:
doc = marker.GetDocument() #Get the doc related to the marker
#Get the time of the marker in fps
time = marker[c4d.TLMARKER_TIME]
fps_time = time.GetFrame(doc.GetFps())
#Get the time of the length in fps
length = marker[c4d.TLMARKER_LENGTH]
fps_length = length.GetFrame(doc.GetFps())
#if user frame is betwen we add to the list
if fps_time <= frame <= fps_time + fps_length:
return marker_list
def get_time_from_fps(doc, fps):
#Utility function that return a c4d.BaseTime from a given doc / fps
doc_fps = doc.GetFps()
return c4d.BaseTime(float(fps) / doc_fps)
def main():
#Create marker
doc = c4d.documents.GetActiveDocument()
first_marker = c4d.documents.AddMarker(doc, None, get_time_from_fps(doc, 30), "first")
second_marker = c4d.documents.AddMarker(doc, None, get_time_from_fps(doc, 27), "second")
second_marker[c4d.TLMARKER_LENGTH] = get_time_from_fps(doc, 5)
#Get data from them
markers = get_all_marker(doc)
marker_30fps = get_marker_frame(markers, 30)
print marker_30fps
if __name__=='__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment