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

    Centre of Perspective view

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 657 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 30/10/2012 at 05:05, xxxxxxxx wrote:

      Finally got back to a bit of programming.

      I want to put something at the centre of the perspective view as a guide.

      What is the best method to use here to plot my line 
      ie how do I always guarantee the centre of the viewport when it is something that changes?

      tia

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 30/10/2012 at 11:05, xxxxxxxx wrote:

        Hi,
        If you mean something like crosshairs you could use the bd.GetFrame() in the Draw function to get the screen dimensions and calculate the center.
        Then you could draw there a point, a line or a circle with the corresponding 2D BaseDraw functions.
        Hope that helps.
        Phil

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 31/10/2012 at 03:25, xxxxxxxx wrote:

          thanks for hint

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 08/11/2012 at 01:20, xxxxxxxx wrote:

            After various tinkerings

            Do I take it that cannot be done in a simple script?

            Doing it in a tag seems cumbersome and even that doesn't seem to work in the python generator

            only sensible options appears to be to write a full blown plugin?

            Seems real overkill when I just want a user defined circle on the screen

            or have I missed something

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 08/11/2012 at 11:11, xxxxxxxx wrote:

              Hi.
              I'm not quite sure what you're trying to do. 
              If you put a python tag with this code on an object it will jump to the center of your camera:

              import c4d  
              from c4d import utils  
              #Welcome to the world of Python  
                
                
              def main() :  
              bd = doc.GetActiveBaseDraw()  
              cam = bd.GetSceneCamera(doc)  
              mg = cam.GetMg()  
                tm = c4d.utils.MatrixMove(c4d.Vector(0,0,10)) #Move the object a little bit in front of the camera  
              mg = mg * tm  
              op.GetObject().SetMg(mg)
              

              I tried it with a circle spline with a diameter of 0.1cm and this should do the trick, if that's what you're after. This only works if the playhead in your timeline is moving or any other event happens, not by just moving the camera.
              Phil

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 11/11/2012 at 15:24, xxxxxxxx wrote:

                Thanks
                Just want a variable circle that centres in the viewport. ie a drawn circle not and OM object.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 12/11/2012 at 01:07, xxxxxxxx wrote:

                  It's easy enough to obtain a viewport, get a BaseDraw, and draw a circle on the screen. The problem you have is that it won't stay there. As soon as there's a screen update, it might disappear.

                  So what you need is some way to ensure that your drawing routine is called every time there is a screen update. That's why you can't use a script, because that's only executed once. You need a plugin with a Draw() function as part of its interface. Lots of them do - ObjectData, TagData, ToolData, SceneHookData, etc.

                  I'd look at a SceneHookData in the first instance, if you can do those in Python. If not, a TagData would be the next choice for me.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 13/11/2012 at 01:54, xxxxxxxx wrote:

                    That was the problem. Trying to work out how to keep the thing visible. A tag seems really clunky - will take a look at SceneHookData.

                    ta

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