Transform an entity a given distance along a given vector

Is there any way to move an entity a given distance along a vector
what type of transformation would i use?

this is what i want to do but don’t know how to create the transformation
trans = Geom::Transformation.new(point, vector, distance)

The transformation you wrote (point, vector, distance) is not part of the API. The vector can include a length, or distance to displace, so the distance can be redundant. To move a relative amount, consider:

vector.length = distance
translate = Geom::Transformation.translation( vector )
entity.transform! translate

Group and components provide the “transform!” method, which “apply” the transform to the existing one (an affine transformation), moving it a relative amount.

If your position “point” is the current position of the group or component instance, then there would no additional operations. What is position “point”?

I know that it is not a part of the API. it was only to illustrate what i am trying to accomplish. i actually didn’t meant to put the point in there. I want to move an entity a given distance in a given direction.

for example i have a square face that i position at the start of two input points. i have it rotate so the face.normal is parallel to the vector that the two input points make. from there i can pushpull it the distance between the two input points.

But before i extrude it i want to position the face at the desired quadrant that the user chooses in a inputbox
hopefully the pictures will help

The method @BruceYoung describes will work. You just have to calculate the required vector direction and length to move to the required quadrant. This may be easier if you break it down into two sequential translations along the two axes of the grid. Also, note that not all entities offer translate!. For primitive Edges and Faces you need to use their parent Entities collection’s transform_entities method.

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:

2 Likes