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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Zoom Selection

    Scheduled Pinned Locked Moved Developers' Forum
    36 Posts 10 Posters 5.4k Views 10 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.
    • J Offline
      Jim
      last edited by

      @cadfather said:

      ok, this is what happens to the script: if i am inside of a group/component and 'hide rest of model' is on, zoom selection does not work. surely this must happen to everyone?

      You are correct, it does not work. There are 2 ways to zoom to a selection using the API and they both fail when "hide rest of model" is enabled.

      I'm not seeing a quick solution other than Matt's idea of temporarily switching 'hide rest' on, zooming, and then switching it off again.

      I'm sure a better "Zoom to Selection" could be written, though - one that would work in all configurations.

      Hi

      1 Reply Last reply Reply Quote 0
      • CadFatherC Offline
        CadFather
        last edited by

        Jim, you mean if a script was written from scratch it could be done?

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          @cadfather said:

          Jim, you mean if a script was written from scratch it could be done?

          Yes, a camera zoom is simply moving the camera closer to the target, and can be done using Ruby.

          Hi

          1 Reply Last reply Reply Quote 0
          • N Offline
            N Lindenthal
            last edited by

            @jim said:

            …
            a camera zoom is simply moving the camera closer to the target, and can be done using Ruby.

            Please, Jim, tell me how to move the camera to a selected item with distance of 2 meter by ruby script.

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              model = Sketchup.active_model
              view = model.active_view
              camera = view.camera
              
              eye = camera.eye
              target = camera.target
              up = camera.up
              
              vector = target - eye
              vector.length = 2.m
              eye = eye + vector
              
              camera.set eye, target, up
              
              

              Hi

              1 Reply Last reply Reply Quote 0
              • N Offline
                N Lindenthal
                last edited by

                Unbelievably, Jims code moves my model. Thank you very much.

                I have to play a lot, because I don’t understand, what the code makes. Repeating brings my model nearer and nearer. Change the unit from 2. to 2000. makes bigger steps. Change the unit from 2000. to -2000. turns the direction (the model goes remote).

                So, how can I see one part of my model with distance of 2 meters?

                1 Reply Last reply Reply Quote 0
                • R Offline
                  RickW
                  last edited by

                  I think if the last 4 lines are

                  vector = eye - target
                  vector.length = 2.m
                  eye = target + vector
                  
                  camera.set eye, target, up
                  
                  

                  then you will get the desired result

                  RickW
                  [www.smustard.com](http://www.smustard.com)

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    N Lindenthal
                    last edited by

                    Sometimes RickWs code works pretty. But often it does not work. Then sometimes the error is:
                    @unknownuser said:

                    Error: #<ArgumentError: (eval):197:in 'set': Eye and target points must be different>

                    My goal is to select one item by name and to show this item with camera with distance 2 meters.

                    1 Reply Last reply Reply Quote 0
                    • N Offline
                      N Lindenthal
                      last edited by

                      @n lindenthal said:

                      …
                      But often it does not work.
                      …

                      To make it work, I had to »Start Animation Observer«.

                      @Rick
                      Your code works properly. Thank you very much.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        D1scon
                        last edited by

                        @pixero said:

                        @cadfather said:

                        if i select something inside of a group it does not work - but will fit the contents to screen if nothing is selected.

                        What do you mean with "It doesnt work" ? What do you want it to do?
                        If you are inside a group the group itself isn't selected.
                        My script zooms in to whats selected. Inside group or not.

                        Thx a lot! Great plugin. Work fine, no problem with selection zoom.
                        Can you recommend me any other useful plug?

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

                        Advertisement