Skip to main content

Solid

solidAPI#

Provides functions for interaction with the classcad solid api.

clearSolid#

Clears the given solid in the drawing.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to clear

Returns Promise<void>

clearSolids#

Clears all solids in the drawing.

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing

Returns Promise<void>

copy#

Creates a copy of the given solid

Declaration

async (drawingId: DrawingID, solid: ObjectID): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to copy

Returns Promise<number>
Id of the created copy soild

createBox#

Creates a simple box solid

Declaration

async (drawingId: DrawingID, length: number, width: number, height: number): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
lengthnumberLength of the box (x-axis)
widthnumberWidth of the box (y-axis)
heightnumberHeight of the box (z-axis)

Returns Promise<number>
Id of the created box solid

createCone#

Creates a simple cone solid

Declaration

async (drawingId: DrawingID, height: number, diameter1: number, diameter2: number): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
heightnumberHeight of the cone (z-axis)
diameter1numberDiameter at the bottom of the cone
diameter2numberDiameter at the top of the cone

Returns Promise<number>
Id of the created cone solid

createCylinder#

Creates a simple cylinder solid

Declaration

async (drawingId: DrawingID, height: number, diameter: number): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
heightnumberHeight of the cylinder (z-axis)
diameternumberDiameter of the cylinder

Returns Promise<number>
Id of the created cylinder solid

createExtrude#

Extrudes the region which is defined by the points and bulges

Declaration

async (drawingId: DrawingID, height: PointMemValue, points: PointMemValue[], bulges: number[]): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
heightPointMemValueHeight of extrusion
pointsPointMemValue[]Points which define the corners (vertices) of the polyline
bulgesnumber[]Bulge between two points. The bulge is tan(a/4), a is the included angle for the arc between the two points. Bulge is positive for arcs directed counterclockwise when looking in opposite direction of the normal. A semicircle has the bulge 1, a straight line the bulge 0.

Returns Promise<number>
Id of the extruded solid

createExtrudeRegion#

Extrudes the region which is defined by the curve array

Declaration

async (drawingId: DrawingID, height: PointMemValue, curveArray: CurveArray): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
heightPointMemValueHeight of extrusion
curveArrayCurveArrayThe specific curve array, which is the result of transforming the THREE.Shape.curves into drawable region in ClassCAD. Depending on the curve types used in the THREE.Shape, this array contains all necessary points and control points in a multidimensional array.

Returns Promise<number>
Id of the extruded solid

createFillet#

Creates a fillet at the given edges with given radius

Declaration

async (drawingId: DrawingID, radius: number, edges: ObjectID[]): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
radiusnumberRadius of the fillet
edgesObjectID[]Edges to create fillets on

Returns Promise<number>
Id of the fillet solid

createRevolve#

Revolves the region which is defined by the points and bulges

Declaration

async (drawingId: DrawingID, position: PointMemValue, direction: PointMemValue, angle: number, points: PointMemValue[], bulges: number[]): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
positionPointMemValuePosition of rotation axis
directionPointMemValueDirection of rotation axis
anglenumberAngle of rotation in rad
pointsPointMemValue[]Points which define the corners (vertices) of the polyline
bulgesnumber[]Bulge between two points. The bulge is tan(a/4), a is the included angle for the arc between the two points. Bulge is positive for arcs directed counterclockwise when looking in opposite direction of the normal. A semicircle has the bulge 1, a straight line the bulge 0.

Returns Promise<number>
Id of the revolved solid

createRevolveRegion#

Revolves the region which is defined by the curve array

Declaration

async (drawingId: DrawingID, position: PointMemValue, direction: PointMemValue, angle: number, curveArray: CurveArray): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
positionPointMemValuePosition of rotation axis
directionPointMemValueDirection of rotation axis
anglenumberAngle of rotation in rad
curveArrayCurveArrayThe specific curve array, which is the result of transforming the THREE.Shape.curves into drawable region in ClassCAD. Depending on the curve types used in the THREE.Shape, this array contains all necessary points and control points in a multidimensional array.

Returns Promise<number>
Id of the revolved solid

createSphere#

Creates a simple sphere solid.

Declaration

async (drawingId: DrawingID, radius: number): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
radiusnumberRadius of the sphere

Returns Promise<number>
Id of the created sphere solid

edgeLoops#

Returns all adjacent edges of a face or vertex

Declaration

async (drawingId: DrawingID, breps: ObjectID[]): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
brepsObjectID[]Face or vertex ids to get the adjacent edges from

Returns Promise<number[]>
Ids of all adjacent edges

export#

Writes the current solid or specific solids to a stream in stp data format and returns the data.

Declaration

async (drawingId: DrawingID, type: 'stp', solids?: ObjectID[]): Promise<any>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
type'stp'Type of the exported file, currently only 'stp' files possible
solids?ObjectID[]Optional ids of the solids to export, otherwise all solids will be exported

Returns Promise<any>
Data stream of the exported solids

import#

Loads an arraybuffer in stp file format. All solids existing in stp data will be returned in an array. Current drawing will not be overwritten, imports will just be added.

Declaration

async (drawingId: DrawingID, data: ArrayBuffer, type: 'stp'): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
dataArrayBufferData of file as arraybuffer
type'stp'Type of importing file, currently only 'stp' possible

Returns Promise<number[]>
Ids of all imported solids

init#

Initializes the drawing and creates an initial part.

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing

Returns Promise<void>

intersect#

Creates an intersection between two solids.

Declaration

async (drawingId: DrawingID, solid1: ObjectID, keepSolid: boolean, solid2: ObjectID): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solid1ObjectIDId of the base solid of intersection
keepSolidbooleanFlag, whether to keep the solid or delete it after intersection
solid2ObjectIDId of the solid to intersect with base solid

Returns Promise<number>
Id of result solid after intersection

load#

Loads an arraybuffer in native file format. Native file format is 'ofb', if you want to load 'stp' file formats, use import function. Current drawing will be overwritten by loaded data.

Declaration

async (drawingId: DrawingID, data: ArrayBuffer, type: string, doClearDrawingAndInitialiseBM: boolean): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
dataArrayBufferData of file as arraybuffer
typestringType of loading file, currently only 'ofb' possible
doClearDrawingAndInitialiseBMbooleanFlag, whether to clear and initialise the drawing or not

Returns Promise<number>
Id of the loaded product in the file

mirror#

Mirrors the solid at the specified plane.

Declaration

async (drawingId: DrawingID, solid: ObjectID, point: PointMemValue, normal: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to be mirrored
pointPointMemValuePosition of mirror plane
normalPointMemValueNormal vector of mirror plane

Returns Promise<void>

moveTo#

Moves the solid to the given position in global coordinates

Declaration

async (drawingId: DrawingID, solid: ObjectID, position: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to move
positionPointMemValuePosition to move the solid to

Returns Promise<void>

offset#

Creates an offset of the solid.

Declaration

async (drawingId: DrawingID, solid: ObjectID, offsetDistance: number): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid which becomes an offset
offsetDistancenumberDistance of the offset

Returns Promise<number>
Id of the offset solid

pick#

Returns all geometry depending on given type which matches the points.

Declaration

async (drawingId: DrawingID, solid: ObjectID, type: 'vertex' | 'edge' | 'face', ...points: PointMemValue[]): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to look for geometry
type'vertex' l 'edge' l 'face'Type of geometry to look for, 'vertex' l 'edge' l 'face'
pointsPointMemValue[]Points where geometry will be exptected

Returns Promise<number[]>
Ids of all found geometry

rotateTo#

Rotates the given solid around x-, y- and z-axis with defined angles.

Declaration

async (drawingId: DrawingID, solid: ObjectID, rotationVec: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to rotate
rotationVecPointMemValueVector of rotation around x-, y- and z-axis in rad

Returns Promise<void>

save#

Writes the current drawing as native file format to a stream and returns the data. Native file format is 'ofb', for 'stp' file format use export method.

Declaration

async (drawingId: DrawingID, type: 'ofb'): Promise<any>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
type'ofb'Type of the saved file, currently only 'ofb' files possible

Returns Promise<any>
Data stream of the saved solids

scale#

Scales the solid in all or specified axis.

Declaration

async (drawingId: DrawingID, solid: ObjectID, pointOrFactor: PointMemValue | number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to scale
pointOrFactorPointMemValue l numberIf factor is defined, the solid will be scaled in all direction with same scale value. Otherwise in the given x-, y- and z-direction of the vector.

Returns Promise<void>

slice#

Slices the solid at specified plane. Part of solid which is on the positive side of defined plane will be removed.

Declaration

async (drawingId: DrawingID, solid: ObjectID, point: PointMemValue, normal: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid to slice
pointPointMemValuePosition of the slice plane
normalPointMemValueNormal vector of the slice plane

Returns Promise<void>

solidExtendAtPlane#

The solid is extended at the defined plane with a solid created by extruding the section defined by the plane.

Declaration

async (drawingId: DrawingID, solid: ObjectID, point: PointMemValue, normal: PointMemValue, distance: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solidObjectIDId of the solid which will be extended
pointPointMemValuePosition of plane to extend from
normalPointMemValueNormal vector of plane to extend from
distancenumberDistance of extrusion

Returns Promise<void>

subtract#

Creats a subtractio between two solids

Declaration

async (drawingId: DrawingID, solid1: ObjectID, keepSolid: boolean, solid2: ObjectID): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solid1ObjectIDId of the base solid of subtraction
keepSolidbooleanIf true, the solid will be kept and can be used again
solid2ObjectIDId of the solid to subtract from base solid

Returns Promise<number>
Id of result solid after intersection

union#

Creates a union between two solids

Declaration

async (drawingId: DrawingID, solid1: ObjectID, keepSolid: boolean, solid2: ObjectID): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDId of the drawing
solid1ObjectIDId of the base solid of union
keepSolidbooleanIf true, the solid will be kept and can be used again
solid2ObjectIDId of the solid to unite with base solid

Returns Promise<number>
Id of the result solid after union