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

    Is there a Python equivalent of SceneHookData::Draw()?

    Scheduled Pinned Locked Moved Cinema 4D SDK
    pythonc++2026
    5 Posts 2 Posters 42 Views 2 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.
    • AnlvA Offline
      Anlv
      last edited by Anlv

      Hey community,

      I'd like to develop a viewport helper plugin in Python that displays dimension lines, values, and units for the currently selected objects, making it easier to assess their actual size and proportions.

      I'd like this display to work alongside the native Move, Rotate, and Scale tools, without adding helper objects to the scene or attaching tags to the objects.

      While looking through the SDK, I found that SceneHookData::Draw()
      in C++ seems suitable for this purpose, but I haven't found an equivalent interface in Python.

      I'm currently building a C++ version of the plugin, but I'd still like to see equivalent viewport drawing support added to Python.

      Is there a similar interface in Python, or another way to achieve this under these constraints? If not, are there any plans to expose SceneHookData, particularly its Draw() callback, to Python?

      Cheers,
      Anlv

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

        Hey Anlv,

        thank you for reaching out to us.

        There is no SceneHookData equivalent in Python yet. In this cycle we just tested internally a prototype but we haven't made a choice there yet. The main concern is performance, especially of Draw. It is currently unclear if we will ever go forward with the idea of a Python SceneHookData.

        The workaround we suggested in the past was to add a hidden object to a scene via a MessageData handler or any other node that has the methods you need. But that is not really better performance wise. In general is the idea to have a Python plugin which draws in each an every scene a bit of a mixed bag. I personally think it is not that much of a deal, because when the plugin slows down Cinema because the author wrote terrible Draw code, the user can just uninstall it. Some of my colleagues are more of the stance that we should not allow such setups at all, as the average user might be unable to pinpoint the plugin as the source of slowdowns.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        AnlvA 1 Reply Last reply Reply Quote 1
        • AnlvA Offline
          Anlv @ferdinand
          last edited by Anlv

          Hey @ferdinand,

          Thanks for your reply. When building this plugin in Python, I implemented move, scale, and rotate functionality within the plugin, since switching to C4D’s native tools would stop the dimension information from being drawn.

          However, this made the plugin rather bloated, and the performance was indeed less than ideal. Having to maintain those transform functions myself also felt like reinventing the wheel.

          I’ve now completed the C++ version of the plugin, and I’m very happy with it so far. Going forward, I’ll probably choose between C++ and Python depending on the use case.

          Demo Video:

          Cheers~
          Anlv

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

            Unless I misunderstand the scope of the tool, you could implement this as a tool because a tool can draw. But with the caveat that the user has to enable it. But doing something like this as a scene hook is not great, even in C++. The reason is UX. Either you implement it as a pure scene hook with no feedback, then the user is stuck with always having this bounding box shown on the selected object. Or you add some kind of toggle that enables or disables it, but then you are already pretty close to reimplementing a tool.

            Question is: Do you really need this bounding box overlay to be able to coexist next to another activated tool. If so, you need a scene hook. Otherwise you should go with a tool.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • AnlvA Offline
              Anlv
              last edited by Anlv

              Hi @ferdinand ,

              Yes, I do need the dimension overlay to coexist with another active tool. The plugin is mainly intended to help adjust objects to realistic dimensions and proportions.

              When precise dimensions are not required, the overlay helps me quickly resize and place objects in the scene. Once that is done, I can turn off the dimension overlay.

              The plugin can be enabled or disabled directly and includes some settings, with usage similar to the Symmetry tool. Inactive objects do not display dimension information, and grouped objects are measured as a whole, so the viewport does not become a sea of dimension annotations🤗 .

              Cheers,
              Anlv

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