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

    Check "if view?"

    Scheduled Pinned Locked Moved Plugins
    7 Posts 3 Posters 250 Views 3 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.
    • CadFatherC Offline
      CadFather
      last edited by Gábor

      does anyone know if there is a way to check whether one is aligned to a standard view (current view)?

      tried various combinations, "if view=='ViewTop" etc. there seems to be nothing in the api.

      Thanks

      1 Reply Last reply Reply Quote 0
      • jiminy-billy-bobJ Offline
        jiminy-billy-bob
        last edited by

        This will return true if the view is looking straight down (top view)
        if Sketchup.active_model.active_view.camera.zaxis == [0,0,-1]

        25% off Skatter for SketchUcation Premium Members

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

          I like Camera#direction - it's more clear than zaxis.

          Vector3d#parallel? and Vector3d#samedirection? might be better than == since they consider tolerance.

          Hi

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

            thanks J, that's promising!

            EDIT: something's moving...! will report back 😆

            yes....just wonderful, all works great.

            Jim, are you trying to scare me? 🤓 😲

            Thanks!

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

              @cadfather said:

              Jim, are you trying to scare me? 🤓 😲
              Thanks!

              Not very scary.

              
              cam_dir = Sketchup.active_model.active_view.camera.direction
              if cam_dir.samedirection?(Y_AXIS)
                # Front
              elsif cam_dir.samedirection?(Y_AXIS.reverse)
                # Back
              elsif cam_dir.samedirection?(X_AXIS)
                # Left
              elsif cam_dir.samedirection?(X_AXIS.reverse)
                # Right
              elsif cam_dir.samedirection?(Z_AXIS)
                # Bottom
              elsif cam_dir.samedirection?(Z_AXIS.reverse)
                # Top
              else
                # Not aligned to Std View
              end
              
              

              Hi

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

                Jim, that neat way, makes perfect sense..! 😄

                here's the follow up to the previous if anyone has any idea:

                working with this below, all good. but are there not controls for the 'look around' tool as well?
                (nothing in the api)

                   def onKeyDown(key, repeat, flags, view)
                		case key
                		 when @upArrow  then  Sketchup.active_model.active_view.zoom 1.01
                		 when @downArrow  then  Sketchup.active_model.active_view.zoom 0.99
                		end
                

                what i'm trying to achieve is a plugin that will use the keyboard to incrementally spin and turn around the model or a selection. (will be out in 2019).

                1 Reply Last reply Reply Quote 0
                • jiminy-billy-bobJ Offline
                  jiminy-billy-bob
                  last edited by

                  Indeed much nicer way to do it, jim 😉

                  25% off Skatter for SketchUcation Premium Members

                  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