sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Camera API not working properly?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 429 Views 3 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.
    • renderizaR Offline
      renderiza
      last edited by

      Hi,

      I am testing some code with camera and things are not working, here is example of just one of many;

       camera = Sketchup;;Camera.new
       status = camera.perspective?
       if (status)
         UI.messagebox "Perspective"
       else
         UI.messagebox "Orthographic"
       end
      

      It always says its on Perspective even when its not. πŸ˜•

      Other examples found here doesn't work as well.. http://www.sketchup.com/intl/en/developer/docs/ourdoc/camera.php#perspective?

      I am using Ruby Code Editor to test this code...Any ideas on what is wrong here?

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • renderizaR Offline
        renderiza
        last edited by

        That worked..thank you very much!

        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Yeah, you're not actually testing the state oft he current camera being used in the model, your testing the state of a new camera object - Sketchup::Camera.new. And it looks like new cameras default to perspective. Instead, try this:

          camera = Sketchup.active_model.active_view.camera
          status = camera.perspective?
          if (status)
          UI.messagebox "Perspective"
          else
          UI.messagebox "Orthographic"
          end

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            I do see that what you put there is taken verbatim from the API..... what can I say, oops! We'll need to upgrade those examples.

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @chris fullmer said:

              I do see that what you put there is taken verbatim from the API..... what can I say, oops! We'll need to upgrade those examples.

              And many more. cough #typename cough

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • renderizaR Offline
                renderiza
                last edited by

                Hi,

                I require some help again. 😳

                I can't get the following code to do;

                1. Change current scene from "Perspective" to "Orthographic". <--This is done fine

                2. Update current page and preserve "Orthographic" camera. <--The code changes from Persp to Ortho but when I click on page again it changes back to Persp.

                How can I solve this?

                model = Sketchup.active_model ;
                pages = model.pages ;
                page = pages.selected_page
                
                camera = Sketchup.active_model.active_view.camera ;
                status = camera.perspective? ;
                if (status)
                    Sketchup.send_action(CMD_VIEW_PERSPECTIVE) ;
                end ;
                
                page.update(1) ;
                

                Again thanks for the help! πŸ‘

                [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  model = Sketchup.active_model camera = model.active_view.camera camera.perspective = false model.pages.selected_page.update(1)

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • renderizaR Offline
                    renderiza
                    last edited by

                    Thanks it worked! 😍

                    [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement