Skip to main content

Assembly Builder

assemblyBuilderAPI#

Provides functions for interaction with the classcad assembly builder api.

addInstances#

Adds products as instances to root assembly, assembly instance or assembly template.

  • If the owner is an instance in the expanded tree, its template in the assembly container will also be updated.
  • If the onwer is an assembly template, all instances of the template will also be updated

Declaration

async (drawingId: DrawingID, instances: InstanceParam[]): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingID
instancesInstanceParam[]Array of objects, containing the information of to adding instances

Returns Promise<number[]>
Array containing the ids of the added instances

convertToTemplate#

Converts the current root assembly into a template and adds it to the assembly container. It also creates a new empty root assembly

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
namestringName of the converted template

Returns Promise<void>

create3DConstraint#

Creates new 3D constraint in the assembly

Declaration

async (drawingId: DrawingID, assemblyId: ObjectID, cctype: string, name: string): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
assemblyIdObjectIDId of the assembly to create the constraint on
cctypestringType of constraint to create
namestringName of the created constraint

Returns Promise<number>
The id of the new created constraint or null.

createAssemblyAsTemplate#

Creates a new assembly template. This template will be added to the assembly container and can be instantiated multiple times as a sub assembly in the root assembly or in other assembly template. Assembly templates can only be created if the root is already an assembly.

Declaration

async (drawingId: DrawingID, name: string = 'Assembly'): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
name?string'Assembly'Optional name for the assembly template, default is 'Assembly'.

Returns Promise<number>
Id of the assembly template

createPartAsTemplate#

Creates a new part template. This template will be added to the part container and can be instantiated multiple times in the root assembly or in assembly templates. Part templates can only be created if the root is already an assembly.

Declaration

async (drawingId: DrawingID, name: string = 'Part'): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
name?string'Part'Optional name for the part template, default is 'Part'.

Returns Promise<number>
Id of the part template

createRootAssembly#

Creates a new root assembly.

Declaration

async (drawingId: DrawingID, name: string = 'AssemblyRoot', options?: {
ident?: ObjectIdent;
}): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
name?string'AssemblyRoot'Optional name for the root assembly, default is 'AssemblyRoot'.
options.ident?ObjectIdent

Returns Promise<number>
The id of the created root assembly.

exportNode#

Exports the given node and its potential subtree in case of it is an assembly. The node will be converted to a CC_AssemblyRoot. All used products with its containers will be exported as well.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
nodeOrProdIdObjectIDNode in expanded tree or product to export
type?'ofb' l 'stp' l 'step' l 'stl''ofb'Type of file: either 'ofb', 'stp' or 'stl'

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

finishMovingUnderConstraints#

Finishes moving constrained objects (products).

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
assemblyIdObjectIDId of the assembly which contains moved objects.

Returns Promise<void>

loadProduct#

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 'step' l 'stl'.
name?stringAn optional name for data to load (for example filename). Has just logging purpose.
options.ident?ObjectIdent

Returns Promise<number[]>
Array containing the id of the loaded products

loadProductFromUrl#

Loads a product from the given URL. Caller is responsible the identical product is not used already.

Declaration

async (drawingId: DrawingID, url: string, filetype: 'ofb' | 'stp' | 'step' | 'stl', options?: {
ident?: ObjectIdent;
}): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
urlstringThe url.
filetype'ofb' l 'stp' l 'step' l 'stl'The file type.
options.ident?ObjectIdent

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

moveUnderConstraints#

Attempts to move constrained objects (products). 'rotation' and 'offset' parameters should be decomposed from transform T: W0*T=W, where W0 is the original transform of the moved object, and W is a wanted transform.

Declaration

async (drawingId: DrawingID, assemblyId: ObjectID, rotation: number[], offset: number[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
assemblyIdObjectIDId of the assembly which contains moved objects.
rotationnumber[]An array of 9 numbers which make 3 consecutive rotation (basis) vectors.
offsetnumber[]An array of 3 numbers which make a translation vector.

Returns Promise<void>

removeInstances#

Removes the given instances

Declaration

async (drawingId: DrawingID, instances: {
id: ObjectID | ObjectIdent;
}[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id
instances{ id: ObjectID l ObjectIdent }[]Instances to be removed. Array of objects containing the instance id.

Returns Promise<void>

setCurrentInstance#

Sets the current instance

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id
idObjectIDId of the instance to set as the current

Returns Promise<void>

startMovingUnderConstraints#

Prepares to move constrained objects (products).

Declaration

async (drawingId: DrawingID, assemblyId: ObjectID, productRefIds: ObjectID[], pivotInfo: number[], mucType: 0 | 1 | 2): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
assemblyIdObjectIDId of the assembly which contains moved objects.
productRefIdsObjectID[]An array of object ids to be moved.
pivotInfonumber[]An array of numbers; For mucType === 0 or 1 it should contain 3 numbers which make a transform origin coords (for example, Gizmo position).
mucType0 l 1 l 2Should equal 0 in case of one-dimensionsal translation, 1 in case of two-dimensional translation, 2 in case of rotation

Returns Promise<void>

transformInstances#

Transforms the given instances by given transformations.

Declaration

async (drawingId: DrawingID, instances: {
id: ObjectID | ObjectIdent;
transformation: TransformParam;
options?: {
isLocal?: boolean;
};
}[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
instances{ id: ObjectID l ObjectIdent; transformation: TransformParam; options?: { isLocal?: boolean } }[]Array of objects, containing the information of to transform instances

Returns Promise<void>

update3DConstraintValues#

Updates multiple constraint's specified (with 'paramName') limited value

Declaration

async (drawingId: DrawingID, constraintValues: ConstraintValueParam[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintValuesConstraintValueParam[]Array of objects, containing the information of to update 3d constraint values

Returns Promise<void>

updateCircularPatternConstraints#

Updates multiple Circular Pattern 3D constraints

Declaration

async (drawingId: DrawingID, constraints: CircularPatternConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsCircularPatternConstraint[]Array of objects, containing the information to update the circular pattern constraint

Returns Promise<void>

updateCylindricalConstraints#

Updates multiple Cylindrical 3D constraints

Declaration

async (drawingId: DrawingID, constraints: CylindricalConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsCylindricalConstraint[]Array of objects, containing the information to update the cylindrical constraint

Returns Promise<void>

updateFastenedConstraints#

Updates multiple Fastened 3D constraints

Declaration

async (drawingId: DrawingID, constraints: FastenedConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsFastenedConstraint[]Array of objects, containing the information to update the fastened constraint

Returns Promise<void>

updateFastenedOriginConstraints#

Updates multiple Fastened Origin 3D constraints

Declaration

async (drawingId: DrawingID, constraints: FastenedOriginConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsFastenedOriginConstraint[]Array of objects, containing the information to update the fastened origin constraint

Returns Promise<void>

updateGearRelations#

Updates multiple Gear 3D relations

Declaration

async (drawingId: DrawingID, relations: GearRelation[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
relationsGearRelation[]Array of objects, containing the information to update the gear relation

Returns Promise<void>

updateGroupConstraints#

Updates multiple Group 3D constraints

Declaration

async (drawingId: DrawingID, constraints: GroupConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsGroupConstraint[]Array of objects, containing the information to update the group constraint

Returns Promise<void>

updateLinearPatternConstraints#

Updates multiple Linear Pattern 3D constraints

Declaration

async (drawingId: DrawingID, constraints: LinearPatternConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsLinearPatternConstraint[]Array of objects, containing the information to update the linear pattern constraint

Returns Promise<void>

updateParallelConstraints#

Updates multiple Parallel 3D constraints

Declaration

async (drawingId: DrawingID, constraints: ParallelConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsParallelConstraint[]Array of objects, containing the information to update the parallel constraint

Returns Promise<void>

updatePlanarConstraints#

Updates multiple Planar 3D constraints

Declaration

async (drawingId: DrawingID, constraints: PlanarConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsPlanarConstraint[]Array of objects, containing the information to update the planar constraint

Returns Promise<void>

updateRevoluteConstraints#

Updates multiple Revolute 3D constraints

Declaration

async (drawingId: DrawingID, constraints: RevoluteConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsRevoluteConstraint[]Array of objects, containing the information to update the revolute constraint

Returns Promise<void>

updateSliderConstraints#

Updates multiple Slider 3D constraints

Declaration

async (drawingId: DrawingID, constraints: SliderConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsSliderConstraint[]Array of objects, containing the information to update the slider constraint

Returns Promise<void>

updateSphericalConstraints#

Updates multiple Spherical 3D constraints

Declaration

async (drawingId: DrawingID, constraints: SphericalConstraint[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
constraintsSphericalConstraint[]Array of objects, containing the information to update the spherical constraint

Returns Promise<void>