Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Register
    • Login

    DrawHudText interferes with Polygon Pen Tool etc

    Cinema 4D SDK
    2
    4
    690
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic was forked from BaseDraw.DrawTexture Issue i_mazlov
    This topic has been deleted. Only users with topic management privileges can see it.
    • FlavioDinizF
      FlavioDiniz
      last edited by

      It's me again @i_mazlov, sorry ☹️
      I came across another issue caused by the DrawHudText:

      It's almost impossible to use some tools while the DrawHudText is active. As soon as I disable it, everything goes back to normal !

      The tools I noticed the issue are:

      • Polygon Pen Tool
      • Loop / Path Cut

      I Imagine that's because these tools draws stuff on screen in the same "canvas" the DrawHudText draws...
      I'll investigate it a bit more, maybe there's some z-depth or another settings that helps on this, maybe other flags for the GetDrawParam ...

      If anything, I could try to disable automatically the draw function if those modeling tools get selected 🤔

      Cheers,
      Flavio Diniz

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @FlavioDiniz
        last edited by

        Hi Flavio,

        Thanks for getting back to us! There's no reason to be sorry, it's the opposite, you're very welcome to share your ideas and post questions!

        I've forked your question to a separate thread. Even though this sounds like a similar issue, under the hood it can be a completely different story 😉

        Please attach a sample project file (or at least the python code you're using), which would help us reproducing the behavior from the video. This makes things happenning easier and faster.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • FlavioDinizF
          FlavioDiniz
          last edited by

          Thanks @i_mazlov !
          So, I figured what the problem was, it was kind of my fault due to my not so good scripting skills, lol

          I'll explain the issues I was having anyway:

          Issue 1

          File save state was constantly unsaved. If you click to save, then click to close the document, it would ask if you want to save the document. CTRL+S didn't do any difference.

          Issue 2

          When the DrawHudText was visible on screen, it was preventing the usage of some tools:

          1. Polygon Pen Tool,
          2. Loop / Path Cut,
            pen_tool.mp4

          I'm attaching the C4D file and the code on the python tag below:
          Using C4D 2025.2.1
          DrawHudText_Issue.c4d

          # Autosave Info By Flavio Diniz
          import c4d
          
          def main() -> None:
              pass
          
          def draw(bd: c4d.BaseDraw) -> bool:
          
              savedColor = bd[c4d.BASEDRAW_HUD_TEXTCOLOR]
              savedBG = bd[c4d.BASEDRAW_HUD_BACKCOLOR]
              savedOpacity = bd[c4d.BASEDRAW_HUD_BACKOPACITY]
          
              if bd.GetDrawPass() != c4d.DRAWPASS_OBJECT or bd.GetDrawParam(c4d.BASEDRAW_IS_PICK_OBJECT):
                  return True
          
              bd = doc.GetActiveBaseDraw()
          
              if c4d.GetWorldContainerInstance()[c4d.WPREF_AUTOSAVE_ENABLE] == 1:
                  autosave = "Enabled"
          
                  bd[c4d.BASEDRAW_HUD_TEXTCOLOR]= c4d.Vector(0.3, 0.8, 0.3)
                  bd[c4d.BASEDRAW_HUD_BACKCOLOR]= c4d.Vector(0,0.7,0)
                  bd[c4d.BASEDRAW_HUD_BACKOPACITY] = 0.2
          
                  bd.DrawHUDText(0, 3, "Autosave: {}".format(autosave))
          
                  bd[c4d.BASEDRAW_HUD_TEXTCOLOR]= savedColor
                  bd[c4d.BASEDRAW_HUD_BACKCOLOR]= savedBG
                  bd[c4d.BASEDRAW_HUD_BACKOPACITY] = savedOpacity
          
          
              elif c4d.GetWorldContainerInstance()[c4d.WPREF_AUTOSAVE_ENABLE] == 0:
                  autosave = "Disabled"
          
                  bd[c4d.BASEDRAW_HUD_TEXTCOLOR]= c4d.Vector(0.8, 0.5, 0.5)
                  bd[c4d.BASEDRAW_HUD_BACKCOLOR]= c4d.Vector(0.9,0,0)
                  bd[c4d.BASEDRAW_HUD_BACKOPACITY] = 0.1
          
                  bd.DrawHUDText(0, 3, "Autosave: {}".format(autosave))
          
                  bd[c4d.BASEDRAW_HUD_TEXTCOLOR]= savedColor
                  bd[c4d.BASEDRAW_HUD_BACKCOLOR]= savedBG
                  bd[c4d.BASEDRAW_HUD_BACKOPACITY] = savedOpacity
          
              return c4d.DRAWRESULT_OK
          

          .

          So, in short, the problem is my attempt to change the background and text color of the DrawHudText !
          998f9a83-a908-4303-a686-074fd1b55bc3-image.png

          I know it's not fully supported in Python, but I found a piece of code that allowed me to store the original HUD color, then change the color, draw the HUD, then revert back the color to the original... yes, I imagine this is 200% not recommended to do hahaha

          As soon as I remove these functions to change color from the code, both issues listed above are gone !

          This is the code without the coloring part:

          # Autosave Info By Flavio Diniz
          import c4d
          
          def main() -> None:
              pass
          
          def draw(bd: c4d.BaseDraw) -> bool:
              if bd.GetDrawPass() != c4d.DRAWPASS_OBJECT or bd.GetDrawParam(c4d.BASEDRAW_IS_PICK_OBJECT):
                  return True
          
              bd = doc.GetActiveBaseDraw()
          
              if c4d.GetWorldContainerInstance()[c4d.WPREF_AUTOSAVE_ENABLE] == 1:
                  autosave = "Enabled"
                  bd.DrawHUDText(0, 3, "Autosave: {}".format(autosave))
          
              elif c4d.GetWorldContainerInstance()[c4d.WPREF_AUTOSAVE_ENABLE] == 0:
                  autosave = "Disabled"
                  bd.DrawHUDText(0, 3, "Autosave: {}".format(autosave))
          
              return c4d.DRAWRESULT_OK
          

          I can live without the coloring part, if you know a better way to do it or a fix, good! if not, that's fine! 🙂

          Cheers,
          Flavio Diniz

          i_mazlovI 1 Reply Last reply Reply Quote 0
          • i_mazlovI
            i_mazlov @FlavioDiniz
            last edited by i_mazlov

            Hi @FlavioDiniz,

            thanks for providing more information on the issue.

            Regarding your "Issue 2". I see no reason for the background color (and other properties) to not work in your setup, hence I've created a bug report for that (ITEM#587756). Thanks for reporting the issues you face during your development.

            We are happy to handle your "Issue 1" about "constantly unsaved document" in a separate thread, once you create it yourself.

            Cheers,
            Ilia

            MAXON SDK Specialist
            developers.maxon.net

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