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!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Rotation about the origin

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 319 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.
    • R Offline
      rossthompson
      last edited by

      Hi guys,

      I am trying to write a script that very simply rotates selected objects by 90 degrees in the Z axis. I have put together some code but it isn't working. Can anyone help? I am new to Ruby so I have probably made some really basic mistakes.

      Ross

      
      require 'sketchup.rb'
      
      
      # Add a menu item
      UI.menu("PlugIns").add_item("rotate90") {  
        rotate90	# Call method.
      }
      
      def rotate90
      	rv = Geom;;Vector3d.new(0,0,1)
      	ra = 90.degrees
      	rp = Geom;;Point3d.new(0,0,0) 
      
      	Sketchup.active_model.Transformation.rotation(rp, rv, ra))
      	
      end
      
      
      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        require 'sketchup.rb'
        
        
        # Add a menu item
        UI.menu("PlugIns").add_item("rotate90") { rotate90 }  # Call method.
        
        def rotate90
           
           mod = Sketchup.active_model
           ent = mod.entities
           sel = mod.selection
        
           rv = Geom;;Vector3d.new(0,0,1)
           ra = 90.degrees
           rp = Geom;;Point3d.new(0,0,0) 
        
        # define the rotation transformation
           trr = Geom;;Transformation.rotation(rp, rv, ra)
        # apply the rotation transformation to the selection
           ent.transform_entities(trr,sel.to_a)
           
        end
        
        

        You were close. Use http://code.google.com/apis/sketchup/docs/index.html to help with syntax.

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

        http://sdmitch.blogspot.com/

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

          Sam,

          Thanks very much that works perfectly.

          Ross

          1 Reply Last reply Reply Quote 0
          • bigstickB Offline
            bigstick
            last edited by

            Are you planning to build on your programming skills and add functionality to this?

            What I have always found really frustrating is when you use the group/component 'handles' to rotate components. It is a neat time-saver, but for years I have always wanted to rotate about a component's origin.

            Alternatively if anyone else out there has a plugin that does this, I would be grateful if someone could please point me in its direction.

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

              @bigstick said:

              Are you planning to build on your programming skills and add functionality to this?

              What I have always found really frustrating is when you use the group/component 'handles' to rotate components. It is a neat time-saver, but for years I have always wanted to rotate about a component's origin.

              Alternatively if anyone else out there has a plugin that does this, I would be grateful if someone could please point me in its direction.

              Check out Rotate&Scale on my blog. It works with groups and components and rotation is about the origin.

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

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • daikuD Offline
                daiku
                last edited by

                This already exists here:

                http://rhin.crai.archi.fr/rld/plugin_details.php?id=345

                and here:

                http://forums.sketchucation.com/viewtopic.php?f=323&t=9739&hilit=rot90

                Perfect for mapping to a shortcut key.

                Clark Bremer
                http://www.northernlightstimberframing.com

                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