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

    Get mouse coordinates from viewport

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 132 Views
    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.
    • H Offline
      Helper
      last edited by

      On 09/01/2013 at 14:56, xxxxxxxx wrote:

      Hi
      This is a complete noob question so please bare with me.
      Im trying to write a script that uses Vray to render a user selected region to the pictureviewer. Its supposed to work like the built in C4d Render region command just that it render the area to the picture viewer instead. I stumble upon a couple of problems.
      - How can i get the mouse coordinates (user drags out a rectangle) from the viewport.
      - How can i convert the above coordinates to percentage values of the viewport size.

      I have figured out how to set the region in the Render settings, but im completely lost on the mouse/viewport thing 🙂
      I really wish the SDK had more meaningful examples. This would make it so much easier for noobs like myself to learn faster.

        
      import c4d   
      import sys   
      from c4d import documents, bitmaps, gui   
      #Welcome to the world of Python   
        
      doc = documents.GetActiveDocument()   
      rd = doc.GetActiveRenderData()   
      post = rd.GetFirstVideoPost()   
        
      if post == None:   
          pass   
      else:   
          while post:   
              if post.GetType() == 1019782: ## if Video Post Effect is V-Ray Bridge   
                  vray = post   
                  post = None ## changes post object to none so the loop is broken         
              else:         
                  post = post.GetNext() ## Try the next Post-Effect   
        
          vray[c4d.VP_VRAYBRIDGE_REGIONON] = True # Turns on Render region in the Vray effect      
          vray[c4d.VP_VRAYBRIDGE_REGIONRENDER_X1] = 0.1 #Sets the values for the region in the Vray effect   
          vray[c4d.VP_VRAYBRIDGE_REGIONRENDER_Y1] = 0.1   
          vray[c4d.VP_VRAYBRIDGE_REGIONRENDER_X2] = 0.9   
          vray[c4d.VP_VRAYBRIDGE_REGIONRENDER_Y2] = 0.9   
      

      Any help appreciated

      Cheers
      Bonsak

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