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
    • Register
    • Login

    Advice on implementing undo/redo in a Tool

    Scheduled Pinned Locked Moved Cinema 4D SDK
    c++2026
    3 Posts 2 Posters 20 Views 1 Watching
    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.
    • SteveHill3DS Offline
      SteveHill3D
      last edited by

      C4D SDK newbie here. I am implementing a geometry creation Tool which works by dragging an initial shape and then allows multiple edits through handle or other drags in the viewport or via attribute changes in the AM. I would like these changes to be undoable while the tool is active i.e. until the tool is finalized via ESC or something happens like the active object changes.

      Does anyone have any advice on how best to manage this?

      (I reluctantly asked three AIs and got three answers -- hidden tag (Copilot), object base container (ChatGPT) and do it yourself (Claude))

      Thanks.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF Offline
        ferdinand @SteveHill3D
        last edited by ferdinand

        Hey @SteveHill3D,

        Welcome to the Maxon developers forum and its community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

        • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
        • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
        • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

        It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: How to Ask Questions.

        About your First Question

        You could look at our edgecuttool.cpp C++ SDK example, it demonstrates both the usage of undos and cinema::InteractiveModeling_Restart, i.e., rolling updates. In some cases InteractiveModeling_Restart will not cut it you have to un-roll your undos yourself or even not use undos at all for rolling updates and instead work with a tool finalization logic.

        By chance I just wrote an example for the latter for the upcoming Python SDK. You will not be able to run it, as the customer release version is missing the Python API to deal with SDS weights, but you can have a look at its code. The idea is simple: Establish a ground truth and operate based on that. But for modelling tools and especially tools that add or remove geometry using undos and InteractiveModeling_Restart should be preferred when possible, as it will be usually faster, as the cinema core can pull some tricks you cannot as a third party.

        Cheers,
        Ferdinand

        Please understand that this example is a preview and might be subject to change.
        py-cmd_tool_finalization_2026_2.zip

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • SteveHill3DS Offline
          SteveHill3D
          last edited by

          Thank you for the pointers. I will digest the examples.

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