Undoing all transformations
-
I'm pretty sure I've seen this before but I can't find the answer... so sorry in advanced if this is a repeat question.
I'd like to remove all transformation for a given instance... so basically reverse what ever moves and rotations were done.
I can get the transformation array,
e.transformation.to_a
and i tried setting everything back to 0 bu that didn't work...
Thanks
-
Maybe this?
mod = Sketchup.active_model ent = mod.entities sel = mod.selection cmp=sel.first t=cmp.transformation.to_a t[0]=1;t[1]=0;t[2]=0;#t[3]=nil t[4]=0;t[5]=1;t[6]=0;#t[7]=nil t[8]=0;t[9]=0;t[10]=1;#t[11]=nil t[12]=0;t[13]=0;t[14]=0;#t[15]=nil cmp.transformation=cmp.transformation.set! t
-
sdmitch, just had a chance to try it out and it does work...
Thanks!
-
Also, to reset all transformations and puts the instance g at the origin, just use
g.transformation = Geom::Transformation.new
If you have a state before some transformations are made to the instance, you can save the state with (
clone
is important)
tr0 = g.transformation.clone
Then, later, you can resume this state with
g.transformation = tr0
Note that the transformation of an instance corresponding to
g.transformation
is always in the context of its parent. -
Thanks for all that info fredo... It'll certainly come in handy
Advertisement