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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Setting up camera/scene using Ruby

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 811 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.
    • T Offline
      ttype
      last edited by

      I want to export from Rhino to SU. Unfortunately Rhino's exporter for SU doesn't export cameras so that they end up being scenes in SU. So I wrote a script that gets the camera's data from Rhino and generates a Ruby script that I can then just paste in SU. Here is my camera in Rhino:
      camera.png

      And that's the script generated:
      ` eye = [0.0,-25.0,2.0];
      target = [0.0,0.0,2.0];
      up = [0.0,0.0,1.0];

      camera = Sketchup::Camera.new eye, target, up;
      camera.focal_length = 50.0;

      view = Sketchup.active_model.active_view;
      view.camera = camera;

      page = Sketchup.active_model.pages.add('Perspective')`

      And here are the two views:
      suview.jpg
      rhinoview.jpg

      Unfortunately the latter box is a tiny bit closer. Can someone perhaps tell me what I need to do here to get the exact same views?

      1 Reply Last reply Reply Quote 0
      • jiminy-billy-bobJ Offline
        jiminy-billy-bob
        last edited by

        I'd guess that the focal length sets the horizontal FOV in one case, and vertical FOV in the other case.

        25% off Skatter for SketchUcation Premium Members

        1 Reply Last reply Reply Quote 0
        • T Offline
          ttype
          last edited by

          Thank you!

          I am not 100% sure yet, because documentation on both sides is rather vague, but right now it looks like this is always(?) working:

          camera.focal_length = lens_length_in_Rhino * 1.5;

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

            SU's FOV is by default the vertical (height) axes. Which is something that always tripped me up. Use the camera.fov_is_heigh? to determin if fov is vertical or horizontal: http://ruby.sketchup.com/Sketchup/Camera.html#fov_is_height%3F-instance_method

            You might have to take into account the aspect ratio of the SU viewport and your target viewport.

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

            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