Skip to content
On this page

[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGePoint3dArray

Class: McGePoint3dArray

2d.McGePoint3dArray

Array representing three-dimensional points

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new McGePoint3dArray(imp?, isDestroyImp?)

Constructor.

Parameters

NameTypeDescription
imp?` ObjectInternal implementation object
isDestroyImp?boolean-

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad";

//Create a new instance of McGePoint3dArray
  const myArray = new McGePoint3dArray();

//Initialize McGePoint3dArray by passing in an object
  const initialValues = [
    new McGePoint3d({ x: 1, y: 2, z: 3 }),
    new McGePoint3d({ x: 4, y: 5, z: 6 }),
  ];
  const myArray2 = new McGePoint3dArray(initialValues);

Properties

imp

imp: any

Internal implementation object

Methods

append

append(val): void

Add a value

Parameters

NameTypeDescription
Val[McGePoint3d] (2d. McGePoint3d. md)3D point object

Returns

void

Example

ts
import { McGePoint3d, McGePoint3dArray } from "mxcad"

const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

at

at(index): McGePoint3d

Obtain the value of a data element based on the array index value

Parameters

NameTypeDescription
Indexnumberarray index

Returns

McGePoint3d

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  const point = array.at(0);
console.log(point); //  Output: McGePoint3d { x: 1, y: 2, z: 3 }

clear

clear(): void

Clear the array

Returns

void

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.clear();
console.log(array.length()); //  Output: 0

copy

copy(val): McGePoint3dArray

Copy the value of the object

Parameters

NameTypeDescription
Val[McGePoint3dArray] (2d. McGePoint3dArray. md) \[McGePoint3d] (2d. McGePoint3d. md) []

Returns

McGePoint3dArray

Example

ts
import { McGePoint3d, McGePoint3dArray } from "mxcad"

  const array1 = new McGePoint3dArray();
  const array2 = new McGePoint3dArray();
  array2.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array2.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

//Copy the value of array2 to array1
  array1.copy(array2);

forEach

forEach(call): void

Traverse the array

Parameters

NameTypeDescription
Call(val: [McGePoint3d] (2d. McGePoint3d. md), index: number=>voidcallback function

Returns

void

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.forEach((point, index) => {
    console.log(`Index ${index}: Point ${point}`);
  });
//Output:
  // Index 0: Point McGePoint3d { x: 1, y: 2, z: 3 }
  // Index 1: Point McGePoint3d { x: 4, y: 5, z: 6 }

isEmpty

isEmpty(): boolean

Return an empty array

Returns

boolean

Boolean value

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"
  const array = new McGePoint3dArray();
console.log(array.isEmpty()); //  Output: true

  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
console.log(array.isEmpty()); //  Output: false

length

length(): number

Return the length of the array

Returns

number

Array length

Example

ts
import { McGePoint3dArray } from "mxcad"
const array = new McGePoint3dArray();
console.log(array.length()); //  Output: 0

setAt

setAt(index, val): void

Set the value of data elements through array indexing

Parameters

NameTypeDescription
Indexnumberarray index
Val[McGePoint3d] (2d. McGePoint3d. md)3D point object

Returns

void

Example

ts
import { McGePoint3dArray, McGePoint3d } from "mxcad"

  const array = new McGePoint3dArray();
  array.append(new McGePoint3d({ x: 1, y: 2, z: 3 }));
  array.append(new McGePoint3d({ x: 4, y: 5, z: 6 }));

  array.setAt(0, new McGePoint3d({ x: 7, y: 8, z: 9 }));
console.log(array.at(0)); //  Output: McGePoint3d { x: 7, y: 8, z: 9 }