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
    • Login
    1. Home
    2. FlavioDiniz
    • Profile
    • Following 1
    • Followers 1
    • Topics 8
    • Posts 24
    • Best 0
    • Controversial 0
    • Groups 0

    FlavioDiniz

    @FlavioDiniz

    0
    Reputation
    148
    Profile views
    24
    Posts
    1
    Followers
    1
    Following
    Joined Last Online
    Website twitter.com/flaviopdiniz Location Brazil Age 31

    FlavioDiniz Unfollow Follow

    Latest posts made by FlavioDiniz

    • RE: DrawHudText interferes with Polygon Pen Tool etc

      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

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz
    • DrawHudText interferes with Polygon Pen Tool etc

      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

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz
    • RE: DrawHUDText issue with viewport camera navigation

      Thanks a lot @i_mazlov !
      The issue is solved !

      posted in Bugs
      FlavioDinizF
      FlavioDiniz
    • RE: BaseDraw.DrawTexture Issue

      Fantastic @i_mazlov !
      Both issues are solved, thank you so much !

      Cheers,
      Flavio Diniz

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz
    • BaseDraw.DrawTexture Issue

      Hi !
      In an attempt to circumvent a bug in the DrawHUDText and DrawMultipleHUDText (link below), I'm trying to use the DrawTexture function, but now we have two issues.
      (https://developers.maxon.net/forum/topic/15394/drawhudtext-issue-with-viewport-camera-navigation)

      1 - The first issue is the mouse cursor doesn't orbit to the object in the viewport, it's like the text is being drawn in the whole screen and the camera is orbiting around the text... I tested several Zdepth settings. no luck.

      2 - The second issue is the lag, notice the difference in C4D 2023 and 2025 in the video below (problem is also present in 2024).

      So far I noticed the lag (and the camera orbit issue) on the DrawHUDText, DrawMultipleHUDText and DrawTexture functions. Other simple functions like DrawPoint2D, DrawLine2D and DrawLine does't have issues.

      The code I'm using on a tag is:

      import c4d
      from c4d import plugins, bitmaps, documents
      
      def main() -> None:
          pass
      
      def draw(bd) -> bool:
          bh = c4d.plugins.BaseDrawHelp(bd, doc)
          bd.LineZOffset(2)
      
          bd.SetMatrix_Screen()
      
          text = "My Tex asssssssssssssssssssdasdasdt"
      
          cm = c4d.bitmaps.GeClipMap()
          cm.Init(0, 0, 32)
          cm.BeginDraw()
          width = cm.TextWidth(text)
          height = cm.TextHeight()
          cm.EndDraw()
          cm.Destroy()
      
          cm.Init(width, height, 32)
          cm.BeginDraw()
          cm.SetColor(255, 255, 255, 255)
          cm.TextAt(0,0,text)
          cm.EndDraw()
          bd.SetMatrix_Screen()
          bd.SetLightList(c4d.BDRAW_SETLIGHTLIST_NOLIGHTS)
      
          xpos=255
          ypos=255
      
          padr = [(c4d.Vector(xpos,ypos,0)), (c4d.Vector(xpos+width,ypos,0)), (c4d.Vector(xpos+width,ypos+height,0)), (c4d.Vector(xpos,ypos+height,0))]
          cadr = [(c4d.Vector(1,1,1)), (c4d.Vector(1,1,1)), (c4d.Vector(1,1,1)), (c4d.Vector(1,1,1))]
          vnadr = [(c4d.Vector(0,0,1)), (c4d.Vector(0,0,1)), (c4d.Vector(0,0,1)), (c4d.Vector(0,0,1))]
          uvadr = [(c4d.Vector(0,0,0)), (c4d.Vector(1,0,0)), (c4d.Vector(1,1,0)),(c4d.Vector(0,1,0))]
      
          cmbmp = bitmaps.BaseBitmap()
          cmbmp = cm.GetBitmap()
          bmp = bitmaps.BaseBitmap()
          bmp = cm.GetBitmap()
          alpha = bmp.GetInternalChannel()               #Get at the RGBA channels of the bitmap copy
          alpha = bmp.AddChannel(True, False)
      
          bd.SetDepth(False)
          bd.DrawTexture(bmp,padr,cadr,vnadr,uvadr,4,c4d.DRAW_ALPHA_NORMAL,c4d.DRAW_TEXTUREFLAGS_0)
      
          return True
      

      There's nothing special on the code, we can also see the issue with a simpler code:

      import c4d
      def main() -> None:
          pass
      def draw(bd: c4d.BaseDraw) -> bool:
          bd = doc.GetActiveBaseDraw()
          bd.DrawHUDText(200,200,"TESTING TEXT")
      
          return c4d.DRAWRESULT_OK
      

      I'm also attaching my C4D file:
      draw_hud_text_issue2.c4d

      That said, is there any working way to write text to the viewport with Python ?

      Thanks in advance !
      Flavio Diniz

      posted in Cinema 4D SDK 2025 python
      FlavioDinizF
      FlavioDiniz
    • RE: BaseDraw.DrawHUDText in Cinema4D 2024

      @ferdinand said in BaseDraw.DrawHUDText in Cinema4D 2024:

      But generally speaking, no, DrawHUDText is not broken, at least not our knowledge.

      Hi @ferdinand , sorry if this is an inappropriate place to post, but I should remember there's a bug on DrawHudText.
      It's not related to the issue @Runner009 related, but this one: https://developers.maxon.net/forum/topic/15394/drawhudtext-issue-with-viewport-camera-navigation

      I just downloaded the script you provided in the post above and tested in C4D 2024.2.0, and the issue exists, not sure if it was fixed in C4D 2024.4.

      Best,
      Flavio Diniz

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz
    • RE: DrawHUDText issue with viewport camera navigation

      I think it must be a bug ! and I'm surprised I haven't heard anyone talking about this so far, since the "DrawHUDText" is so common for people to use 🤔
      I also noticed the same problem happening with "DrawMultipleHUDText".

      Thanks!
      Flavio Diniz

      posted in Bugs
      FlavioDinizF
      FlavioDiniz
    • DrawHUDText issue with viewport camera navigation

      Hi!

      I made an script back in C4D 2023 to draw some information on the viewport (filename, camera lens, frame number, etc). It was working perfectly in C4D 2023, but in 2024 it is glitching the viewport camera navigation.

      It's like the drawn text is in front of everything and when you click to orbit the camera, you click on the drawn text instead of the object.

      Let me try to explain with some GIFs.
      2023: I click on the corner of the cube to orbit the camera around it and it works.
      Cinema_4D_ocPCAax3qM.gif

      2024: I click on the corner of the cube to orbit the camera and the orbit pivot insn't on the cube, but on the center of the screen.
      Cinema_4D_HsHckRZN05.mp4_1024px_24fps.gif

      It's not about the navigation mode, I already made sure I'm on the "mouse" mode.
      bb6d1516-d622-4351-8780-ee9bc7318b0a-image.png

      When I delete the script on 2024, everything goes back to the normal, so I know the problem is the script.

      and here it is, it's on a python tag:

      # Playblast Overlay by Flavio Diniz
      import c4d
      
      def main() -> None:
          pass
      
      def draw(bd: c4d.BaseDraw) -> bool:
          bd = doc.GetActiveBaseDraw()
      
          frame = bd.GetFrame()
          right = frame["cr"]
          bottom = frame["cb"]
      
          camera = "Camera: "+ bd.GetSceneCamera(doc).GetName()
          filename =  doc[c4d.DOCUMENT_FILEPATH].split("\\",-1)[-1]
          focal = str(bd.GetSceneCamera(doc)[c4d.RSCAMERAOBJECT_FOCAL_LENGTH]) +" mm"
          frame = "Frame: "+ str(doc[c4d.DOCUMENT_TIME].GetFrame(doc.GetFps()))
      
          bd.DrawHUDText(int(right /2)-300, int(bottom)-20, "{0}   |   {1} - {2}   |   {3}".format(filename, camera, focal, frame))
      
          return c4d.DRAWRESULT_OK
      

      Does anyone have any idea of what could be happening ?
      Thanks!

      Flavio Diniz

      posted in Bugs 2024 python
      FlavioDinizF
      FlavioDiniz
    • RE: Get edges segments in a polygon object

      Awesome @m_magalhaes, works perfect now!
      Thank very much!

      Flavio

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz
    • RE: Get edges segments in a polygon object

      Fantastic @m_magalhaes !
      works very well! and for the use I'm planning, I will always be using parallel selection segments, so cross selections isn't a issue 🙂 !

      there's an small error, I guess it's happening because there's no polygons to the left to be checked.
      alt text

      I haven't had time to fully read your code yet, but it's already very helpful!
      I'll try to solve this error by modifying your code or building another use using you as base.

      Thank you!

      (I'll let it unsolved for today, in case someone wants to post something else, then I'll change to solved)

      Flavio Diniz

      posted in Cinema 4D SDK
      FlavioDinizF
      FlavioDiniz