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

    VertexMap Display (Behavior Equivalent to Double-Click)

    Scheduled Pinned Locked Moved Cinema 4D SDK
    2026pythonwindows
    3 Posts 2 Posters 21 Views 1 Watching
    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.
    • ymoonY Offline
      ymoon
      last edited by ymoon

      When you select a Vertex Map tag on an object and double-click it, the colors become visible in the viewport. How can I replicate this double-click behavior through a script?

      import c4d
      
      def main():
          obj = doc.SearchObject("PointObj")
          
          vmap_tag = None
      
          for tag in obj.GetTags():
              if tag.CheckType(c4d.Tvertexmap):
                  vmap_tag = tag
                  break
          doc.SetActiveTag(vmap_tag, c4d.SELECTION_NEW)
      
          c4d.EventAdd()
      
      if __name__ == '__main__':
          main()
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF Offline
        ferdinand @ymoon
        last edited by ferdinand

        Hey @ymoon,

        Thank you for your question. First of all, your code is more complicated than it has to be. You can just call BaseObject.GetTag to get the first tag of a specific type on an object. Also, your code already does what you are asking for, it selects the tag and therefore causes Cinema 4D to draw the vertex map in the viewport (equivalent to single clicking the tag).

        To have the Paint Tool enabled (i.e., what happens when you double click a vertex map), you could either activate the tool yourself, or just send MSG_EDIT to the tag, the message which is sent to scene elements when they are double clicked.

        Cheers,
        Ferdinand

        Code

        import c4d
        
        doc: c4d.documents.BaseDocument  # The currently active document.
        op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
        
        def main() -> None:
            """Called by Cinema 4D when the script is being executed.
            """
            if not op:
                return c4d.gui.MessageDialog("Please select an object.")
            
            tag: c4d.BaseTag | None = op.GetTag(c4d.Tvertexmap)
            if not tag:
                return c4d.gui.MessageDialog("The selected object has no Vertex Map tag.")
            
            doc.SetActiveTag(tag, c4d.SELECTION_NEW)
            tag.Message(c4d.MSG_EDIT)
            
            c4d.EventAdd()
        
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • ymoonY Offline
          ymoon
          last edited by ymoon

          @ferdinand
          Thank you. It works well. --> tag.Message(c4d.MSG_EDIT)

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