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

    How to draw a primitive object in BaseDraw

    Cinema 4D SDK
    python 2023 2024 s26
    2
    3
    573
    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.
    • gheyretG
      gheyret
      last edited by

      Hi everyone!
      I try to draw a primitive object like Plane, Cube, e.t.c with Tooldata.Draw().
      And in BaseDraw, i saw it have tow method to draw object:

      • BaseDraw.DrawPolygonObject()
      • BaseDraw.DrawObject()

      I've tried both methods in my code, but it's not working

      def Draw(self, doc, data, bd, bh, bt, flags):
          bd.SetMatrix_Screen()
          
          obj = c4d.BaseObject(c4d.Ocube)
          bd.DrawPolygonObject(bh, obj, flags=c4d.DRAWOBJECT_NONE, parent=None, col=Vector(0.5))
          bd.DrawObject(bh, obj, flags=c4d.DRAWOBJECT_NONE, drawpass=c4d.DRAWPASS_OBJECT, parent=None, col=Vector(0.5))
      
          return c4d.TOOLDRAW_NONE
      

      The explanation of both methods in the documentation is simple and straightforward.
      And i'm not sure if I can't use these two methods in ToolData, or am I misunderstanding something?

      www.boghma.com

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

        Hey @gheyret,

        Thank you for reaching out to us. Your obj there has no cache. You just instantiated it, there is nothing to draw. We talked about cache building multiple times on the forum, for example here. In the geometry model section of our Python examples, I also went over caches and cache building in geometry_caches_s26.py.

        You should however be careful with the amount of work you do in Draw. Although the method is despite its name not actually a drawing method and would be more aptly named as GetDrawingInstructions, you should still go for performance there. Building complex geometry there is not a good idea. Either build your inputs beforehand, or better, draw primitives like a cube yourself (constructed out of shaded polygons or lines).

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        gheyretG 1 Reply Last reply Reply Quote 0
        • gheyretG
          gheyret @ferdinand
          last edited by

          Hi @ferdinand

          Thank you for your reply and guidance. I'll get around to it.

          Cheers 🍻
          Gheyret

          www.boghma.com

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