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

    Undo Script

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 376 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 21/09/2015 at 20:23, xxxxxxxx wrote:

      So, first post, noob question. :blush:  
        
      I have these two really simple scripts that save me some clicks every now and then.  
      All I want to do is undo them in one go but for the life of me I can't figure out how.  
        
        
      1: To make a single mesh out of anything (e.g. cloner object)   
      //-------------------------------------------------------------------------------------  
      def main() :  
          bc = c4d.GetWorldContainerInstance()    # Get the Prefs  
          oldInsertAt = bc[c4d.WPREF_INSERTAT]    # Get the current Insert setting  
          bc[c4d.WPREF_INSERTAT] = 3         # Set to Parent  
          c4d.CallCommand(100004772) # Group Objects  
          c4d.CallCommand(1011010) # Connect  
          c4d.CallCommand(12236) # Make Editable  
          bc[c4d.WPREF_INSERTAT] = oldInsertAt # Reset the pref to original value  
      if \__name\_\_=='\__main\_\_':  
          main()  
        
      //-------------------------------------------------------------------------------------  
        
        
        
      2: Delete polygons + optimize when in polygon/point mode  
         or optimize when in edge mode  
      //-------------------------------------------------------------------------------------  
      mode = doc.GetMode()  
      if mode==c4d.Medges: #in edge mode  
       c4d.CallCommand(440000043) # Dissolve  
      elif mode!=c4d.Medges: #Not in edge mode  
       c4d.CallCommand(12109) # Delete  
       c4d.CallCommand(14039) # Optimize...  
        
      //-------------------------------------------------------------------------------------  
        
      Any thoughts? please!!`Lamp`[URL-REMOVED]  
      

      [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

        On 22/09/2015 at 04:21, xxxxxxxx wrote:

        Hi,

        welcome to the Plugin Café forums 🙂

        Unfortunately it's not going to work.
        Normally you'd use StartUndo(), AddUndo() and EndUndo() to create undo steps. But in your case you are using CallCommand(), which (as the name already says) calls Cinema4D's built-in commands. These commands usually handle undo on their own and thus create their individual separate undo steps. Nothing much you can do about it.
        Some of the commands you are using are quite easy to implement yourself. So you could at least reduce the number of undo steps, by implementing these yourself and thus having full control over the undo steps using above commands.

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

          On 22/09/2015 at 05:54, xxxxxxxx wrote:

          So, that's why everything I tried didn't work.

          Huge thanks Andreas for taking the time 🤝

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