Skip to main content

Base API

baseAPI#

Basic ClassCAD API functions. All other API's are using this base functions.

callSafeAPI#

Declaration

async (drawingId: DrawingID, namespace: string, func: string, args: any[], options?: APIOptions): Promise<ServerResponse>

Params

NameTypeDefaultDescription
drawingIdDrawingID
namespacestring
funcstring
argsany[]
options?APIOptions

Returns Promise<ServerResponse>

callUnsafeAPI#

Declaration

async (drawingId: DrawingID, command: string): Promise<ServerResponse>

Params

NameTypeDefaultDescription
drawingIdDrawingID
commandstring

Returns Promise<ServerResponse>

createCCDrawing#

Creates a new drawing and its Socket client and connects it to the server.

Declaration

async (drawingName?: string, client?: AwvNodeClient): Promise<DrawingID | null>

Params

NameTypeDefaultDescription
drawingName?string
client?AwvNodeClient

Returns Promise<DrawingID | null>
The id of the new drawing.

disconnectCCDrawing#

Disconnects the drawing from ClassCAD and resets the drawing.

It does not remove the Socket client!

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID

Returns Promise<void>

reconnectCCDrawing#

Executes the following sequence:

  1. @see disconnectCCDrawing
  2. connectCCDrawing (internal function)
  3. @see baseModelerAPI.recalc

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID

Returns Promise<void>

fetchTree#

Fetch the tree from the ClassCAD model.

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID

Returns Promise<void>

callMiddleware#

Declaration

async (drawingId: DrawingID, middlewareCommand: string, data: any): Promise<ServerResponse>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
middlewareCommandstringThe custom middleware command to call.
dataanyArbitrary data to be used by the server middleware.

Returns Promise<ServerResponse>

undo#

Undo the last operation or if state isn't empty, load the state with name = state.

Declaration

async (drawingId: DrawingID, state?: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
state?string

Returns Promise<void>

redo#

Redo the last undo or if state isn't empty, load the state with name = state.

Declaration

async (drawingId: DrawingID, state?: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
state?string

Returns Promise<void>