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
drawingIdDrawingIDThe drawing id.
idsObjectID[]Ids of the objects to delete

Returns Promise<void>

getGeometryInformation#

Returns an array containing the center of gravity as a point and the volume as a number from the model. Depending on the input parameter the calculations were made on a single solid, a part, a subassembly, the whole model, ... E.g. the center of gravity of a root assembly, will be the sum of all solid's center of gravity over the whole assembly structure

Declaration

async (drawingId: DrawingID, id: ObjectID): Promise<[
PointMemValue,
number
] | null>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
idObjectIDId of the part, assembly, instance or solid we want the information from

Returns Promise<[PointMemValue, number] | null>
Array of two elements containing center of gravity and the volume

load#

Loads the given data.

Declaration

async (drawingId: DrawingID, data: ArrayBuffer, type: 'ofb' | 'stp' | 'step' | 'stl', name?: string, options?: {
ident?: ObjectIdent;
}): 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.
options.ident?ObjectIdent

Returns Promise<number[]>

loadFromUrl#

Loads from the given url.

Declaration

async (drawingId: DrawingID, url: string, filetype: 'ofb' | 'stp', doClearAndInitialiseBM: boolean, options?: {
ident?: ObjectIdent;
}): 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.
options.ident?ObjectIdent

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

recalc#

Recalc / update of the whole drawing with all its objects

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.

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>

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>

requestVisualisationOfEntities#

Requests the visualisation of the given cad entities

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
cadEntityIdsObjectID[]Ids of the cad entities to request visualisation from

Returns Promise<void>

requestVisualisationOfObject#

Requests the visualisation of the given entity (e.g. Solid, Sheet)

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
entityIdObjectIDId of the entity, to request visualisation of its cad entities

Returns Promise<void>

save#

Gets the current 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
drawingIdDrawingIDThe drawing id.
type?'ofb' l 'stp' l 'step' l 'stl''ofb'Optional type to define data format, by default 'ofb'

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

saveToUrl#

Gets the current drawing as stream data 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.

setAppearance#

Sets the appearance of the given entities (solid, sheet, curve arrays) like color, transparency, chord height and angle tolerance

Declaration

async (drawingId: DrawingID, objectIds: ObjectID[], appearance: AppearanceParam): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
objectIdsObjectID[]The array with ids of the entities to change appearance.
appearanceAppearanceParamThe appearance to set on the given entities.

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>

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>

setColor#

DEPRECATED use setAppearance() instead, setColor() will be removed in a future release.

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

Declaration

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

Params

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

Returns Promise<void>

setCurrentProduct#

Sets the given product as the current product

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
productIdnumberId of the product.

Returns Promise<void>

setTransparency#

DEPRECATED use setAppearance() instead, setTransparency() will be removed in a future release.

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

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingID
solidIdsObjectID[]The array with ids of the solids to change transparency.
transparencynumberNumber value from 0 to 1.

Returns Promise<void>