Hi, i'm new to ruby. I'd like to know how to move vertex using absolute coordinate ? i used transform_by_vectors and transform_entities , they only provide relative transformation.
Thanx
move vertex using absolute coordinate
5 posts
• Page 1 of 1
move vertex using absolute coordinateHi, i'm new to ruby. I'd like to know how to move vertex using absolute coordinate ? i used transform_by_vectors and transform_entities , they only provide relative transformation.
Thanx
Re: move vertex using absolute coordinateCalculate the final destination based on the original position.
vector = vertex.position.vector_to( new_position ) entities.transform_by_vectors( [vertex], [vector] ) Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: move vertex using absolute coordinatetrt=Geom:Transformation.translation(vector)
then obj.transform!(trt) moves the object by length of the vector in the direction of the vector. trn=Geom:Transformation.new(point) then obj.transform!(trn) moves the object to the specified point irrespective of where is is beforehand. To move an array of vertices you can use entities.transform_entities(trt, vertices) when they'll all shunt over in the direction of vector by the length of vector. If you have a collection of different vectors for different vertices then use entities.transform_by_vectors(vertices_array, vectors_array) You don't want to to apply a 'move' trn type of transformation as they'd all end up coincident ! If you have an array of 'vertices' and a matching array of their new absolute 'positions'... then use an iteration... vertices.each_with_index{|v, i| pt=positions[i] tr=Geom:Transformation.new(pt) entities.transform_entities(tr, v) } Each vertex in turn is then assigned the new position [point]... TIG
Re: move vertex using absolute coordinate
Very inefficient! You want to transform all at once. What I do for vertex tools is by using transform_by_vectors
At all times try to use bulk methods that updates multiple entities at the same time. Even for selections, don't use add/remove within an iterator - use a cache array and update in bulk afterwards. It's the difference between minutes and seconds. Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: move vertex using absolute coordinateThat is a much more efficient way of doing it [transforming [or erasing] entities en mass is often preferable]... But in my defense... the title of the post is move vertex... NOT move vertices... - so there is probably no significant benefit in the en mass way when he's moving just one or two or three vertices - obviously if a whole load of things are changing a time lag will be noticeable...
TIG
SketchUcation One-Liner AdvertsNeed Authorised SketchUp Training by experts in various disciplines? Check out our Training details.
5 posts
• Page 1 of 1
|