You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Plane struct represents an infinite plane in 3D space, defined by a point on the plane and a normal vector perpendicular to it. Planes are used for mirroring, projections, coordinate system definitions, and geometric calculations.
Namespace
Autodesk.AutoCAD.Geometry
Key Properties
Property
Type
Description
Normal
Vector3d
Gets the normal vector perpendicular to the plane
PointOnPlane
Point3d
Gets a point on the plane
Constructors
Constructor
Description
Plane(Point3d, Vector3d)
Creates plane from point and normal vector
Plane(Point3d, Point3d, Point3d)
Creates plane from three non-collinear points
Plane()
Creates XY plane at origin
Key Methods
Method
Return Type
Description
GetClosestPointTo(Point3d)
Point3d
Gets closest point on plane to given point
DistanceTo(Point3d)
double
Gets signed distance from point to plane
IsCoplanarTo(Plane)
bool
Checks if coplanar with another plane
IsPerpendicular(Plane)
bool
Checks if perpendicular to another plane
IsParallelTo(Plane)
bool
Checks if parallel to another plane
IsEqualTo(Plane)
bool
Checks equality with default tolerance
IsEqualTo(Plane, Tolerance)
bool
Checks equality with custom tolerance
Code Examples
Example 1: Creating Planes
// XY plane at origin (Z = 0)PlanexyPlane=newPlane();// Plane from point and normalPoint3dorigin=Point3d.Origin;Vector3dnormal=Vector3d.ZAxis;PlanecustomPlane=newPlane(origin,normal);// Plane from three pointsPoint3dp1=newPoint3d(0,0,0);Point3dp2=newPoint3d(10,0,0);Point3dp3=newPoint3d(0,10,0);PlaneplaneFrom3Pts=newPlane(p1,p2,p3);ed.WriteMessage($"\nXY Plane normal: {xyPlane.Normal}");ed.WriteMessage($"\nCustom plane point: {customPlane.PointOnPlane}");ed.WriteMessage($"\n3-point plane normal: {planeFrom3Pts.Normal}");
Example 2: Point-to-Plane Distance
// Create XY plane at Z = 0PlanexyPlane=newPlane(Point3d.Origin,Vector3d.ZAxis);// Test pointsPoint3dpt1=newPoint3d(5,5,10);// Above planePoint3dpt2=newPoint3d(3,3,-5);// Below planePoint3dpt3=newPoint3d(7,7,0);// On plane// Calculate signed distancesdoubledist1=xyPlane.DistanceTo(pt1);// +10doubledist2=xyPlane.DistanceTo(pt2);// -5doubledist3=xyPlane.DistanceTo(pt3);// 0ed.WriteMessage($"\nDistance pt1 to plane: {dist1:F2}");ed.WriteMessage($"\nDistance pt2 to plane: {dist2:F2}");ed.WriteMessage($"\nDistance pt3 to plane: {dist3:F2}");// Positive = above plane (in direction of normal)// Negative = below plane (opposite to normal)// Zero = on plane
Example 3: Projecting Points onto Plane
// Create vertical plane (YZ plane at X = 0)PlaneyzPlane=newPlane(Point3d.Origin,Vector3d.XAxis);// Point to projectPoint3dtestPoint=newPoint3d(10,5,3);// Get closest point on plane (projection)Point3dprojected=yzPlane.GetClosestPointTo(testPoint);// Calculate projection distancedoubledistance=yzPlane.DistanceTo(testPoint);ed.WriteMessage($"\nOriginal point: {testPoint}");ed.WriteMessage($"\nProjected point: {projected}");ed.WriteMessage($"\nProjection distance: {distance:F2}");// Draw line showing projectionusing(Transactiontr=db.TransactionManager.StartTransaction()){LineprojLine=newLine(testPoint,projected);projLine.ColorIndex=1;// RedBlockTableRecordbtr=tr.GetObject(db.CurrentSpaceId,OpenMode.ForWrite)asBlockTableRecord;btr.AppendEntity(projLine);tr.AddNewlyCreatedDBObject(projLine,true);tr.Commit();}
// Create planesPlanexyPlane=newPlane(Point3d.Origin,Vector3d.ZAxis);PlaneparallelPlane=newPlane(newPoint3d(0,0,10),Vector3d.ZAxis);PlaneperpPlane=newPlane(Point3d.Origin,Vector3d.XAxis);// Check relationshipsboolisParallel=xyPlane.IsParallelTo(parallelPlane);// trueboolisPerpendicular=xyPlane.IsPerpendicular(perpPlane);// trueboolisCoplanar=xyPlane.IsCoplanarTo(parallelPlane);// falseed.WriteMessage($"\nXY parallel to offset XY: {isParallel}");ed.WriteMessage($"\nXY perpendicular to YZ: {isPerpendicular}");ed.WriteMessage($"\nXY coplanar to offset XY: {isCoplanar}");// Check if same planePlanesamePlane=newPlane(newPoint3d(5,5,0),Vector3d.ZAxis);boolisCoplanar2=xyPlane.IsCoplanarTo(samePlane);// true (same plane)ed.WriteMessage($"\nXY coplanar to same plane: {isCoplanar2}");
Example 6: Creating Plane from Entity
using(Transactiontr=db.TransactionManager.StartTransaction()){// Get a planar entity (e.g., Circle, Region, Hatch)Circlecircle=tr.GetObject(circleId,OpenMode.ForRead)asCircle;// Create plane from circle's propertiesPlanecirclePlane=newPlane(circle.Center,circle.Normal);ed.WriteMessage($"\nCircle center: {circle.Center}");ed.WriteMessage($"\nCircle normal: {circle.Normal}");ed.WriteMessage($"\nPlane created from circle");// Check if point is on circle's planePoint3dtestPt=newPoint3d(10,10,0);doubledist=circlePlane.DistanceTo(testPt);boolisOnPlane=Math.Abs(dist)<0.001;ed.WriteMessage($"\nTest point on plane: {isOnPlane}");tr.Commit();}
Example 7: Plane from Face Normal
// Create plane from three points defining a facePoint3dp1=newPoint3d(0,0,0);Point3dp2=newPoint3d(10,0,0);Point3dp3=newPoint3d(5,10,5);// Calculate normal using cross productVector3dv1=p1.GetVectorTo(p2);Vector3dv2=p1.GetVectorTo(p3);Vector3dnormal=v1.CrossProduct(v2).GetNormal();// Create planePlanefacePlane=newPlane(p1,normal);// Alternative: use 3-point constructorPlanefacePlane2=newPlane(p1,p2,p3);ed.WriteMessage($"\nPlane from vectors - Normal: {facePlane.Normal}");ed.WriteMessage($"\nPlane from 3 points - Normal: {facePlane2.Normal}");
Example 8: Checking Point Side of Plane
// Create horizontal plane at Z = 5Planeplane=newPlane(newPoint3d(0,0,5),Vector3d.ZAxis);Point3dabove=newPoint3d(0,0,10);Point3dbelow=newPoint3d(0,0,2);Point3donPlane=newPoint3d(5,5,5);// Check which side of planedoubledistAbove=plane.DistanceTo(above);doubledistBelow=plane.DistanceTo(below);doubledistOn=plane.DistanceTo(onPlane);if(distAbove>0.001)ed.WriteMessage("\nPoint is above plane (in normal direction)");elseif(distAbove<-0.001)ed.WriteMessage("\nPoint is below plane");elseed.WriteMessage("\nPoint is on plane");ed.WriteMessage($"\nDistances: above={distAbove:F2}, below={distBelow:F2}, on={distOn:F6}");
Common Patterns
Creating Construction Plane
// Get UCS planeEditored=Application.DocumentManager.MdiActiveDocument.Editor;Matrix3ducs=ed.CurrentUserCoordinateSystem;CoordinateSystem3ducsCS=ucs.CoordinateSystem3d;PlaneucsPlane=newPlane(ucsCS.Origin,ucsCS.Zaxis);
Checking if Points are Coplanar
Point3dp1=newPoint3d(0,0,0);Point3dp2=newPoint3d(10,0,0);Point3dp3=newPoint3d(0,10,0);Point3dp4=newPoint3d(5,5,0);// Create plane from first three pointsPlaneplane=newPlane(p1,p2,p3);// Check if fourth point is on planedoubledistance=plane.DistanceTo(p4);boolisCoplanar=Math.Abs(distance)<0.001;ed.WriteMessage($"\nPoints are coplanar: {isCoplanar}");
Getting Perpendicular Plane
// Original plane (XY)PlanexyPlane=newPlane(Point3d.Origin,Vector3d.ZAxis);// Create perpendicular plane through X axisPlaneperpPlane=newPlane(Point3d.Origin,Vector3d.YAxis);// Verify perpendicularityboolisPerp=xyPlane.IsPerpendicular(perpPlane);ed.WriteMessage($"\nPlanes perpendicular: {isPerp}");
Best Practices
Normal Direction: Ensure normal vector is normalized for consistent results
Three Points: When creating from 3 points, ensure they're not collinear
Signed Distance: Remember distance is signed (positive/negative based on normal)
Tolerance: Use tolerance when checking if points are on plane
Coordinate Systems: Planes are fundamental for UCS and coordinate transformations
Mirroring: Use planes for mirror transformations
Projections: Use GetClosestPointTo() for point-to-plane projections