• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Camera API not working properly?

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 3 Posters 349 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.
  • R Offline
    renderiza
    last edited by 26 May 2013, 22:58

    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
    • R Offline
      renderiza
      last edited by 27 May 2013, 02:11

      That worked..thank you very much!

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

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 27 May 2013, 02:14

        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
        • C Offline
          Chris Fullmer
          last edited by 27 May 2013, 02:18

          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
          • T Offline
            thomthom
            last edited by 27 May 2013, 07:42

            @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
            • R Offline
              renderiza
              last edited by 27 May 2013, 15:52

              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
              • T Offline
                thomthom
                last edited by 27 May 2013, 16:30

                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
                • R Offline
                  renderiza
                  last edited by 27 May 2013, 16:58

                  Thanks it worked! 😍

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

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

                  Advertisement