MotorXP-AFM Scripting API
    Preparing search index...

    Interface Geom

    Built-in Geom object

    interface Geom {
        angle(x: number, y: number): number;
        angle(v1: Vector3, v2: Vector3): number;
        angleBetweenVector(v1: Vector3, v2: Vector3): number;
        angleBetweenVectors(v1: Vector3, v2: Vector3): number;
        angleX(point: Point3): number;
        angleX(x: number, y: number, z: number): number;
        angleY(point: Point3): number;
        angleY(x: number, y: number, z: number): number;
        angleZ(point: Point3): number;
        angleZ(x: number, y: number, z: number): number;
        arc(radius: number, angle: number): Shape;
        arc(radius: number, angle1: number, angle2: number): Shape;
        arc(p1: Point3, p2: Point3, p3: Point3): Shape;
        boundingBox(shp: Shape): BoundingBox;
        box(x: number, y: number, z: number): Shape;
        box(a: number): Shape;
        bspline(points: Point3[], closed?: boolean): Shape;
        chamfer(shp: Shape, r: number): Shape;
        chamfer(shp: Shape, r: number, refs: Point3[]): Shape;
        circle(radius: number): Shape;
        circle(radius: number, angle: number): Shape;
        circle(radius: number, angle1: number, angle2: number): Shape;
        collar(r1: number, r2: number, h: number): Shape;
        collar(r1: number, r2: number, h: number, angle: number): Shape;
        cone(r1: number, r2: number, h: number): Shape;
        cone(r1: number, r2: number, h: number, angle: number): Shape;
        cylinder(r: number, h: number): Shape;
        cylinder(r: number, h: number, angle: number): Shape;
        deg(radians: number): number;
        degreesToRadians(degrees: number): number;
        diff(a: Shape, b: Shape): Shape;
        diff(shapes: Shape[]): Shape;
        difference(a: Shape, b: Shape): Shape;
        difference(shapes: Shape[]): Shape;
        distance(p1: Point3, p2: Point3): number;
        distance(p1: Point2, p2: Point2): number;
        distanceToSegment(p1: Point3, p2: Point3, p: Point3): number;
        distanceToSegmentXY(p1: Point3, p2: Point3, point: Point3): number;
        distanceToSegmentXZ(p1: Point3, p2: Point3, point: Point3): number;
        distanceToSegmentYZ(p1: Point3, p2: Point3, point: Point3): number;
        ellipse(majorRadius: number, minorRadius: number): Shape;
        ellipse(
            majorRadius: number,
            minorRadius: number,
            angle1: number,
            angle2: number,
        ): Shape;
        ellipse(s1: Point3, s2: Point3, center: Point3): Shape;
        ellipse(
            s1: Point3,
            s2: Point3,
            center: Point3,
            angle1: number,
            angle2: number,
        ): Shape;
        even(v: number): number;
        fill(shp: Shape): Shape;
        fillet(shp: Shape, r: number): Shape;
        fillet(shp: Shape, r: number, refs: Point3[]): Shape;
        filletFace(shp: Shape, r: number, ref: Point3 | Shape): Shape;
        fromPolar(radius: number, angle: number): Point2;
        helperPiece(shp: Shape, color?: Color): Piece;
        helperPiece(pt: Point3, radius?: number, color?: Color): Piece;
        infplane(pos?: Point3, dir?: Vector3): Shape;
        intersect(a: Shape, b: Shape): Shape;
        intersect(shapes: Shape[]): Shape;
        intersectionCircle2Circle2(
            c1: Point2,
            r1: number,
            c2: Point2,
            r2: number,
        ): Point2[];
        intersectionSegment2Circle2(
            p1: Point2,
            p2: Point2,
            c: Point2,
            r: number,
        ): Point2[];
        intersectionSegment2Segment2(
            p1: Point2,
            p2: Point2,
            q1: Point2,
            q2: Point2,
        ): Point2[];
        intersectionSegment3Segment3(
            p1: Point3,
            p2: Point3,
            q1: Point3,
            q2: Point3,
        ): Point3;
        intersectsSegments(p1: Point3, p2: Point3, q1: Point3, q2: Point3): Point3;
        isEpsilon(arg: number, eps?: number): boolean;
        isEqual(arg1: number, arg2: number, eps?: number): boolean;
        isEven(v: number): boolean;
        isGreat(v1: number, v2: number): boolean;
        isGreatEqual(arg1: number, arg2: number, eps?: number): boolean;
        isLess(v1: number, v2: number): boolean;
        isLessEqual(arg1: number, arg2: number, eps?: number): boolean;
        isOdd(v: number): boolean;
        middleAngle(a1: number, a2: number, dir: Coil): number;
        ngon(radius: number, n: number): Shape;
        normAngle(a: number): number;
        normAngleAt180(a: number): number;
        normSpanAngle(a: number): number;
        odd(v: number): number;
        piece(
            shp: Shape,
            material:
                | ConductorMaterial
                | CustomMaterial
                | EmptyMaterial
                | EndturnMaterial
                | GeneralMaterial
                | IronMaterial
                | MagnetParallelMaterial
                | MagnetRadialMaterial,
        ): Piece;
        point2(x?: number, y?: number): Point2;
        point3(x?: number, y?: number, z?: number): Point3;
        point3(p: Point2, z?: number): Point3;
        pointAtPolygon(polygon: Point3[], point: Point3): number;
        pointAtPolygonXY(polygon: Point3[], point: Point3): number;
        pointAtPolygonXZ(polygon: Point3[], point: Point3): number;
        pointAtPolygonYZ(polygon: Point3[], point: Point3): number;
        pointAtSegment(p1: Point3, p2: Point3, t: number): Point3;
        pointAtSegment(p1: Point2, p2: Point2, t: number): Point2;
        pointAtShape(shape: Shape, point: Point3): number;
        polygon(points: Point3[]): Shape;
        polysegment(points: Point3[], closed?: boolean): Shape;
        project(p: Point3, shape: Shape): Point3;
        projectToSegment(p: Point3, p1: Point3, p2: Point3): Point3;
        projectToSegmentXY(p: Point3, p1: Point3, p2: Point3): Point3;
        projectToSegmentXZ(p: Point3, p1: Point3, p2: Point3): Point3;
        projectToSegmentYZ(p: Point3, p1: Point3, p2: Point3): Point3;
        rad(degrees: number): number;
        radiansToDegrees(radians: number): number;
        radius(x: number, y: number): number;
        radiusX(point: Point3): number;
        radiusX(x: number, y: number, z: number): number;
        radiusY(point: Point3): number;
        radiusY(x: number, y: number, z: number): number;
        radiusZ(point: Point3): number;
        radiusZ(x: number, y: number, z: number): number;
        rectangle(a: number, b: number, center?: boolean): Shape;
        ring(radius1: number, radius2: number): Shape;
        ring(radius1: number, radius2: number, angle: number): Shape;
        ring(
            radius1: number,
            radius2: number,
            angle1: number,
            angle2: number,
        ): Shape;
        round(value: number, precision: number): number;
        section(a: Shape, b: Shape, pretty?: boolean): Shape;
        segment(p1: Point3, p2: Point3): Shape;
        shape(bbox: BoundingBox): Shape;
        sign(n: number): number;
        spanAngle(a1: number, a2: number, dir: Coil): number;
        sphere(r: number): Shape;
        sphere(r: number, an1: number): Shape;
        sphere(r: number, an1: number, an2: number): Shape;
        sphere(r: number, an1: number, an2: number, an3: number): Shape;
        square(a: number, center?: boolean): Shape;
        torus(r1: number, r2: number): Shape;
        torus(r1: number, r2: number, ua: number): Shape;
        torus(r1: number, r2: number, va1: number, va2: number): Shape;
        torus(r1: number, r2: number, va1: number, va2: number, ua: number): Shape;
        unify(shp: Shape): Shape;
        unite(a: Shape, b: Shape): Shape;
        unite(shapes: Shape[]): Shape;
        vector3(x?: number, y?: number, z?: number): Vector3;
        vector3(p: Point3): Vector3;
        vector3(p1: Point3, p2: Point3): Vector3;
        wire(shapes: Shape[]): Shape;
    }
    Index

    Methods

    • Gets the angle of a point about [0,0,0] in the YOZ plane.

      Parameters

      • point: Point3

        Point in three-dimensional space.

      Returns number

      Angle of the point in degrees about [0,0,0] in the YOZ plane. Zero is the three o'clock direction; the angle increases clockwise.

    • Gets the angle of [x,y,z] about the origin in the YOZ plane.

      Parameters

      • x: number

        X coordinate (unused).

      • y: number

        Y coordinate.

      • z: number

        Z coordinate.

      Returns number

      Angle of the point in degrees.

    • Gets the angle of a point about [0,0,0] in the XOZ plane.

      Parameters

      • point: Point3

        Point in three-dimensional space.

      Returns number

      Angle of the point in degrees about [0,0,0] in the XOZ plane. Zero is the three o'clock direction; the angle increases clockwise.

    • Gets the angle of [x,y,z] about the origin in the XOZ plane.

      Parameters

      • x: number

        X coordinate.

      • y: number

        Y coordinate (unused).

      • z: number

        Z coordinate.

      Returns number

      Angle of the point in degrees.

    • Gets the angle of a point about [0,0,0] in the XOY plane.

      Parameters

      • point: Point3

        Point in three-dimensional space

      Returns number

      Angle of the point in degrees about [0,0,0] in the XOY plane. Zero is the three o'clock direction; the angle increases clockwise.

    • Gets the angle of [x,y,z] about the origin in the XOY plane.

      Parameters

      • x: number

        X coordinate.

      • y: number

        Y coordinate.

      • z: number

        Z coordinate (unused).

      Returns number

      Angle of the point in degrees.

    • Chamfers a shape. Unlike filleting, this operation applies only to solids. The chamfer is defined by distance r from the edge to the chamfer line and an array of nearby reference points refs.

      Parameters

      • shp: Shape

        Solid to chamfer.

      • r: number

        Distance from the edge to the chamfer line.

      Returns Shape

      Result of the chamfer operation.

    • Chamfers a shape. Unlike filleting, this operation applies only to solids. The chamfer is defined by distance r from the edge to the chamfer line and an array of nearby reference points refs.

      Parameters

      • shp: Shape

        Solid to chamfer.

      • r: number

        Distance from the edge to the chamfer line.

      • refs: Point3[]

        Array of reference points near the edges to chamfer.

      Returns Shape

      Result of the chamfer operation.

    • 2D circle or circular sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius: number

        Circle radius.

      Returns Shape

      Shape representing a circle or circular sector.

    • 2D circle or circular sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius: number

        Circle radius.

      • angle: number

        Sector angle in degrees in (0°, 360°); the shape is centered about the OX axis.

      Returns Shape

      Shape representing a circle or circular sector.

    • 2D circle or circular sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius: number

        Circle radius.

      • angle1: number

        Start angle of the sector in degrees in (0°, 360°).

      • angle2: number

        End angle of the sector in degrees in (0°, 360°).

      Returns Shape

      Shape representing a circle or circular sector.

    • 3D solid primitive: a sleeve (a cylinder with an axial hole), defined by outer radius r1, inner radius r2, and height h, relative to [0,0,0]. The angle parameter can specify a sleeve sector.

      Parameters

      • r1: number

        Outer radius of the sleeve.

      • r2: number

        Inner radius of the sleeve.

      • h: number

        Sleeve height.

      Returns Shape

      Shape representing a sleeve.

    • 3D solid primitive: a sleeve (a cylinder with an axial hole), defined by outer radius r1, inner radius r2, and height h, relative to [0,0,0]. The angle parameter can specify a sleeve sector.

      Parameters

      • r1: number

        Outer radius of the sleeve.

      • r2: number

        Inner radius of the sleeve.

      • h: number

        Sleeve height.

      • angle: number

        Sleeve sector angle in degrees; the shape is centered about OX.

      Returns Shape

      Shape representing a sleeve.

    • 3D solid primitive: a cone defined by bottom radius r1, top radius r2, and height h, relative to [0,0,0]. The angle parameter can specify a cone sector.

      Parameters

      • r1: number

        Bottom radius of the cone.

      • r2: number

        Top radius of the cone.

      • h: number

        Cone height.

      Returns Shape

      Shape representing a cone.

    • 3D solid primitive: a cone defined by bottom radius r1, top radius r2, and height h, relative to [0,0,0]. The angle parameter can specify a cone sector.

      Parameters

      • r1: number

        Bottom radius of the cone.

      • r2: number

        Top radius of the cone.

      • h: number

        Cone height.

      • angle: number

        Cone sector angle in degrees; the shape is centered about OX.

      Returns Shape

      Shape representing a cone.

    • 3D solid primitive: a cylinder defined by radius r and height h, relative to [0,0,0]. The angle parameter can specify a cylinder sector.

      Parameters

      • r: number

        Cylinder radius.

      • h: number

        Cylinder height.

      Returns Shape

      Shape representing a cylinder.

    • 3D solid primitive: a cylinder defined by radius r and height h, relative to [0,0,0]. The angle parameter can specify a cylinder sector.

      Parameters

      • r: number

        Cylinder radius.

      • h: number

        Cylinder height.

      • angle: number

        Cylinder sector angle in degrees; the shape is centered about OX.

      Returns Shape

      Shape representing a cylinder.

    • Calculates the distance from a point to a segment in the XOY plane. All points are three-dimensional, but only X and Y are used in the calculation.

      Parameters

      • p1: Point3

        Start point of the segment.

      • p2: Point3

        End point of the segment.

      • point: Point3

        Point from which the distance is measured.

      Returns number

      Distance from the point to the segment in the XOY plane.

    • Calculates the distance from a point to a segment in the XOZ plane. All points are three-dimensional, but only X and Z are used in the calculation.

      Parameters

      • p1: Point3

        Start point of the segment.

      • p2: Point3

        End point of the segment.

      • point: Point3

        Point from which the distance is measured.

      Returns number

      Distance from the point to the segment in the XOZ plane.

    • Calculates the distance from a point to a segment in the YOZ plane. All points are three-dimensional, but only Y and Z are used in the calculation.

      Parameters

      • p1: Point3

        Start point of the segment.

      • p2: Point3

        End point of the segment.

      • point: Point3

        Point from which the distance is measured.

      Returns number

      Distance from the point to the segment in the YOZ plane.

    • 2D ellipse or elliptic sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • majorRadius: number

        First radius of the ellipse.

      • minorRadius: number

        Second radius of the ellipse.

      Returns Shape

      Shape representing an ellipse or elliptic sector.

    • 2D ellipse or elliptic sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • majorRadius: number

        First radius of the ellipse.

      • minorRadius: number

        Second radius of the ellipse.

      • angle1: number

        Start angle of the elliptic sector in degrees in (0°, 360°).

      • angle2: number

        End angle of the elliptic sector in degrees in (0°, 360°).

      Returns Shape

      Shape representing an ellipse or elliptic sector.

    • Ellipse centered at center: its major axis passes through center and s1, and its minor radius is the distance from s2 to the major axis. The ellipse lies in the plane through center, s1, and s2.

      Parameters

      • s1: Point3

        Point on the major axis.

      • s2: Point3

        Point defining the minor radius.

      • center: Point3

        Ellipse center.

      Returns Shape

      Shape representing an ellipse.

    • Elliptic sector centered at center (see ellipse(s1, s2, center)).

      Parameters

      • s1: Point3

        Point on the major axis.

      • s2: Point3

        Point defining the minor radius.

      • center: Point3

        Ellipse center.

      • angle1: number

        Start angle of the sector in degrees.

      • angle2: number

        End angle of the sector in degrees.

      Returns Shape

      Shape representing an elliptic sector.

    • Fillets a shape. For solids, edges are modified; for planar shapes, vertices are modified. Fillets are defined by radius r and an array of reference points refs near the edges or vertices to modify.

      Parameters

      • shp: Shape

        Shape to fillet.

      • r: number

        Fillet radius.

      Returns Shape

      Shape resulting from the fillet operation.

    • Fillets a shape. For solids, edges are modified; for planar shapes, vertices are modified. Fillets are defined by radius r and an array of reference points refs near the edges or vertices to modify.

      Parameters

      • shp: Shape

        Shape to fillet.

      • r: number

        Fillet radius.

      • refs: Point3[]

        Array of reference points refs near the edges or vertices to fillet.

      Returns Shape

      Shape resulting from the fillet operation.

    • Returns true if the absolute value of arg is less than or equal to eps.

      Parameters

      • arg: number

        Numeric value to process.

      • Optionaleps: number

        eps [default=Math.EPSILON] - Floating-point comparison tolerance.

      Returns boolean

      Operation result.

    • Returns true if the difference between the absolute values of arg1 and arg2 is less than or equal to eps.

      Parameters

      • arg1: number

        First numeric value.

      • arg2: number

        Second numeric value.

      • Optionaleps: number

        eps [default=Math.EPSILON] - Floating-point comparison tolerance.

      Returns boolean

      Operation result.

    • Returns true if arg1 is greater than or equal to arg2, allowing for eps.

      Parameters

      • arg1: number

        First numeric value.

      • arg2: number

        Second numeric value.

      • Optionaleps: number

        eps [default=Math.EPSILON] - Floating-point comparison tolerance.

      Returns boolean

      Operation result.

    • Returns true if arg1 is less than or equal to arg2, allowing for eps.

      Parameters

      • arg1: number

        First numeric value.

      • arg2: number

        Second numeric value.

      • Optionaleps: number

        eps [default=Math.EPSILON] - Floating-point comparison tolerance.

      Returns boolean

      Operation result.

    • Calculates the mean angle between a1 and a2 in the specified direction (CW — clockwise, CCW — counterclockwise).

      Parameters

      • a1: number

        First angle in degrees.

      • a2: number

        Second angle in degrees.

      • dir: Coil

        Traversal direction (required): Coil.CW (clockwise) or Coil.CCW (counterclockwise).

      Returns number

      Mean angle in degrees.

    • 2D regular N-sided polygon in the XOY plane, centered at [0,0,0].

      Parameters

      • radius: number

        Polygon radius: distance from the center to the vertices.

      • n: number

        Number of polygon vertices (at least 3).

      Returns Shape

      Shape representing a regular N-sided polygon.

    • Determines the position of a point relative to a polygon in 3D space.

      Parameters

      • polygon: Point3[]

        Polygon defined by an array of points.

      • point: Point3

        Point to test.

      Returns number

      -1 — outside the polygon (ON_UNBOUNDED_SIDE), 0 — on the polygon boundary (ON_BOUNDARY), 1 — inside the polygon (ON_BOUNDED_SIDE).

    • Determines the position of a point relative to a geometric shape in 3D space.

      Parameters

      • shape: Shape

        Geometric shape, such as a curve, edge, or wire.

      • point: Point3

        Point to test.

      Returns number

      -1 — outside the shape (ON_UNBOUNDED_SIDE), 0 — on the shape boundary (ON_BOUNDARY), 1 — inside the shape (ON_BOUNDED_SIDE).

    • 2D rectangle in the XOY plane.

      Parameters

      • a: number

        Rectangle side along X

      • b: number

        Rectangle side along Y

      • Optionalcenter: boolean

        If true, the rectangle is centered at [0,0,0]; otherwise, one corner is at [0,0,0].

      Returns Shape

      Shape representing a rectangle.

    • 2D ring or ring sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius1: number

        Outer ring radius

      • radius2: number

        Inner ring radius

      Returns Shape

      Shape representing a ring or ring sector.

    • 2D ring or ring sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius1: number

        Outer ring radius

      • radius2: number

        Inner ring radius

      • angle: number

        Ring sector angle from 0 to 360°. The shape is centered about OX.

      Returns Shape

      Shape representing a ring or ring sector.

    • 2D ring or ring sector in the XOY plane, centered at [0,0,0], with angles in degrees.

      Parameters

      • radius1: number

        Outer ring radius

      • radius2: number

        Inner ring radius

      • angle1: number

        Start angle of the ring sector in degrees

      • angle2: number

        End angle of the ring sector in degrees

      Returns Shape

      Shape representing a ring or ring sector.