# Transform an entity a given distance along a given vector

**URL:** <https://forums.sketchup.com/t/transform-an-entity-a-given-distance-along-a-given-vector/16506>\
**Category:** Ruby API\
**Created:** [October 19, 2015, 4:46pm UTC](https://forums.sketchup.com/t/transform-an-entity-a-given-distance-along-a-given-vector/16506 "2015-10-19T16:46:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![kimpastro](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/kimpastro/32/10571_2.png) [@kimpastro](https://forums.sketchup.com/u/kimpastro)\
**Post date:** [October 19, 2015, 6:03pm UTC](https://forums.sketchup.com/t/transform-an-entity-a-given-distance-along-a-given-vector/16506/5 "2015-10-19T18:03:07Z")

</div>

```
vec = entity.transformation.xaxis
vec.length = 12 #how much you wanna move
vec.reverse! # if needed to move to otherside
entity.transform! Geom::Transformation.translation(vec)

```

I think it’s the same problem as that:

> [@Transform\_entities not updating origin](http://forums.sketchup.com/t/transform-entities-not-updating-origin/14262):
>
> Hi guys, I’m working on a Tool that align elements, but when using entities#transform\_entities, the origin of the element doesn’t update. When perform a transform! over the element it updates (is this a rigid transformation?). Some example code: #element = best picked element.definition.entities.transform\_entities(Geom::Transformation.translation [0, 12, 0], element.definition.entities.to\_a) Then, when go to Ruby Console and perform the code below (with element selected), the origin came wi…

---

_[View the full topic](https://forums.sketchup.com/t/transform-an-entity-a-given-distance-along-a-given-vector/16506)._
