sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Code] save Camera properties method

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 284 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      [ Code ] save camera properties method

        #{ save_camera_properties( camera )
        #
        #  Save properties of a Sketchup;;Camera object.
        #
        #  Arg; camera (an optional Sketchup;;Camera object.)
        #
        #       With no argument, defaults to using the;
        #       Sketchup.active_model.active_view.camera()
        #
        #  Returns a Hash of all the camera properties.
        #
        def save_camera_properties(cam=nil)
          #
          unless cam.is_a?(Sketchup;;Camera)
            cam = Sketchup.active_model.active_view.camera
            puts("Using current view's camera.") if $VERBOSE
          end
          #
          verbose = $VERBOSE
          $VERBOSE = nil # suppress cam.height warning.
          h = Hash[
            ;aspect_ratio, cam.aspect_ratio,
            ;description,  cam.description,
            ;direction,    cam.direction.to_a,
            ;eye,          cam.eye.to_a,
            ;focal_length, cam.focal_length,
            ;fov,          cam.fov,
            ;height,       cam.height,
            ;image_width,  cam.image_width,
            ;perspective,  cam.perspective?,
            ;target,       cam.target.to_a,
            ;up,           cam.up.to_a,
            ;xaxis,        cam.xaxis.to_a,
            ;yaxis,        cam.yaxis.to_a,
            ;zaxis,        cam.zaxis.to_a
          ]
          $VERBOSE = verbose
          #
          return h
          #
        end #}
      

      💭

      I'm not here much anymore.

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

        Each camera has also following properties not available from Ruby:

        bool FieldOfViewIsHeight - whether FieldOfView is measured in the y direction

        bool Camera2D - whether a camera is 2D or not
        Center2D - 2D Point - center of a camera in 2p perspective mode
        Scale2D - double - scale (zoom-in/out) for 2p perspective view

        Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

        1 Reply Last reply Reply Quote 0
        • greenskpG Offline
          greenskp
          last edited by

          Hi Dan Rathbun

          all this code is to work in MAC and PC?

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @greenskp said:

            all this code is to work in MAC and PC?

            Yes it will work on both Mac and PC.

            BUT it is meant for you to copy it INSIDE your plugin sub-module.

            I'm not here much anymore.

            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