Skip to main content

Base Modeler

baseModelerAPI#

Provides functions for interaction with the classcad base modeler api.

deleteObjects#

Deletes a multiple objects from structure tree or operation sequence

Declaration

async (drawingId: DrawingID, ids: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
idsObjectID[]

Returns Promise<void>

load#

Loads the given data.

Declaration

async (drawingId: DrawingID, data: ArrayBuffer, type: 'ofb' | 'stp' | 'step' | 'stl', name?: string): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
dataArrayBufferThe data of the file as ArrayBuffer.
type'ofb' l 'stp' l 'step' l 'stl'The data type. The server needs the type of the data to determine which import needs to be used. Possible values: 'ofb' l 'stp' l 'stl'.
name?stringAn optional name for data to load (for example filename). Has just logging purpose.

Returns Promise<number[]>

loadFromUrl#

Gets the model stream from the given url and calls @see BaseModelerAPI.Load.

Declaration

async (drawingId: DrawingID, url: string, filetype: 'ofb' | 'stp', doClearAndInitialiseBM: boolean): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
urlstringThe url to load data from.
filetype'ofb' l 'stp'The type of data delivered by the url (ofb, stp).
doClearAndInitialiseBMbooleanIf TRUE the drawing is cleared before loading and BaseModeling is initialised if needed.

Returns Promise<number[]>
Returns the ids of the loaded products.

save#

Get the current the drawing as stream data.

Important notes about the ofb format:

  • It contains binary geometry blocks.
  • Do not try to convert it to text, the geometry blocks will get damaged!

Declaration

async (drawingId: DrawingID, type: 'ofb' | 'stp' | 'step' | 'stl' = 'ofb'): Promise<Uint8Array | null>

Params

NameTypeDefaultDescription
drawingIdDrawingID
type?'ofb' l 'stp' l 'step' l 'stl''ofb'

Returns Promise<Uint8Array | null>
The data or null.

saveToUrl#

Calls @see BaseModlerAPI.Save and POSTs the result to the given url.

Declaration

async (drawingId: DrawingID, url: string, filetype: 'ofb' | 'stp'): Promise<boolean>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
urlstringThe url to POST the model to.
filetype'ofb' l 'stp'The file type be saved ('ofb', 'stp').

Returns Promise<boolean>
TRUE if saving was successfull.

requestVisualisationOfObject#

Requests the visualisation of the given object

Declaration

async (drawingId: DrawingID, solidId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
solidIdObjectID

Returns Promise<void>

requestVisualisationOfEntities#

Requests the visualisation of the given entities

Declaration

async (drawingId: DrawingID, solidIds: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
solidIdsObjectID[]

Returns Promise<void>

setCurrentProduct#

Declaration

async (drawingId: DrawingID, productId: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
productIdnumber

Returns Promise<void>

setBrepElementColor#

Sets the r,g,b values of the provided brep element on the given solid.

Declaration

async (drawingId: DrawingID, solidId: ObjectID, brepElementId: GraphicID, r: number, g: number, b: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
solidIdObjectIDThe solid (CC_Solid) the brep element belongs to.
brepElementIdGraphicIDThe id of the brep element to change color.
rnumberThe red value of new color (0...255)
gnumberThe green value of new color (0...255)
bnumberRepElementId The id of the brep element to change color.

Returns Promise<void>

removeBrepElementColor#

Removes the color of the provided brep element on the given solid.

Declaration

async (drawingId: DrawingID, solidId: ObjectID, brepElementId: GraphicID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
solidIdObjectIDThe solid (CC_Solid) the brep element belongs to.
brepElementIdGraphicIDThe id of the brep element to change color.

Returns Promise<void>

setBrepElementLabel#

Sets the label of the provided brep element on the given solid.

Declaration

async (drawingId: DrawingID, solidId: ObjectID, brepElementId: GraphicID, label: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
solidIdObjectIDThe solid (CC_Solid) the brep element belongs to.
brepElementIdGraphicIDThe id of the brep element to change color.
labelstringThe label as string.

Returns Promise<void>

removeBrepElementLabel#

Removes the label of the provided brep element on the given solid.

Declaration

async (drawingId: DrawingID, solidId: ObjectID, brepElementId: GraphicID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
solidIdObjectIDThe solid (CC_Solid) the brep element belongs to.
brepElementIdGraphicIDThe id of the brep element to change color.

Returns Promise<void>

setColor#

Sets the r,g,b values of a product and propagates the color to the entities of the following operations if necessary.

Declaration

async (drawingId: DrawingID, productIds: ObjectID[], r: number, g: number, b: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
productIdsObjectID[]The array with ids of the products to change color.
rnumberThe red value (0...255).
gnumberThe green value (0...255).
bnumberThe blue value (0...255).

Returns Promise<void>

setTransparency#

Sets the transparency of a product and propagates the transparency to the entities of the following operations if necessary.

Declaration

async (drawingId: DrawingID, productIds: ObjectID[], transparency: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
productIdsObjectID[]The array with ids of the products to change color.
transparencynumberNumber value from 0 to 1.

Returns Promise<void>

recalc#

Recalc / update of the whole drawing with all its objects

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID

Returns Promise<void>