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

    BaseDraw.DrawTexture Issue

    Cinema 4D SDK
    2025 python
    2
    3
    636
    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.
    • FlavioDinizF
      FlavioDiniz
      last edited by

      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

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

        Hi Flavio Diniz,

        Thank you for providing an extensive description of your issue.

        I've updated the original thread about the DrawHUDText issue. I don't see the orbiting center issue anymore after applying the change to the python tag code, namely adding the following early exit condition to the draw function:

            if bd.GetDrawPass() != c4d.DRAWPASS_OBJECT or bd.GetDrawParam(c4d.BASEDRAW_IS_PICK_OBJECT):
                return True
        

        The same thing stands for the lag issue - I cannot reproduce it with the patched python tag code.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

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

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

          Cheers,
          Flavio Diniz

          1 Reply Last reply Reply Quote 0
          • i_mazlovI i_mazlov forked this topic on
          • First post
            Last post