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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Delete marker with python

    Cinema 4D SDK
    2
    3
    797
    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.
    • G
      gsmetzer
      last edited by

      Hello,

      I have a Python Generator with an integer UserData. My code functions by adding markers based on the integer from my user data. Adding markers is working as expected. However deleting markers does not. I can't find anything in the API that deletes markers from the timeline. How would I do this? The only other option would be to delete all markers with command data. My code:

      def GetMarkers(doc=c4d.documents.GetActiveDocument(), sort=True):
          markers = []
          
          thisMarker = c4d.documents.GetFirstMarker(doc)
          while thisMarker is not None:
              markers.append(thisMarker)
              thisMarker = thisMarker.GetNext()
          
          return markers
      
          
      def main():  
          
          #Get a list of markers
          markers = GetMarkers(doc)
          
          print len(markers)
          #check if my user data integer is greater/less than the number of markers 
          if len(markers) < op[c4d.ID_USERDATA,1]:
              c4d.documents.AddMarker(doc, None, c4d.BaseTime(len(markers)), 'name')
              print 'add Marker'
              
          elif len(markers) > op[c4d.ID_USERDATA,1]:
              #Removing or del from Markers list doesnt work...   
              print 'delete Marker'
          
          #Here I loop through the list and set the name,time, length, color etc. if needed
          for i in range(0, len(markers)):
              
              markers[i].SetName('fred')
          
          c4d.EventAdd()
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @gsmetzer please read and apply for your next topics:

        • Q&A New Functionality
        • How to Post Questions

        Regarding your issue.
        a Marker is a BaseList2D, which is also a GeListNode. So you can call GeListNode.Remove

        However, note that you are in a generator and a generator is not supposed to change the scene structure (aka add a new object to it (and a marker is a new object). For more information see Threading Information. The correct way to do it would be to create a CommandData plugin.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • G
          gsmetzer
          last edited by

          Thank you @m_adam

          markers[0].Remove()
          

          worked in the Python Generator without crashing. I hope it isn't stupid to try this. I do plan on converting it to a plugin. Thanks, you can solve this question.

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