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

    Move group to left corner of screen

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 633 Views 5 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

      @view.zoom sel[0]

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • S Offline
        sonjachr
        last edited by

        Thanks Dan for the quick reply.
        I tried it before, but what I get is the below Image. I need an Image without the green borders at the left and at the top..


        Mer_Bie_01_interpol.png

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

          Select the object.
          Change to a non-perspective Camera.
          Change to a Plan view.
          Then Zoom extents of the Selection.
          There are Sketchup.send_action methods for these:

          Sketchup.send_action(10519) ### PC only, otherwise mess on with model.active_view.camera settings... Sketchup.send_action("viewTop:") Sketchup.send_action("viewZoomToSelection:")

          TIG

          1 Reply Last reply Reply Quote 0
          • S Offline
            slbaumgartner
            last edited by

            Be aware that if the aspect ratio of the image does not match that of the view, it can not be zoomed to fill the entire view window!

            1 Reply Last reply Reply Quote 0
            • S Offline
              sonjachr
              last edited by

              Thanks for your help,

              • I draw a simple rectangle
                Then I tried:
              Sketchup.send_action(10519)  #Change to a non-perspective Camera.
              Sketchup.send_action("viewTop;")  #Change to a Plan view.
              Sketchup.send_action("viewZoomToSelection;") #Zoom extents of the Selection.
              
              
              

              Unfortunately I still have the annoying green borders as shown in the below Image. Can anybody try it and come back with his/her Image.

              I have no clue what is wrong.

              Help is very much appreciated


              Unbenannt.png

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                @sonjachr said:

                Thanks for your help,

                • I draw a simple rectangle
                  Then I tried:
                Sketchup.send_action(10519)  #Change to a non-perspective Camera.
                > Sketchup.send_action("viewTop;")  #Change to a Plan view.
                > Sketchup.send_action("viewZoomToSelection;") #Zoom extents of the Selection.
                > 
                > 
                

                Unfortunately I still have the annoying green borders as shown in the below Image. Can anybody try it and come back with his/her Image.

                I have no clue what is wrong.

                Help is very much appreciated

                First of all, the face dimensions would have to perfectly match the screen dimensions and even then the "border" would still exists after zoom extents or selection.

                I would suggest capturing the screen and paste into a image editing program and crop it.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sonjachr
                  last edited by

                  I can ' t ask the user to triim the image by himself, before my code is going to put it as a texture onto a terrain.

                  Any further ideas?

                  It seems to be the last open issue in my routine, so I am very eager to get this solved.

                  Thanks for your help

                  1 Reply Last reply Reply Quote 0
                  • sdmitchS Offline
                    sdmitch
                    last edited by

                    @sonjachr said:

                    I can ' t ask the user to triim the image by himself, before my code is going to put it as a texture onto a terrain.

                    Any further ideas?

                    It seems to be the last open issue in my routine, so I am very eager to get this solved.

                    Thanks for your help

                    I thought I had this figured out before but the code I posted quite working as soon as I posted it. Very strange. I obviously made a change and didn't know it. yada yada yada

                    This code seems to work even better than the previous anyway. Although it has a top view command it, it takes two executions if model is not already in top view. Can't imagine why it just does. So pick top view then execute.

                    
                    mod = Sketchup.active_model
                    ent = mod.active_entities
                    sel = mod.selection
                    vue = mod.active_view
                    Sketchup.send_action 10501#"viewTop;"
                    vue.zoom sel
                    fac = sel[0]
                    ulc = fac.bounds.corner(2); puts "ulc=#{ulc}"
                    dst = vue.pixels_to_model 1,ulc;
                    cor = vue.screen_coords(ulc); puts "cor=#{cor}"
                    vec = Geom;;Vector3d.new(-cor.x*dst,cor.y*dst,0)
                    tr = Geom;;Transformation.new(vec)
                    ent.transform_entities(tr,fac)
                    
                    

                    Nothing is worthless, it can always be used as a bad example.

                    http://sdmitch.blogspot.com/

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      @sonjachr said:

                      Hallo, I need your help on above issue.

                      I want to perform a view.write_image of a selected Group with coloured faces and use this Image as texture for a Terrain.

                      The only way I found to apply the Image to the Terrain in a proper way, is by
                      aligning the group to the left/upper side of the screen before writing the Image.

                      Otherwise the Image contains uncolored portions to the left and the top of the Image.

                      I tried to move the Group to the upper left Corner using the following code:

                      model = Sketchup.active_model 
                      > @view = model.active_view 
                      > 
                      > keys = { 
                      > 	;filename => @chosen_file,
                      > 	;width => @view.vpwidth, 
                      > 	;height => @view.vpheight,
                      > 	;antialias => false, 
                      > 	;compression => 0.9, 
                      > 	;transparent => true 
                      > } 
                      > 	
                      > ip0=@view.inputpoint(0,0)
                      > ip1=@view.inputpoint(@view.vpwidth,0)
                      > p0=ip0.position
                      > p1=ip1.position
                      > sel= model.selection
                      > bbox = sel[0].bounds
                      > sel[0].move! [p0.x+bbox.width/2,p0.y-bbox.height/2,0]		
                      > view.write_image keys	
                      > view.invalidate
                      > 
                      

                      Unfortunately this does not work reliable.

                      Any better ideas? Maybe there is even a more simple solution.

                      Very much appreciate your help!

                      Played around with your code and got it to work, sort of. Like mine, including top view and zoom selection commands caused it not to work.

                      .move! is only for groups and/or components and is not undoable so should be avoided.

                      Here is my version of your code.

                      #Sketchup.send_action 10501 #top view
                      #Sketchup.send_action 21469 #zoom sel
                      model = Sketchup.active_model 
                      @view = model.active_view 
                      sel= model.selection
                      0.upto(1){
                       ip0=@view.inputpoint(0,0); p0=ip0.position;
                       p1 = sel[0].bounds.corner(2);
                       sel[0].transform! Geom;;Transformation.new(p0-p1)
                      }#do it twice
                      
                      keys = { 
                         ;filename => @chosen_file,
                         ;width => @view.vpwidth, 
                         ;height => @view.vpheight,
                         ;antialias => false, 
                         ;compression => 0.9, 
                         ;transparent => true 
                      } 
                      #view.write_image keys 
                        
                      @view.invalidate
                      
                      

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        sonjachr
                        last edited by

                        Wow! This is awesome! It works!

                        Thanks a lot.
                        I almost gave up!
                        Good to know, that there are real experts in this forum who are willing to help.

                        Thanks again.

                        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