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

    [SOLVED]set standard view

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 800 Views 4 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.
    • P Offline
      Pout
      last edited by Pout

      I know it is possible to use Sketchup.send_action("viewIso:") to set the active_view to one of the standard views.
      The problem is, when this is used in a loop like this all images return equal:

      standardviews=['SV_Top','SV_Bottom','SV_Front','SV_Back','SV_Left','SV_Right','SV_Iso']
      standardviews.each{|view|
      if view=='SV_Top'
      	Sketchup.send_action("viewTop;")
      elsif view=='SV_Bottom'
      	Sketchup.send_action("viewBottom;")
      elsif view=='SV_Front'
      	Sketchup.send_action("viewFront;")
      elsif view=='SV_Back'
      	Sketchup.send_action("viewBack;")
      elsif view=='SV_Left'
      	Sketchup.send_action("viewLeft;")
      elsif view=='SV_Right'
      	Sketchup.send_action("viewRight;")
      elsif view=='SV_Iso'
      	Sketchup.send_action("viewIso;")
      end
      x = Sketchup.active_model.active_view
      path="c;\\"+Sketchup.active_model.title
      imagename = path+view.to_s+".jpg"
      Sketchup.set_status_text("Writing #{imagename}")
      x.write_image(imagename,200,200,true)
      }
      

      Now when i add a messagebox at the end of the loop it seems to goes well.
      This is probably gonna be something stupid, i really have an off day on coding SU ruby.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Are you doing that within a start_operation block that disables the UI?

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          Not 100% sure, but...

          What is the Scene transition time set to? Either set it to 0, or wait for the Scene animation to finish before writing the image.

          Hi

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pout
            last edited by

            ThomThom:
            no, but i'll give it a shot

            Jim:
            scene transitions are off

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @pout said:

              ThomThom:
              no, but i'll give it a shot

              No - I was thinking that might be why it didn't work.

              Maybe you can use view.refresh ?

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

                Ah, there are no scenes, so no scene tranistions.

                Oh, and even simpler: πŸ˜‰

                
                standardviews = %w(viewTop; viewBottom; viewFront; viewBack; viewRight; viewLeft viewIso;)
                standardviews.each do |view|
                  Sketchup.send_action(view)
                  # write image
                end
                
                

                Hi

                1 Reply Last reply Reply Quote 0
                • P Offline
                  Pout
                  last edited by

                  Thx Jim for the code update

                  ThomThom,

                  I've tried just to see if there was any diff. and there is none.
                  I also already tried to do active_view.refresh after each view switch but that doesn't help either.
                  In the API this is the explanation on send_action:
                  The send_action method sends a message to the message queue to perform some action asynchronously.

                  I don't know if this could have something to do with it

                  Btw did you try the code?

                  Extra info, if you switch pages 'scenes) in the same loop all goes well.

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Hm...
                    Tried setting the camera object itself instead of issuing the SU commands?

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • P Offline
                      Pout
                      last edited by

                      I was thinking about that.
                      But I need the standard views attributes for that so i can use them in a camera definition.
                      I have not yet found a way to adress these standard views. (or i'm looking over it completely)

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @pout said:

                        But I need the standard views attributes for that so i can use them in a camera definition.

                        ❓
                        Attributes? Camera definitions?

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          You mean how to set the camera vectors?

                          I'd think just setting the camera to match X_AXIS, YAXIS and Z_AXIS should be enough... ?

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • P Offline
                            Pout
                            last edited by

                            yes to 'copy' the standard cameras it would be great to be able to copy the eye, target and up of the standard cameras into new cameras so i can use those.
                            fact is i can't itterate over those standard cameras as shown above and i need the specific values of eye and target otherwise i need to calculate the center of the bounding box of all elements of the model to specify the eye and target.

                            At the other hand, maybe i'm lacking any sense today (you wouldn't be the first to say that today πŸ˜„)

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

                              And once you set the camera eye to target vector to suit an AXIS vector you need to use Sketchup.send_action("viewZoomExtents:") to see everything ???

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                The native standard view buttons doesn't zoom extent - but if that is what you want - then eye and target does not matter.

                                direction = Z_AXIS.reverse Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y) Sketchup.active_model.active_view.zoom_extents

                                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • P Offline
                                  Pout
                                  last edited by

                                  Overview of the code for each standard view (informative)

                                  Top

                                  direction = Z_AXIS.reverse
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Bottom

                                  direction = Z_AXIS
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Front

                                  direction = Y_AXIS
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Back

                                  direction = Y_AXIS.reverse
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Left

                                  direction=X_AXIS
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Right

                                  direction=X_AXIS.reverse
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  Iso

                                  direction=Geom;;Vector3d.new -0.666667, 0.666667, -0.333333
                                  Sketchup.active_model.active_view.camera.set( ORIGIN, direction, direction.axes.y)
                                  Sketchup.active_model.active_view.zoom_extents
                                  

                                  This emulates the standard cameras, combined with zoom extents.
                                  Credits to ThomThom!

                                  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