• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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.
  • A Offline
    alexandre sk
    last edited by 22 Feb 2015, 04:43

    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
    • S Offline
      sdmitch
      last edited by 22 Feb 2015, 17:26

      @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 22 Feb 2015, 17:40

        @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 22 Feb 2015, 19:31

          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
          • A Offline
            alexandre sk
            last edited by 24 Feb 2015, 04:15

            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
            1 / 1
            • First post
              5/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement