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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| instances | InstanceParam[] | 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| name | string | Name of the converted template |
Returns Promise<void>
create3DConstraint#
Creates new 3D constraint in the assembly
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| assemblyId | ObjectID | Id of the assembly to create the constraint on | |
| cctype | string | Type of constraint to create | |
| name | string | Name 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| nodeOrProdId | ObjectID | Node 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| assemblyId | ObjectID | Id of the assembly which contains moved objects. |
Returns Promise<void>
loadProduct#
Loads the given data.
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| data | ArrayBuffer | The 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? | string | An 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| url | string | The 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| assemblyId | ObjectID | Id of the assembly which contains moved objects. | |
| rotation | number[] | An array of 9 numbers which make 3 consecutive rotation (basis) vectors. | |
| offset | number[] | An array of 3 numbers which make a translation vector. |
Returns Promise<void>
removeInstances#
Removes the given instances
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id | |
| id | ObjectID | Id of the instance to set as the current |
Returns Promise<void>
startMovingUnderConstraints#
Prepares to move constrained objects (products).
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| assemblyId | ObjectID | Id of the assembly which contains moved objects. | |
| productRefIds | ObjectID[] | An array of object ids to be moved. | |
| pivotInfo | number[] | An array of numbers; For mucType === 0 or 1 it should contain 3 numbers which make a transform origin coords (for example, Gizmo position). | |
| mucType | 0 l 1 l 2 | Should 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| 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
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraintValues | ConstraintValueParam[] | Array of objects, containing the information of to update 3d constraint values |
Returns Promise<void>
updateCircularPatternConstraints#
Updates multiple Circular Pattern 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | CircularPatternConstraint[] | Array of objects, containing the information to update the circular pattern constraint |
Returns Promise<void>
updateCylindricalConstraints#
Updates multiple Cylindrical 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | CylindricalConstraint[] | Array of objects, containing the information to update the cylindrical constraint |
Returns Promise<void>
updateFastenedConstraints#
Updates multiple Fastened 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | FastenedConstraint[] | Array of objects, containing the information to update the fastened constraint |
Returns Promise<void>
updateFastenedOriginConstraints#
Updates multiple Fastened Origin 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | FastenedOriginConstraint[] | Array of objects, containing the information to update the fastened origin constraint |
Returns Promise<void>
updateGearRelations#
Updates multiple Gear 3D relations
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| relations | GearRelation[] | Array of objects, containing the information to update the gear relation |
Returns Promise<void>
updateGroupConstraints#
Updates multiple Group 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | GroupConstraint[] | Array of objects, containing the information to update the group constraint |
Returns Promise<void>
updateLinearPatternConstraints#
Updates multiple Linear Pattern 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | LinearPatternConstraint[] | Array of objects, containing the information to update the linear pattern constraint |
Returns Promise<void>
updateParallelConstraints#
Updates multiple Parallel 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | ParallelConstraint[] | Array of objects, containing the information to update the parallel constraint |
Returns Promise<void>
updatePlanarConstraints#
Updates multiple Planar 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | PlanarConstraint[] | Array of objects, containing the information to update the planar constraint |
Returns Promise<void>
updateRevoluteConstraints#
Updates multiple Revolute 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | RevoluteConstraint[] | Array of objects, containing the information to update the revolute constraint |
Returns Promise<void>
updateSliderConstraints#
Updates multiple Slider 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | SliderConstraint[] | Array of objects, containing the information to update the slider constraint |
Returns Promise<void>
updateSphericalConstraints#
Updates multiple Spherical 3D constraints
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| constraints | SphericalConstraint[] | Array of objects, containing the information to update the spherical constraint |
Returns Promise<void>