sketchucation logo sketchucation
    • Login
    šŸ¤‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Zoom in on object

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 2.7k Views 2 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.
    • Al HartA Offline
      Al Hart
      last edited by

      I want to be able to zoom in on an object - by rotating the camera and changing the field of view, rather than moving the camera like the standard zoom area does. Does anyone have this in a ruby anywhere already?

      Often when you use Zoom Area in SketchUp, the object you were trying to zoom on is no longer visible. If you were to zoom by changing the FOV, then the object would still be visible - just larger.

      The attached image shows what happens when I use the standard Zoom Area to zoom in on the sconce on the left wall.

      We have used Sketchup.active_model.active_view.zoom(Sketchup.active_model.selection) with the same results.


      zoom area.jpg

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

        Have you tried Sketchup.send_action("viewZoomToSelection:") ?
        It should work cross-platform.

        TIG

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          @tig said:

          Have you tried Sketchup.send_action("viewZoomToSelection:") ?
          It should work cross-platform.

          I just tried it - it works just the same as Sketchup.active_model.active_view.zoom(Sketchup.active_model.selection) and moves the camera over next to the wall, and you cannot see the object on the wall.

          The right solution will point the camera at the selected object, without moving the eye itself, and then adjust the FOV so that the selected object is zoomed in on from the same camera position as the original view. We can write it and post it here on SketchUcation. But if someone else has already written it, it would save us some time.

          Al Hart

          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

          1 Reply Last reply Reply Quote 0
          • Al HartA Offline
            Al Hart
            last edited by

            [These quotes are from a private message which was sent to me]

            @unknownuser said:

            @unknownuser said:

            The right solution will point the camera at the selected object, without moving the eye itself, and then adjust the FOV so that the selected object is zoomed in on from the same camera position as the original view. We can write it and post it here on SketchUcation. But if someone else has already written it, it would save us some time.

            Are you sure that's what you want?

            I don't want to change the guy's FOV at all, it stays changed, then he has to reset it to get back to what he uses.

            I just want to zoom to the selection w/o changing the FOV and then back the eye out a little.

            I wonder why Zoom to Selection does not do this already?

            But it is a good idea. You should be able to move the camera along a line from the eye to the target, and you should be able to calculate just how far to move it by measuring the selected object in the current view.


            On the other hand, I don't mind changing the FOV as much as you do, as long as the user is smart enough to use view previous to return.

            Perhaps we can make that an option.


            I got to thinking that perhaps the problem with the current zoom to selection was that it was preserving my Front View, so I changed to a non-named view by rotating a bit. Still when I selected an object, (the rectangle), on the left wall and right clicked to "Zoom Extents", it still moved the camera to the left rather than moving it towards the selected object and placed the camera on the wrong side of the wall.


            zoom area 2.jpg

            Al Hart

            http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
            IRender nXt from Render Plus

            1 Reply Last reply Reply Quote 0
            • TIGT Online
              TIG Moderator
              last edited by

              Don't you want to 'align the view to face' [or similar] first, before using 'zoom-selection'... BUT of course if the object[s] selected are 3d, then which face is going to be chosen for that alignment ???

              TIG

              1 Reply Last reply Reply Quote 0
              • Al HartA Offline
                Al Hart
                last edited by

                @tig said:

                Don't you want to 'align the view to face' [or similar] first, before using 'zoom-selection'... BUT of course if the object[s] selected are 3d, then which face is going to be chosen for that alignment ???

                Here is one method.

                This is the original view with Susan selected.

                zoom11.jpg

                If I use SketchUp Zoom to Selection, the camera is moved left and the selection is no longer visible.

                zomm12.jpg

                However, if I first point the camera at the selection and then zoom to selection it works pretty well.

                zoom13.jpg

                So, for the function I want I just need to move the target of the camera to the center of the selection before using Zoom to Selection

                Al Hart

                http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                IRender nXt from Render Plus

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  Here is the code which makes this work.

                  If points to the center of the first item in the selection set,
                  then uses SketchUp zoom to selection to do the zoom.

                  It zooms to the third, desired, image in the post previous to this one.

                  
                  	def zoom_selection	
                  		# zoom to selection by rotating camera first
                  		model = Sketchup.active_model
                  		
                  		entity = model.selection[0]
                  		if (!entity)
                  			do_error("Nothing selected")
                  			return
                  		end#if
                  		
                  	    view = model.active_view
                  	    camera = view.camera
                  	    eye = camera.eye
                  		target = camera.target
                  		up = camera.up
                  		target = entity.bounds.center
                  		camera.set(eye, target, up) # point to selection
                  		view.zoom(model.selection) # then zoom
                  	end#def
                  
                  

                  Al Hart

                  http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

                  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