Point Entity (DotEnt)
Less than 1 minute
Point Entity (DotEnt)
DotEnt represents a point entity in CAD, used to mark positions.
Overview
A point entity is the simplest graphical element, containing only a single position coordinate. The display style of points is controlled by system variables.
Constructor
import { DotEnt, Point2D } from 'vjcad';
// Shorthand syntax (recommended)
const dot1 = new DotEnt([100, 100]);
// With size parameter
const dot2 = new DotEnt([100, 100], 2);
// Point2D syntax
const dot3 = new DotEnt(new Point2D(100, 100));
dot1.setDefaults();Shorthand Syntax
Both the constructor and the base property support coordinates in [x, y] array form.
Properties
| Property | Type | Description |
|---|---|---|
position | Point2D | The position coordinate of the point |
Methods
Geometric Transformations
import { DotEnt, Point2D } from 'vjcad';
const dot = new DotEnt([50, 50]);
// Shorthand syntax (recommended)
dot.move([0, 0], [100, 100]); // Move
dot.rotate([0, 0], Math.PI / 4); // Rotate (around a specified point)
dot.scale([0, 0], 2); // Scale
dot.mirror([0, 0], [100, 0]); // MirrorExamples
Drawing a Point Grid
import { Engine, DotEnt, Point2D } from 'vjcad';
function drawPointGrid(
startX: number, startY: number,
rows: number, cols: number,
spacing: number
) {
const dots: DotEnt[] = [];
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
const dot = new DotEnt(
new Point2D(startX + j * spacing, startY + i * spacing)
);
dot.setDefaults();
dots.push(dot);
}
}
Engine.addEntities(dots);
}
// Draw a 5x5 point grid
drawPointGrid(0, 0, 5, 5, 20);