Creating the center point of a rectangular plane in python

Hello everyone,

I am running through an issue using RhinoScriptSyntax. I want to create planes along a curve and I want them to be centered on the curve. I am using the rs.PlaneFromNormal() function and it creates a plane with the origin being the point on the curve. The planes aren’t parallel to any global C-plane or global axis.
Now I want the plane to be centered on that point. For that I can use both rs.MovePlane() or rs.Move Object() but I need in both cases (new origin or translation vector) I need the center of the plane.
I didn’t find how to create the contour of my plane to use rs.CurveAreaCentroid(). And neither how to create a diagonal to get its center point.

If any of you has already faced the problem, I’d be very glad to hear how you solved it.

Thanks,
Léon

I’m a bit confused. Can you supply some code and screenshots?

These quotes seem contradictory. The plane is already centred on the curve point already.

I’m sorry for not being clear. Here is a code sample to explain what I’m trying to do along with some screenshots of the current state and the expected result.
Here is the code sample:
`import rhinoscriptsyntax as rs

crv = rs.GetObject(“Pick the curve”, 4)
orig_point = rs.GetObject(“Pick the origin”, 1)

pt_param = rs.CurveClosestPoint(crv, orig_point)
tan_vec = rs.CurveTangent(crv, pt_param)
geom_plane = rs.PlaneFromNormal(orig_point, tan_vec)
psurface = rs.AddPlaneSurface(geom_plane, 40.0, 40.0)`

Current state:

Desired result:

In order to do that, I need to translate the plane and thus I need the coordinates of the center point of the plane. With that I can create a translation vector and move the plane accordingly.

Is it clearer ?

OK, you were referring to a surface the whole time. “Plane” is usually understood here as a geometrical construct defined by an origin, and a x- and y-axis, not a planar surface. :wink:

This should do the trick:

import rhinoscriptsyntax as rs

crv = rs.GetObject("Pick the curve", 4)
orig_point = rs.GetObject("Pick the origin", 1)

pt_param = rs.CurveClosestPoint(crv, orig_point)
tan_vec = rs.CurveTangent(crv, pt_param)
geom_plane = rs.PlaneFromNormal(orig_point, tan_vec)
psurface = rs.AddPlaneSurface(geom_plane, 40.0, 40.0)

center = rs.SurfaceAreaCentroid(psurface)[0]  # surface center
vec = rs.VectorSubtract(orig_point, center)  # translation vector
rs.MoveObject(psurface, vec)  # move surface

Thank you very much ! I did not find any evidence of the SurfaceAreaCentroid method, just of the CurveAreaCentroid method. That’s why I was lost !
Thanks so much !