Multiple flip in component red axis
-
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.
-
@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);}
-
@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.
-
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.
-
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.
Advertisement