sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Multiple flip in component red axis

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 353 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.
    • alexandre skA Offline
      alexandre sk
      last edited by

      Hello people. Trying to make a simple plug-in for a specific purpose but cant find the command.

      When I right click a component it appears Flip>Flip component red axis, but when I selected multiple it flip all together not individually. I am clear? I think not. Anyway, if someone can point me the command line that do that maybe I can make the simple plug-in.

      Or maybe already exist one.

      The use, is: If I have a LOT of cars ( components ), with different rotations and i just want to reverse the cars direction, i have to do individually.

      Thanks.

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

        @alexandre sk said:

        Hello people. Trying to make a simple plug-in for a specific purpose but cant find the command.

        When I right click a component it appears Flip>Flip component red axis, but when I selected multiple it flip all together not individually. I am clear? I think not. Anyway, if someone can point me the command line that do that maybe I can make the simple plug-in.

        Or maybe already exist one.

        The use, is: If I have a LOT of cars ( components ), with different rotations and i just want to reverse the cars direction, i have to do individually.

        Thanks.

        Perhaps this one-liner will do what you want. It will flip the x for all selected.

        Sketchup.active_model.selection.grep(Sketchup;;ComponentInstance).each{|c|xa=c.transformation.xaxis.reverse;t=c.transformation.to_a;t[0]=xa.x;t[1]=xa.y;t[2]=xa.z;c.transformation=c.transformation.set!(t);}
        

        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
          slbaumgartner
          last edited by

          @sdmitch said:

          Perhaps this one-liner will do what you want. It will flip the x for all selected.

          Sketchup.active_model.selection.grep(Sketchup;;ComponentInstance).each{|c|xa=c.transformation.xaxis.reverse;t=c.transformation.to_a;t[0]=xa.x;t[1]=xa.y;t[2]=xa.z;c.transformation=c.transformation.set!(t);}
          

          This will flip the components around their origin without moving the origin. If you want to emulate what the GUI's "flip around component axis" does you will need to also move the components after flipping.

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

            If you load the attached Ruby and then type flip_all_x in the Ruby Console, it will replicate the action of flip along component's red axis for every ComponentInstance or Group in the current selection. This is just an extension of sdmitch's code unwrapped as a file and fixed for the origin shift.

            flip_all_x.rb

            1 Reply Last reply Reply Quote 0
            • alexandre skA Offline
              alexandre sk
              last edited by

              fantastic as always. Thank you slbaumgartner and sdmitch. The flip all x works perfectly! The sdmitch code already was great. This forum is always great.

              I will make a simple free plug-in to help road build, and share here when it is ready.

              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