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

    Zoom Selection

    Scheduled Pinned Locked Moved Developers' Forum
    36 Posts 10 Posters 5.2k 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.
    • M Offline
      Matt666
      last edited by

      The last script was for N lindenthal. But i don't understand what he relly wants... 😕 My poor english language !!

      This last script zooms on selected entities, and hide others. The right click stops script and gives last view before starting script.

      Frenglish at its best !
      My scripts

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

        thanks Matt, i understand now (to be sure i also don't grasp N lindenthal idea - maybe with some screenshots..).

        here is my alternate idea: the script centers the selection to screen (one can assign a shortcut key). however, if say CTRL is pressed then all other objects (not in the selection) get hidden. But there is no right click.

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

          @matt666 said:

          …
          But i don't understand what he relly wants... 😕 My poor english language !!
          …

          My poor english language, too.

          What I want: Zoom selection with distance by preference. For example: I select a door and zoom it. The door comes to the middle of the screen and zooms to fill the screen. Now I measure the distance. Next selctions will be the door handle or the door hinge. If one of them is selected and zoomed, the model will only slide so that the door handle is in the middle of screen but is not zoomed. So the scale of door and the scale of door handle are the same. I see the door handle and the door in same scale (with same distance).

          How can I measure the distance to selection? How can I set the distance to an object by name?

          1 Reply Last reply Reply Quote 0
          • 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