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

    Display points

    Cinema 4D SDK
    python
    2
    2
    542
    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.
    • merkvilsonM
      merkvilson
      last edited by merkvilson

      Hello PluginCafe!

      I'm trying to display object points via the tag plugin.
      The code worked fine in older versions of C4D but it has no effect in the latest versions.
      Am I doing anything wrong?

          def Draw(self, tag, op, bd, bh):
      
              bd.SetPen( c4d.Vector(1))
              bd.SetPointSize( 3 )
              bd.SetMatrix_Screen()
              bd.SetDepth(True)
              objMg = op.GetMg() #Get the world (global) matrix 
      
              ptList = op.GetCache().GetAllPoints()
      
              points = [objMg * p for p in ptList]  # Retrieves Global Coordinates
              screenPoints  =  [ bd.WS(p) for p in points ]  # From world to screen Coordinates (in another array)
              bd.DrawPoints(screenPoints, vc = None, colcnt=1, vn=None)
      
              return c4d.DRAWRESULT_OK
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @merkvilson
        last edited by

        Hello @merkvilson,

        thank you for reaching out to us. It would have been helpful to indicate what you would consider older and the latest version of Cinema 4D in this context, but I assume your problem is caused by you using a pre-S22 TagData plugin which implements TagData.Draw in a S22+ version.

        With S22, the flag TAG_IMPLEMENTS_DRAW_FUNCTION has been added to c4d.plugins.RegisterTagPlugin. You must pass it, when you want the method to be called.

        I would also point out that ptList = op.GetCache().GetAllPoints() is rather risky, as is assumes op to always have a cache which is a point object. Objects can have no caches and caches can contain other things than point objects. You should be a bit more defensive here, even if you intend to only use the plugin 'in this one scenario where this will work'.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

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