Skip to content

Plane

A 3D plane defined by the equation ax + by + cz + d = 0.

Every face in SketchUp lies on a plane, and the Plane class gives you tools to work with that surface mathematically — computing distances from points, getting the normal direction, or transforming the plane along with geometry.

The constructor normalizes the coefficients so that (a, b, c) is always a unit vector (the plane’s normal). You can also create planes from a point and normal using Plane.fromPlaneLike(), or fit a plane through a set of vertices with Plane.fromVertices().

let { Plane, Point3d } = SketchUpApi;
// A plane at z = 10 (normal pointing up)
let floor = new Plane(0, 0, 1, -10);
console.log(floor.normal.to_a);
// => [0, 0, 1]
console.log(floor.origin.toArray());
// => [0, 0, 10]
// Distance from a point to the plane
let pt = new Point3d(5, 5, 25);
console.log(floor.distance(pt));
// => 15

SDK 2.16.0 Protocol 1.13.0

new Plane(a?, b?, c?, d?): Plane

Parameter Type Default value

a

number

0

b

number

0

c

number

0

d

number

0

Plane

readonly a: number = 0


readonly b: number = 0


readonly c: number = 0


readonly d: number = 0

get normal(): Vector3d

A unit vector perpendicular to this plane, pointing in the “front” direction.

SDK 2.17.0

Vector3d


get origin(): Point3d

The point on the plane closest to the world origin — i.e. the perpendicular projection of [0, 0, 0] onto the plane.

SDK 2.25.0

Point3d


get reverse(): Plane

A new plane with the normal flipped (same surface, opposite front/back orientation).

SDK 2.25.0

Plane

applyTransform(transform): Plane

Returns a new plane transformed by the given transformation (rotation, translation, or scale). The original plane is unchanged.

Parameter Type Description

transform

Transformation

‐

Plane


distanceToPoint(pointLike): number

The perpendicular distance from a point to this plane, in inches. Always returns a non-negative value.

Parameter Type Description

pointLike

Readonly<Point3Like>

‐

number

SDK 2.37.0


projectPoint(pointLike): Point3d

Return closest point on this plane to the given point.

Parameter Type Description

pointLike

Readonly<Point3Like>

‐

Point3d

SDK 2.37.0


signedDistanceToPoint(pointLike): number

The perpendicular distance from a point to this plane, in inches.

Positive if the point is “above” the plane, negative otherwise.

Parameter Type Description

pointLike

Readonly<Point3Like>

‐

number

SDK 2.37.0


toArray(): [number, number, number, number]

Returns the coefficients as an [a, b, c, d] tuple.

[number, number, number, number]

SDK 2.35.0


toString(): string

string


static create(input): Plane

Creates a Plane from any PlaneLike value — four coefficients [a, b, c, d], a [point, normal] pair, or an existing Plane instance.

Parameter Type Description

input

Readonly<PlaneLike>

‐

Plane

let { Plane } = SketchUpApi;
// Simple plane on z = 5
let plane = Plane.create([0, 0, 1, -5]);
// Plane(0,0,1,-5)
console.log(plane.toString());

SDK 2.37.0


static fromVertices(vertices): Plane | undefined

Fits a plane through three or more points using a least-squares algorithm. Returns undefined if the points are collinear or don’t all lie on the same plane within tolerance.

Parameter Type Description

vertices

readonly Point3Like[]

at least 3 points

Plane | undefined

a plane or undefined (if there is no plane that fits the inputs)

let { Plane } = SketchUpApi;
let plane = Plane.fromVertices(
[
[0, 100, 5],
[100, 100, 5],
[0, 50, 100]
]
);
// TODO
console.log(plane.toString());

SDK 2.25.0

get to_a(): [number, number, number, number]

[number, number, number, number]


distance(pointLike): number

The perpendicular distance from a point to this plane, in inches. Always returns a non-negative value.

Parameter Type Description

pointLike

Readonly<Point3Like>

‐

number


static fromPlaneLike(planeOrArray): Plane

Creates a Plane from any PlaneLike value — four coefficients [a, b, c, d], a [point, normal] pair, or an existing Plane instance.

Parameter Type Description

planeOrArray

Readonly<PlaneLike>

‐

Plane