# .transform! doesn't keep the transformation

**URL:** <https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176>\
**Category:** Ruby API\
**Tags:** transform, transformation, vertices, vertex, translation\
**Created:** [February 14, 2017, 7:09pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176 "2017-02-14T19:09:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![herve.pipon](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@herve.pipon](https://forums.sketchup.com/u/herve.pipon)\
**Post date:** [February 14, 2017, 7:09pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/1 "2017-02-14T19:09:16Z")

</div>

Hello  
I want to change some points of my edges.  
It seems to work , but when the functiion ends, the points have the former coordinates.  
I use transform! which is supposed to modify the point, as I understand.  
Where is my mistake ?

```
 UI.messagebox to_change.length
to_change.each do |edge|
vertex = edge.end
point = vertex.position
puts "before #{point.x} , #{point.y} , #{point.z}"
vector = point.vector_to [point.x,point.y,0]
tr = Geom::Transformation.translation vector
point.transform! tr
puts "after #{point.x} , #{point.y} , #{point.z}"
end

```

* * *

before 171,8422mm , 290,5582mm , 0,1044mm  
after 171,8422mm , 290,5582mm , 0,0000mm  
before -55,5479mm , 607,8201mm , 0,1043mm  
after -55,5479mm , 607,8201mm , 0,0000mm

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [February 14, 2017, 7:48pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/2 "2017-02-14T19:48:03Z")

</div>

You construct your vector to go from the point to its projection onto the x,y plane: it has values [0,0,-point.z]. Apply this as a transformation, and it leaves the x and y coordinates unchanged while moving the z value to 0.

---

<div class="post-metadata">

**Author:** ![jim\_foltz](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jim_foltz/32/74787_2.png) [@jim\_foltz](https://forums.sketchup.com/u/jim_foltz)\
**Post date:** [February 14, 2017, 7:55pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/3 "2017-02-14T19:55:37Z")

</div>

You need to transform the vertices themselves. The points retrieved from their `position` are not associated with the edges.

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [February 14, 2017, 7:56pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/4 "2017-02-14T19:56:50Z")

</div>

You are right! I may have focused too much on the code snippet and missed the actual goal!

---

<div class="post-metadata">

**Author:** ![herve.pipon](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@herve.pipon](https://forums.sketchup.com/u/herve.pipon)\
**Post date:** [February 14, 2017, 8:40pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/5 "2017-02-14T20:40:02Z")

</div>

Thanks slbaumgartner, jim\_foltz  
I’m not used to all these concepts, I will train;)  
I take advantage of your help, to ask how to use the transformation to modify the two points of a vertex… The transformation for a vertice will make a translation, which is not what I want.

---

<div class="post-metadata">

**Author:** ![jim\_foltz](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jim_foltz/32/74787_2.png) [@jim\_foltz](https://forums.sketchup.com/u/jim_foltz)\
**Post date:** [February 14, 2017, 9:17pm UTC](https://forums.sketchup.com/t/transform-doesnt-keep-the-transformation/39176/6 "2017-02-14T21:17:59Z")

</div>

To move a single vertex. Assume the model consists of a single Edge.

```ruby
model = Sketchup.active_model
entities = model.entities
edge = entities[0]
a = edge.start
b = edge.end
tr = Geom::Transformation.translation([0, 0, 1])
entities.transform_entities(tr, [b])

```

Use `Entities#transform_entities(Transformation, array_of_entities)` to transform a list of entities by the same Transformation.

Use `Entities#transform_by_vectors(array_of_entities, array_of_vectors)` to transform a list of entities each by a different vector. `array_of_entities` and `array_of_vectors` must be the same length.

> **[Class: Sketchup::Entities](https://ruby.sketchup.com/Sketchup/Entities.html)**
>
> The Sketchup::Entities class is a collection of Entity objects, either in a Sketchup::ComponentDefinition or directly in the Sketchup::Model.
