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_aand 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.newIf you have a state before some transformations are made to the instance, you can save the state with (
cloneis important)
tr0 = g.transformation.cloneThen, later, you can resume this state with
g.transformation = tr0Note that the transformation of an instance corresponding to
g.transformationis always in the context of its parent. -
Thanks for all that info fredo... It'll certainly come in handy
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement