How can I move a point through out a custom plane's z axis

Hi all,

I’m quite new on python scripting and I’m getting stuck with the tansformations, since I’m trying to move a point though a custom plane’s z axis to make then a line and I have no clue on how to manage the transformation.
I know how to do it with gh components, I just deconstruct the plane and then move the point applying the “amplitude” component through the z vector, but how can I translate that to python ?
I’ve been searching in the forum and it seems to me is not an easy thing.
Can someone explain that for a gh python rookie?

Thanks in advance ,

Joan

Hi,

Usually you don’t need to use a transformation for moving a point along an axis. The behaviour with transformations usually is, that the object gets obviously transformed, but is not copied. In other words in order to create a line you will need two points.

To move a point along a vector, you just need to add both together. A point plus a vector returns a new transformed point. If you want to determine the exact length, you need to multiply by a vector with length 1 (“unitized/normalized vector”) and multiply with the desired length.


import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
# input
ptA = rg.Point3d(4,3,5)
# vector to move the point along
vec = rg.Vector3d(0,1,2)
#desired length
dis = 15
# unitize/normalize the vectors length to 1
unitizedVec = rs.VectorUnitize(vec);
# move the point
ptB = ptA + (unitizedVec * dis)
# create the line from both points
line = rs.AddLine(ptA,ptB)
#or line = rg.Line(ptA,ptB)
# output
a = line
1 Like

Hi Tom,

Things become very easy when are so well explained.

Thank you so much.

Joan

1 Like