Hide menu
Loading...
Searching...
No Matches
Model

Provides Manufacturing Toolkit (MTK) data model.

The model encapsulates a scene graph (hierarchy of assemblies and parts) and is thus an entry point to entire 3D model data.

The model object can be restored from a file in native MTK format.

Extends

Constructors

new Model()

new Model(name?): Model

Parameters

name?

Name of the model.

null | string

Returns

Model

Overrides

BaseObject.constructor

Accessors

id

Get Signature

get id(): bigint

Returns object id.

Returns

bigint

Inherited from

BaseObject.id


name

Get Signature

get name(): null | string

Returns name of the model. null if the model has no name (by default).

Returns

null | string

Set Signature

set name(name): void

Sets name of the model.

Parameters

name

Name of the model.

null | string

Returns

void


numberOfRoots

Get Signature

get numberOfRoots(): number

Returns number of model's root elements.

Deprecated. Use roots.size instead.

Deprecated

Returns

number


roots

Get Signature

get roots(): ReadonlySet<Part | Assembly>

Returns a set of model's root elements. The elements it contains can only be instances of assemblies or parts.

Returns

ReadonlySet<Part | Assembly>

Methods

accept()

accept(visitor): void

Accepts an element visitor that will visit all root elements.

See also ModelElement::accept.

Parameters

visitor

ModelElementVisitor

Accepted visitor.

Returns

void


addRoot()

Adds new root to the model. If the passed element already presents as a model root, it won't be added. Only assemblies and parts can be assigned as roots. If instance is passed, new assembly will be created and added as root. Passed instance will be added to this assembly.

Param

The root element.

Call Signature

addRoot(root): void

Adds new root to the model. If the passed element already presents as a model root, it won't be added. Only assemblies and parts can be assigned as roots. Thus new assembly will be created and added as root. Passed instance will be added to this assembly.

Parameters

root

Instance

The root element.

Returns

void

Param

The root element.

Call Signature

addRoot(root): void

Adds new root to the model. If the passed element already presents as a model root, it won't be added.

Parameters

root

The root element.

Part | Assembly

Returns

void

Param

The root element.


clear()

clear(): this

Cleans up contents of this object, but saves the assigned name.

Returns

this


isEmpty()

isEmpty(): boolean

Returns true if model is empty, i.e. contains no root elements. Otherwise returns false.

Returns

boolean


merge()

merge(model): this

Merges another model to this object:

  • Adds roots of another model to this object roots.
  • Keeps name of this object.

Parameters

model

Model

Merged model.

Returns

this


open()

open(filename, dataProvider): Promise<boolean>

Reads the MTKWEB model to this model. Returns true if the reading process succeeded, false otherwise.

Parameters

filename

string

Name of the MTKWEB file.

dataProvider

DataProvider

Provider for data stored in external files.

Returns

Promise<boolean>


openFromBuffer()

openFromBuffer(data, dataProvider): Promise<boolean>

Reads the MTKWEB model to this model. Returns true if the reading process succeeded, false otherwise.

Parameters

data

ArrayBufferLike

Buffer with model data.

dataProvider

DataProvider

Provider for data stored in external files.

Returns

Promise<boolean>

true if the reading process succeeded, false otherwise.