Undoing all transformations  Topic is solved

Undoing all transformations

Postby Frankn » Tue Aug 28, 2018 6:28 pm

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,
Code: Select all
e.transformation.to_a
and i tried setting everything back to 0 bu that didn't work...

Thanks
0

Frankn 
 

Re: Undoing all transformations  Topic is solved

Postby sdmitch » Wed Aug 29, 2018 2:51 pm

Maybe this?

Code: Select all
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

1
Nothing is worthless, it can always be used as a bad example.

http://sdmitch.blogspot.com/
User avatar
sdmitch 
PluginStore Author
PluginStore Author
 

Re: Undoing all transformations

Postby Frankn » Thu Aug 30, 2018 7:08 pm

sdmitch, just had a chance to try it out and it does work...

Thanks!
0

Frankn 
 

Re: Undoing all transformations

Postby fredo6 » Fri Aug 31, 2018 6:40 pm

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.
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: Undoing all transformations

Postby Frankn » Sat Sep 08, 2018 6:05 pm

Thanks for all that info fredo... It'll certainly come in handy
0

Frankn 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 11 guests

Visit our sponsors: