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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Set the "DrawCircle" orientation to face camera

    Cinema 4D SDK
    3
    5
    625
    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.
    • mfersaouiM
      mfersaoui
      last edited by

      Hello,

      How to set the orientation of "DrawCircle" to face the camera like in Orientation Property of Null Object.

      info = c4d.HandleInfo()
      # Defines the position and the size of the circle
      circleSettings = bh.GetMg()
      circleSettings.off = info.position
      circleSettings.v1 *= 20
      circleSettings.v2 *= 20
      circleSettings.v3 *= 20
      
      # Draw the Circle
      bd.DrawCircle(circleSettings)
      

      Thank you.

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        as always, please mark your post as a question.

        Can you share a little more information about what you are actually doing? What is the context of the code you provided?

        If you want to draw a circle in screen space, the easiest thing would be to just draw a 2D circle using DrawCircle2D().

        # This example draws a 2D line, circle and point.
        
        bd.SetMatrix_Screen()
        
        center = c4d.Vector(100.0, 100.0, 0)
        tangentPoint = c4d.Vector(150.0, 100.0, 0)
        
        # draw line and circle
        bd.SetPen(c4d.Vector(0.8))
        bd.DrawLine2D(center, tangentPoint)
        bd.DrawCircle2D(center.x, center.y, tangentPoint.x - center.x)
        
        # draw point
        bd.SetPen(c4d.Vector(1.0))
        bd.DrawPoint2D(center)
        
        
        bd.SetMatrix_Matrix(None, c4d.Matrix())
        

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        mfersaouiM 1 Reply Last reply Reply Quote 0
        • mfersaouiM
          mfersaoui @s_bach
          last edited by mfersaoui

          @s_bach
          Hello,
          I want use it on the ObjectData.Draw() function.

          Here is the full code:

          def Draw(self, op, drawpass, bd, bh):
              if drawpass != c4d.DRAWPASS_HANDLES:
                  return c4d.DRAWRESULT_SKIP
          
              bd.SetMatrix_Matrix(op, bh.GetMg())
              hitid = op.GetHighlightHandle(bd)
          
              for i in xrange(self.GetHandleCount(op)):
          
                  color = c4d.GetViewColor(c4d.VIEWCOLOR_SELECTION_PREVIEW) if i == hitid else c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT)        
          
                  bd.SetPen(color)
          
                  info = c4d.HandleInfo()
                  self.GetHandle(op, i, info)
          
                  bd.DrawHandle(info.position, c4d.DRAWHANDLE_BIG, 0)
          
                  bd.SetMatrix_Matrix(op, bh.GetMg())
          
                  circleSettings = bh.GetMg()
                  circleSettings.off = info.position
                  circleSettings.v1 *= 20
                  circleSettings.v2 *= 20
                  circleSettings.v3 *= 20
          
                  bd.DrawCircle(circleSettings)
              
                  return c4d.DRAWRESULT_OK
          

          Thank you.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hello,

            using this to draw a circle at op position. You can use your handle position instead.
            The main point is retrieving the view matrix with bd.GetMg() to have you Y and X vectors lined with the view.

                   if drawpass == c4d.DRAWPASS_OBJECT:
                        rad = 20.0
                        bd.SetMatrix_Matrix(op, c4d.Matrix());
                        m = bd.GetMg();
                        m.off = bh.GetMg().off;
                        m.v3 = c4d.Vector(0.0);
                        m.v1 *= rad;
                        m.v2 *= rad;
                        bd.DrawCircle(m);
                        return c4d.DRAWRESULT_OK
            

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            mfersaouiM 1 Reply Last reply Reply Quote 2
            • mfersaouiM
              mfersaoui @Manuel
              last edited by

              @m_magalhaes
              Thank you. I made some changes but its work!

              Cheers,
              Mustapha

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