Planar surfaces


Geometric definition


A planar surface is a surface with no curvature. In other words, any intersection between this surface and a plane will be a line. Or even, any line between 2 points on the surface is also in the surface.

How to add


Rhinocommons


We will restrict us to planar surfaces from Rhino Commons’s PlaneSurface class. Planar surfaces can also be created via brep objects but are a special case of breps.

import Rhino
import scriptcontext as sc

# Parameters needed to create the planar surface
normal = Rhino.Geometry.Vector3d(1, 1, 1)
origin = Rhino.Geometry.Point3d(4, 5, 20)
my_plane = Rhino.Geometry.Plane(origin, normal)
x_interval = Rhino.Geometry.Interval(-5, 5)
y_interval = Rhino.Geometry.Interval(-2, 2)

# Will create a plane surface from a base plane and two intervals in the x and y direction of the plane
my_planar_surface = Rhino.Geometry.PlaneSurface(my_plane, x_interval, y_interval)

sc.doc.Objects.AddSurface(my_planar_surface)


import Rhino
import scriptcontext as sc

# Parameters needed to create the planar surface
normal = Rhino.Geometry.Vector3d(1, 1, 1)
origin = Rhino.Geometry.Point3d(4, 5, 20)
my_plane = Rhino.Geometry.Plane(origin, normal)

# Will create a square surface with sides of 1 aligned with a plane
my_planar_surface = Rhino.Geometry.PlaneSurface(my_plane)

sc.doc.Objects.AddSurface(my_planar_surface)


import Rhino
import scriptcontext as sc

# Parameters needed to extrude the line to a planar surface
my_vector = Rhino.Geometry.Vector3d(1, 1, 1)
my_line = Rhino.Geometry.Line(0, 0, 0, 1, -1, -1).ToNurbsCurve()

# Will extrude a curve along a vector, hereby creating a surface
my_planar_surface = Rhino.Geometry.Surface.CreateExtrusion(my_line, my_vector)

sc.doc.Objects.AddSurface(my_planar_surface)

Rhinoscriptsyntax


import rhinoscriptsyntax as rs

# Normal and origin needed to create the plane
normal = (2, 3, 4)
origin = (0, 0, 1)

# Will create a planar surface aligned with a plane and with given intervals in the x and y directions of the plane
my_plane = rs.PlaneFromNormal(origin, normal, xaxis=None)

rs.AddPlaneSurface( my_plane, 5, 10 )

Main methods and properties:


Methods


# Parameters needed to create the interpolated curve on the surface
tolerance = sc.doc.ModelAbsoluteTolerance
is_closed = True
pts = [Rhino.Geometry.Point2d(1, 1),
        Rhino.Geometry.Point2d(1, -1),
        Rhino.Geometry.Point2d(-1, -1),
        Rhino.Geometry.Point2d(-1, 1)]

# Will create an interpolated curve on the surface using 2dPoints located in the surface's local coordinates
my_curve = my_planar_surface.InterpolatedCurveOnSurfaceUV(pts, tolerance, is_closed, 0 )


# test point
test_point = Rhino.Geometry.Point3d(0, 0, 0)

# Will calculate the closest point to the test point on the plane surface.
# returns a boolean value for the success of the calculation and the u and v coordinates on the plane surface
res, u, v = my_planar_surface.ClosestPoint(test_point)


# Will calculate the plane at local coordinates u, v on the plane surface.
res, frame = my_planar_surface.FrameAt(u, v)

Properties


Among the most useful properties we can cite:

# Will return the base plane of the planar surface
plane = my_planar_surface.Plane
print(plane)

# Will check if the (planar) surface can be converted to a brep surface
has_brep_form = my_planar_surface.HasBrepForm
print(has_brep_form)


🛠 Exercise


01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍 02: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍

Solution:

01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍 02: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍