Geom::Transformation

Geom::Transformation

Postby anteolic » Fri Aug 11, 2017 1:03 pm

I am totaly beginner in Sketchup scripting.


This code move object to some position,

trans = Geom::Transformation.new(bb.center.vector_to([100,0,0])) ; # move the temp bounding box

How is posible to move object just by zaxis and other axis dont affect.
0
User avatar
anteolic 
 

Re: Geom::Transformation

Postby TIG » Fri Aug 11, 2017 1:25 pm

Your example uses a point [100,0,0] to move the object 100 inches along the X_AXIS.
To move it in the Z_AXIS just try [0,0,100]

Also it'll be best to do a simple 'translate' rather than '[re]locate' it ?
trans = Geom::Transformation.translation([0, 0, 100])

A three element array can be substituted for a point or a vector.

If you want units other than inches do it like this 100.mm
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Geom::Transformation

Postby anteolic » Fri Aug 11, 2017 1:33 pm

I have some object with his location, and select it and i want just to move this object to zaxis=0, and leave other axis unchanged.
0
User avatar
anteolic 
 

Re: Geom::Transformation

Postby TIG » Fri Aug 11, 2017 3:02 pm

Slightly different question.
If you want to move its center onto the ground-plane [z=0], consider this...

### ...
bb = some_object.bounds
ct = bb.center
pt = ct.clone
pt.z = 0
ve = ct.vector_to(pt)
tr = Geom::Transformation.translation(ve)
some_object.transform!(tr)
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Geom::Transformation

Postby anteolic » Fri Aug 11, 2017 4:26 pm

Thanks!
0
User avatar
anteolic 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: Architure, sashka11121 and 5 guests

Visit our sponsors: