Overview
The Rectangle primitive represents a closed rectangular path in 3D space. It is defined by a center point, width (along the X-axis), and breadth (along the Z-axis). The rectangle lies in the XZ plane with Y as the normal direction. Use Cases:- Creating rectangular shapes and boundaries
- Base profiles for extrusion
- Floor plans and section cuts
- Offset operations for creating concentric rectangles
Constructor
- Rust
- TypeScript
Rust Constructor Parameters
Unique identifier for the rectangle instance
TypeScript Constructor Parameters
Configuration options for the rectangle
Optional unique identifier (auto-generated if not provided)
Center point of the rectangle
Width of the rectangle along the X-axis
Breadth of the rectangle along the Z-axis
Rectangle color as a hexadecimal number (e.g., 0x00ff00 for green)
Methods
set_config
- Rust
- TypeScript
generate_geometry
- Rust
- TypeScript
get_geometry_serialized
- Rust
- TypeScript
get_offset_serialized
- Rust
- TypeScript
Distance to offset the rectangle (positive = outward, negative = inward)
Angle threshold for beveling acute corners
Enable beveling at acute angles
get_brep_serialized
- Rust
- TypeScript
getConfig
- TypeScript
discardGeometry
- TypeScript
Properties
Unique identifier for the rectangle instance
Center point of the rectangle (default: origin)
Width along the X-axis (default: 1.0)
Breadth along the Z-axis (default: 1.0)
Internal BREP representation with 4 vertices, 4 edges, and 1 face
Rectangle color (TypeScript only, settable)
Code Examples
Creating a Basic Rectangle
- Rust
- TypeScript
Creating a Square
- TypeScript
Generating Offset Rectangles
- Rust
- TypeScript
Creating Concentric Rectangles
- TypeScript
Updating Rectangle Dimensions
- TypeScript
Getting Rectangle Vertices
- Rust
- TypeScript
Live Demo
Rectangle Demo
Try the Rectangle primitive in the browser
See Also
Polygon
Complex 2D shapes with holes
Polyline
Connected line segments
Line
Straight line segments

