Skip to main content

History

ApiHistory#

History based modeling is similar to solid modeling, but it is non-destructive and parametric. You can move back and forth in the modeling history and create feature expressions which you can alter at a later time, prompting your model to re-calculate. Use this for assembly and variant configurators.

The history modeling approach relies heavily on the underlying assemblyBuilder ClassCAD API. Since this part of the API is still under construction, the interfaces of the history functions can still change.

npm install @buerli.io/headless
import { History } from '@buerli.io/headless'
const cad = new History(url)
cad.init(async api => {
// Your code goes here
})

addDimensions#

Adds multiple dimensions to products in the 3D view

Declaration

(...dimensions: DimensionType[]) => Promise<ObjectID[] | null>

Params

NameTypeDefaultDescription
dimensionsDimensionType[]Dimensions to be added to products

Returns Promise<ObjectID[] | null>
Array containing the ids of added dimensions

Example

// Get the current product
const productId = await api.getCurrentProduct()
// Create dimensions
const dimension1: DimensionType = {
productId: productId,
dimParam: {
dimType: 'LinearDimension',
dimLabel: 'Breite = ',
dimStartPos: { x: 0, y: 0, z: 0 },
dimEndPos: { x: 100, y: 0, z: 0 },
dimTextPos: { x: 50, y: -10, z: 0 },
dimTextAngle: 0,
dimOrientation: 'Horizontal',
},
dxfView: 'Top',
}
const dimension2: DimensionType = {
productId: productId,
dimParam: {
dimType: 'LinearDimension',
dimLabel: 'Laenge = ',
dimStartPos: { x: 0, y: 0, z: 0 },
dimEndPos: { x: 0, y: 100, z: 0 },
dimTextPos: { x: 10, y: 50, z: 0 },
dimTextAngle: 0,
dimOrientation: 'Horizontal',
},
dxfView: 'Top',
}
// Add the dimensions
const dimensionIds = await api.addDimensions(dimension1, dimension2)

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

(...instances: {
productId: VID | ObjectIdent;
ownerId: VID | ObjectIdent;
transformation: Transform;
name?: string;
options?: {
ident?: ObjectIdent;
};
}[]) => Promise<ObjectID[] | null>

Params

NameTypeDefaultDescription
instances{ productId: VID l ObjectIdent ownerId: VID l ObjectIdent transformation: Transform name?: string options?: { ident?: ObjectIdent } }[]Array of objects containing the information of "to add" instances. See following parameter descriptions.

Returns Promise<ObjectID[] | null>
Array containing the ids of added instances direct to owner

boolean#

Creates a boolean operation.

Declaration

(partId: VID, type: BooleanOperationType, operations: VID[]) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the operation will be created on
typeBooleanOperationTypeType of boolean operation.
operationsVID[]Ids of the operations for this boolean operation, e.g. Box, Chamfer. At least two operations are needed. First operation in the array is the basic operation, all following are the tool operations, which will be unified, subtract or intersect with/from the first operation.

Returns ID
Id of the boolean operation

Example

// Creates a box and subtracts a cylinder from it
const part = api.createPart('Part')
const cyl = api.cylinder(part, [], 10, 100)
const box = api.box(part, [], 20, 20, 20)
api.boolean(part, BooleanOperationType.Subtraction, [box, cyl])
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

box#

Creates a box operation

Declaration

(partId: VID, references: VID[], width: number | string, length: number | string, height: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the box will be created
referencesVID[]Reference of work coordinate system to place the box at
widthnumber l stringWidth of the box (y-axis)
lengthnumber l stringLength of the box (x-axis)
heightnumber l stringHeight of the box (z-axis)

Returns ID
Id of the box operation

Example

// Creates a box with a length, width and height of 20
const part = api.createPart('Part')
const box = api.box(part, [], 20, 20, 20)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

chamfer#

Creates a chamfer operation

Declaration

(partId: VID, type: ChamferType, references: VIDs, dist1: number | string, dist2: number | string, angle: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the chamfers will be created
typeChamferTypeType of chamfer operation.
referencesVIDsEdge references where the chmamfers will be created on
dist1number l string1st distance of the chamfer from the edge
dist2number l string2nd distance of the chamfer from the edge. Optional if type = Equal_Distance or Distance_And_Angle
anglenumber l stringAngle of the chamfer. Optional if type = Equal_Distance or Two_Distances

Returns ID
Id of the chamfer operation

Example

// Creates a cylinder and puts a chamfer at the bottom edge
const part = api.createPart('Part')
api.cylinder(part, [], 10, 100)
const bottomEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 0 }])
api.chamfer(part, ChamferType.Equal_Distance, bottomEdges, 2, 0, 0)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

circularPattern#

Creates a circular pattern operation

Declaration

(partId: VID, operations: VID[], references: VID[], params: {
inverted: 0 | 1;
angle: number | string;
count: number | string;
merged: 0 | 1;
}) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to create the circular pattern in.
operationsVID[]Ids of the operations which are used for this circular pattern operation, e.g. box, extrusion, chamfer operation
referencesVID[]References for the rotation axis of the pattern. E.g. edge / work axis or 2 vertices / work points
params.inverted0 l 1
params.anglenumber l string
params.countnumber l string
params.merged0 l 1

Returns ID
Id of the circular pattern operation

cone#

Creates a cone operation.

Declaration

(partId: VID, references: VID[], bDiameter: number | string, tDiameter: number | string, height: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the cone will be created
referencesVID[]Reference of work coordinate system to place the cone at
bDiameternumber l stringBottom diameter of the cone
tDiameternumber l stringTop diameter of the cone
heightnumber l stringHeight of the cone

Returns ID
Id of the cone operation

Example

// Creates a cone with bottom diameter = 20, top diameter = 0 and height = 20
const part = api.createPart('Part')
api.cone(part, [], 20, 0, 20)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

copySketch#

Copy an existing sketch and adds its elements to a new sketch. The id of this new created sketch will be returned.

Declaration

(partId: VID, sketchId: VID, planeId: VID) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part we want to create the new sketch and copy the sketch elements into it
sketchIdVIDId of the sketch to copy
planeIdVIDId of the face or workplane to set the new sketch on

Returns ID
Id of the new sketch, containing the sketch elements form copied sketch

create2DViews#

Creates different 2D views, depending on the given view types, in the given product.

Declaration

(productId: VID, viewTypes: ViewType[], viewOptions?: ViewOptionsType) => IDs

Params

NameTypeDefaultDescription
productIdVIDId of the product where the view will be created in
viewTypesViewType[]Array of view types. E.g. [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO, ...
viewOptions?ViewOptionsTypeOptional object of options (currently color and layer) to set for the views. - color: number value 0 - 256, see AutoCAD Color Index (ACI). 256 = color defined by layer - layer: string value, defines the view's layer - Default = { color: 256, layer: '0'}

Returns IDs
Array containing the ids of created views

Example

// Optionally add dimensions to the product, see addDimension() or addDimensions()
await api.addDimensions(...)
// Create the wanted views
await api.create2DViews(productId, [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO], { color: 2, layer: '6'})

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

(name?: string) => ID

Params

NameTypeDefaultDescription
name?string[optional] name of the assembly template. Default = 'Assembly'

Returns ID
Id of the assembly template

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset1 = { x: 0, y: 0, z: 0 }
const offset2 = { x: 0, y: 0, z: 0 }
const offset3 = { x: 50, y: 0, z: 0 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a assembly template
const asmTempl = await api.createAssemblyAsTemplate('Assembly_Template')
// Creates a part template and adds geometry to it
const partTempl1 = await api.createPartAsTemplate('Part_Template1')
const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
api.box(partTempl1, [wcs1], 30, 30, 30)
// Creates another part template and adds geometry to it
const partTempl2 = await api.createPartAsTemplate('Part_Template2')
const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as instances to the assembly
// and the assembly itself multiple times to the root assembly
const prt1 = await api.addInstances(partTempl1, asmTempl, [orig, xDir, yDir])
const prt2 = await api.addInstances(partTempl2, asmTempl, [orig, xDir, yDir])
const asm1 = await api.addInstances(asmTempl, rootAsm, [orig, xDir, yDir])
const asm2 = await api.addInstances(asmTempl, rootAsm, [offset3, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createBufferGeometry#

Creates the buffer geometry of any product (part or assembly).

Declaration

(productId: VID) => Promise<BufferGeometry[] | undefined>

Params

NameTypeDefaultDescription
productIdVIDId of the product to create buffer geometry from

Returns Promise<BufferGeometry[] | undefined>
Array of buffer geometry

Example

// Creates a cone with bottom diameter = 20, top diameter = 0 and height = 30
const part = api.createPart('Part')
api.cone(part, [], 20, 0, 30)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createCylindricalConstraint#

Creates a cylindrical constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
zOffsetLimitsLimitsParamMin and max value of offset along z
zRotationLimitsLimitsParamMin and max value of rotation around z
namestringName of the constraint

Returns Promise<ObjectID | null>
Id of the cylindrical constraint

createExpressions#

Creates one or more expressions.

Declaration

(partId: VID | ObjectIdent, ...members: {
name: string;
value: number | string;
}[]) => Promise<boolean>

Params

NameTypeDefaultDescription
partIdVID l ObjectIdentId or identifier of the part to create the expressions in
members{ name: string; value: number l string }[]Array of members which contain a name and a value. Value can be an expression, e.g. '2 * laenge'

Returns Promise<boolean>
True or false, depending on whether creating the expressions was successful or not

Example

// Creates an expression and links it with the width of the box
const part = api.createPart('Part')
api.createExpressions(part, { name: 'width', value: 20 })
api.box(part, [], 'ExpressionSet.width', 20, 20)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createFastenedConstraint#

Creates a fastened constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string, xRotation?: number | string, yRotation?: number | string, zRotation?: number | string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its 1st part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
xOffsetnumber l stringDefines a offset in x-axis from mate1 to mate2
yOffsetnumber l stringDefines a offset in y-axis from mate1 to mate2
zOffsetnumber l stringDefines a offset in z-axis from mate1 to mate2
namestringName of the constraint
xRotation?number l string[optional] defines a rotation of mate2 around x-axis of mate1
yRotation?number l string[optional] defines a rotation of mate2 around y-axis of mate1
zRotation?number l string[optional] defines a rotation of mate2 around z-axis of mate1

Returns Promise<ObjectID | null>
Id of the fastened constraint

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset1 = { x: 0, y: 0, z: 0 }
const offset2 = { x: 0, y: 0, z: 0 }
const offset3 = { x: 15, y: 15, z: 30 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a part template and adds geometry to it
const partTempl1 = await api.createPartAsTemplate('Part_Template1')
const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
api.box(partTempl1, [wcs1], 30, 30, 30)
// Creates another part template and adds geometry to it
const partTempl2 = await api.createPartAsTemplate('Part_Template2')
const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as instances to the root assembly
const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
// Creates a fastened constraint between the instances
await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 'FC', 0, 0, 0)
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createFastenedOriginConstraint#

Creates a fastened origin constraint for mate1 to the origin (0, 0, 0).

Declaration

(id: VID, mate1: MateParam, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string, xRotation?: number | string, yRotation?: number | string, zRotation?: number | string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
xOffsetnumber l stringDefines a offset in x-axis from mate1 to mate2
yOffsetnumber l stringDefines a offset in y-axis from mate1 to mate2
zOffsetnumber l stringDefines a offset in z-axis from mate1 to mate2
namestringName of the constraint
xRotation?number l string[optional] defines a rotation of mate2 around x-axis of mate1
yRotation?number l string[optional] defines a rotation of mate2 around y-axis of mate1
zRotation?number l string[optional] defines a rotation of mate2 around z-axis of mate1

Returns Promise<ObjectID | null>
Id of the fastened origin constraint

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset1 = { x: 0, y: 0, z: 0 }
const offset2 = { x: 15, y: 15, z: 15 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a part template and adds geometry to it
const partTempl = await api.createPartAsTemplate('Part_Template')
const wcs1 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs')
const wcs2 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs')
api.box(partTempl, [wcs1], 30, 30, 30)
// Adds the created part template as an instance to the root assembly
const prt = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
// Creates a fastened origin constraint. The box of the part will be centered in origin
await api.createFastenedOriginConstraint(rootAsm, { matePath: [prt], wcsId: wcs2 }, 0, 0, 0, 'FOC', 0, 0, 0)
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial({ transparent: true, opacity: 0.5 })))

createParallelConstraint#

Creates a parallel constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
xOffsetLimitsLimitsParamMin and max value of offset along x
yOffsetLimitsLimitsParamMin and max value of offset along y
zOffsetLimitsLimitsParamMin and max value of offset along z
zRotationLimitsLimitsParamMin and max value of rotation around z
namestringName of the constraint

Returns Promise<ObjectID | null>
Id of the parallel constraint

createPart#

Creates a new root part. This is the top level part.

Declaration

(name?: string) => ID

Params

NameTypeDefaultDescription
name?string[optional] name of the part. Default = 'Part'

Returns ID
Id of the root part

Example

// Creates a box and subtracts a cylinder from it
const part = api.createPart('Part')
api.cylinder(part, [], 10, 100)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

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

(name?: string) => ID

Params

NameTypeDefaultDescription
name?string[optional] name of the part. Default = 'Part'

Returns ID
Id of the part template

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset = { x: 20, y: 0, z: 0 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a part template and adds geometry to it
const partTempl = await api.createPartAsTemplate('Part_Template')
const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
api.box(partTempl, [wcs], 30, 30, 10)
// Adds the created part template as an instance to the root assembly
const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createPlanarConstraint#

Creates a planar constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
zOffsetnumber l stringDefines a offset in z-axis from mate1 to mate2
xOffsetLimitsLimitsParamMin and max value of offset along x
yOffsetLimitsLimitsParamMin and max value of offset along y
zRotationLimitsLimitsParamMin and max value of rotation around z
namestringName of the constraint

Returns Promise<ObjectID | null>
Id of the planar constraint

createRevoluteConstraint#

Creates a revolute constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
zOffsetnumber l stringDefines a offset in z-axis from mate1 to mate2
zRotationLimitsLimitsParamMin and max value of rotation around z
namestringName of the constraint

Returns Promise<ObjectID | null>
Id of the revolute constraint

createRootAssembly#

Creates a new root assembly. This is the top level assembly.

Declaration

(name?: string, options?: {
ident?: ObjectIdent;
}) => ID

Params

NameTypeDefaultDescription
name?string[optional] name of the root assembly. Default = 'AssemblyRoot'
options.ident?ObjectIdent

Returns ID
Id of the root assembly

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset = { x: 20, y: 0, z: 0 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a part template and adds geometry to it
const partTempl = await api.createPartAsTemplate('Part_Template')
const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
api.box(partTempl, [wcs], 30, 30, 10)
// Adds the created part template as an instance to the root assembly
const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createScene#

Creates the threeJS scene of any product (part or assembly).

Declaration

(productId?: VID, options?: {
meshPerGeometry?: boolean;
structureOnly?: boolean;
}) => Promise<{
scene: Scene;
nodes: {
[key: string]: Object3D;
};
materials: {
[key: string]: Material;
};
}>

Params

NameTypeDefaultDescription
productId?VIDId of the product to create scene from
options.meshPerGeometry?boolean
options.structureOnly?boolean

Returns Promise<{ scene: Scene; nodes: { [key: string]: Object3D }; materials: { [key: string]: Material } }>
Object containing all the created THREE objects like scene, nodes and materials

createSliderConstraint#

Creates a slider constraint between mate1 and mate2 within an assembly.

Declaration

(id: VID, mate1: MateParam, mate2: MateParam, xOffset: number | string, yOffset: number | string, zOffsetLimits: LimitsParam, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
idVIDId of the root assembly or an assembly template to create constraints on
mate1MateParamContains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
mate2MateParamContains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
xOffsetnumber l stringDefines a offset in x-axis from mate1 to mate2
yOffsetnumber l stringDefines a offset in y-axis from mate1 to mate2
zOffsetLimitsLimitsParamMin and max value of offset along z
namestringName of the constraint

Returns Promise<ObjectID | null>
Id of the slider constraint

createWorkAxis#

Creates a new work axis for the given part

Declaration

(partId: VID, type: WorkAxisType, references: VID[], position: Vec<number | string>, direction: Vec<number | string>, local: boolean, name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to add the new work axis to
typeWorkAxisTypeType of the work axis
referencesVID[]References for the work axis, needed for all types except 'Custom'
positionVec<number l string>Position of axis, only needed if type = 'Custom'
directionVec<number l string>Direction of axis, only needed if type = 'Custom'
localbooleanIf true, work axis is set in local coordinates of part???
name?stringName of the work axis, if not set default name = 'WorkAxis'

Returns ID
Id of the work axis

createWorkCoordSystem#

Creates a new work coordinate system for the given part.

Declaration

(partId: VID, type: WorkCoordSystemType, references: VID[], offset: Vec<number | string>, rotation: Vec<number | string>, inverted: boolean, name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to add the new work coord system to
typeWorkCoordSystemTypeType of the work coordinate system
referencesVID[]References for the work coordinate system (point and 2 axis). If empty array, the work coordinate system will set to origin (0, 0, 0)
offsetVec<number l string>Offset from work coordinate system in x-, y- and z-direction
rotationVec<number l string>Rotation around x-, y- and z-axis from work coordinate system
invertedbooleanInverts the direction of the primary axis
name?stringName of the work coordinate system, if not set default name = 'WorkCoordSystem'

Returns ID
Id of the work coordinate system

Example

// Defines some consts
const orig = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const rot = { x: 0, y: 0, z: 0 }
const offset1 = { x: 0, y: 0, z: 0 }
const offset2 = { x: 0, y: 0, z: 0 }
const offset3 = { x: 15, y: 15, z: 30 }
// Creates the root assembly first
const rootAsm = await api.createRootAssembly('Root_Assembly')
// Creates a part template and adds geometry to it
const partTempl1 = await api.createPartAsTemplate('Part_Template1')
const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
api.box(partTempl1, [wcs1], 30, 30, 30)
// Creates another part template and adds geometry to it
const partTempl2 = await api.createPartAsTemplate('Part_Template2')
const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as instances to the root assembly
const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
// Creates a fastened constraint between the instances
await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 0, 0, 'FC')
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createWorkPlane#

Creates a new work plane for the given part

Declaration

(partId: VID, type: WorkPlaneType, references: VID[], offset: number, angle: number, position: Vec<number | string>, normal: Vec<number | string>, local: boolean, name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to add the new work plane to
typeWorkPlaneTypeType of the work plane
referencesVID[]References for the work plane, needed for all types except 'Custom'
offsetnumberOffset in normal direction, can be used for all types except 'LinePlaneAndAngle'
anglenumberAngle in degrees, needed for type 'LinePlaneAndAngle'
positionVec<number l string>Position of plane, only needed if type = 'Custom'
normalVec<number l string>Normal vector of work plane, only needed if type = 'Custom'
localbooleanIf true, work plane is set in local coordinates of part???
name?stringName of the work plane, if not set default name = 'WorkAxis'

Returns ID
Id of the work plane

createWorkPoint#

Creates a new work point for the given part

Declaration

(partId: VID, type: WorkPointType, references: VID[], position: Vec<number | string>, local: boolean, name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to add the new work point to
typeWorkPointTypeType of the work point
referencesVID[]References for the work point, needed for all types except 'Custom'
positionVec<number l string>Position of point, only needed if type = 'Custom'
localbooleanIf true, work point is set in local coordinates of part???
name?stringName of the work point, if not set default name = 'WorkPoint'

Returns ID
Id of the work point

cylinder#

Creates a cylinder operation

Declaration

(partId: VID, references: VID[], diameter: number | string, height: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the cylinder will be created
referencesVID[]Reference of work coordinate system to place the cylinder at
diameternumber l stringDiameter of the cylinder (x/y-axis)
heightnumber l stringHeight of the cylinder (z-axis)

Returns ID
Id of the cylinder operation

Example

// Creates a cylinder with height = 50 and diameter = 20
const part = api.createPart('Part')
api.cylinder(part, [], 20, 50)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

deleteExpressions#

Deletes existing expressions.

Declaration

(partId: VID | ObjectIdent, members: string[]) => Promise<boolean>

Params

NameTypeDefaultDescription
partIdVID l ObjectIdentId or identifier of part to delete expressions from
membersstring[]Name of members to delete

Returns Promise<boolean>
True or false, depending on whether deleting the expressions was successful or not

Example

// Deletes an expression from part's expression set
const part = api.createPart('Part')
api.createExpressions(part, { name: 'width', value: 20 }, { name: 'height', value: 40 })
api.deleteExpressions(part, ['height'])
await api.box(part, [], 'ExpressionSet.width', 20, 20)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

exportDXF#

Export the placed views as dxf file.

Declaration

(productId: VID, dxfTemplateFilename?: string) => Promise<Uint8Array | null>

Params

NameTypeDefaultDescription
productIdVIDId of the product where the views exist for export
dxfTemplateFilename?stringOptional filename to load different dxf template. E.g. 'StandardTemplate.dxf'

Returns Promise<Uint8Array | null>

Example

// After creating and placing the views, see place2DViews(), you can export them
// You will get the dxf stream back
await api.exportDXF(productId)

exportSVG#

Exports the placed views as dxf and converts it into svg stream.

Declaration

(productId: VID, modus?: SVGModusType, renderSize?: {
x: number;
y: number;
}, dxfTemplateFilename?: string) => Promise<Uint8Array | null>

Params

NameTypeDefaultDescription
productIdVIDId of the product where the views exist for export
modus?SVGModusTypeOptional modus to define how drawing will fit into svg file, - SVGModusType.WHOLE_DRAWING or SVGModusType.FIT_WHOLE_DRAWING - Default = SVGModusType.FIT_WHOLE_DRAWING
renderSize.xnumber
renderSize.ynumber
dxfTemplateFilename?stringOptional filename to load different dxf template. E.g. 'StandardTemplate.dxf'

Returns Promise<Uint8Array | null>

Example

// After creating and placing the views, see place2DViews(), you can export them
// You will get the svg stream back
await api.exportSVG(productId)

extrusion#

Creates an extrusion operation

Declaration

(partId: VID, sketchOrRegionIds: VID | VIDs, type: ExtrusionType, limit1: number | string, limit2: number | string, taperAngle: number | string, direction: Vec<number | string>, capEnds: 0 | 1) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to create the extrusion in.
sketchOrRegionIdsVID l VIDsId of the sketch to extrude or multiple ids of sketch regions
typeExtrusionTypeType of extrusion (up, down, symmetric, custom)
limit1number l stringStart of extrusion (0 = start at sketch, only for type custom necessary)
limit2number l stringEnd of extrusion, which is actually the height
taperAnglenumber l stringAngle of taper for extrusion
directionVec<number l string>Direction of extrusion
capEnds0 l 1If true, ends will be capped, else a sheet will be created

Returns ID
Id of the extrusion operation

fillet#

Creates a fillet operation

Declaration

(partId: VID, references: VIDs, radius: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the fillet will be created
referencesVIDsEdge references where the fillet will be created on
radiusnumber l stringRadius of the fillet

Returns ID
Id of the fillet operation

Example

// Creates a cylinder and puts a fillet at the top edge
const part = api.createPart('Part')
api.cylinder(part, [], 10, 100)
const topEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
api.fillet(part, topEdges, 2)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

findGeometry#

Find geometries of given type on solids in the given part at the given global positions.

Declaration

(partId: VID, type: GrT, positions: Vec[][]) => IDs

Params

NameTypeDefaultDescription
partIdVIDId of the part where geometries tried to be found.
typeGrTType of the geometry to look for
positionsVec[][]Array of elements containing one or more positions to look for the geometry

Returns IDs
Array containing ids of found geometries

Example

// Find planes at two different positions
const planes = await api.findGeometry(productId, GraphicType.PLANE, [[{x: 50, y: 50, z: 100}], [{x: 100, y: 50, z: 50}]])

findInstance#

Find first instance which can be identified by given identifier or name. If both optional parameters has been set, the identifier is treated with priority. If no instance with given identifier will be found, the name is used to find an instance.

Declaration

(options: {
instanceIdent?: ObjectIdent;
instanceName?: string;
}) => ID

Params

NameTypeDefaultDescription
options.instanceIdent?ObjectIdentIdentifier to find the instance by an identifier
options.instanceName?stringName to find the instance by its name

Returns ID
First found instance which meets the searching conditions or null if nothing could be found

getAssemblyTemplate#

Returns the assembly template with given name from assembly container. If asmName is empty, all assemblies from assembly container will be returned.

Declaration

(asmName?: string) => IDs

Params

NameTypeDefaultDescription
asmName?stringName of assembly to look for

Returns IDs
Array containing ids of assembly templates

getBoundaryBoxFromViews#

This method returns the boundary box of the given views.

Declaration

(productId: VID, viewTypes?: ViewType[]) => Promise<[
Vec,
Vec
][]>

Params

NameTypeDefaultDescription
productIdVIDId of the product from where the boundary box will returned
viewTypes?ViewType[]Array of view types. E.g. 'Top', 'Front', 'Iso', ...

Returns Promise<[Vec, Vec][]>
Array of tuples, each tuple contains a min and max value for one of the given view types. The min an max values represent a Vector with x-, y- and z-coordinates.

Example

// After views have been created, see create2DViews(), you can get boundary boxes
const bbs = await api.getBoundaryBoxFromViews(productId, ['Top', 'Right_90°', 'Iso'])
// Returns for each view a min and max point
console.info(bbs) // [[{x: -105, y: -89, z: 0}, {x: 105, y: 55, z: 0}], [...], [...]]

getConstraint#

DEPRECATED use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.

Returns information about a constraint in the given reference

Declaration

(refId: VID, constrName?: string) => Promise<ConstraintType>

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrName?stringName of the constraint to look for

Returns Promise<ConstraintType>
Array containing information about the constraint [ constraintId, [ reference id of first mate, workcoordsystem id of first mate, flip type of first mate, reoriented type of first mate ], [ reference id of second mate, workcoordsystem id of second mate, flip type of second mate, reoriented type of second mate ], xOffset, yOffset, zOffset ]

getCurrentInstance#

Returns the id of the current instance

Declaration

() => ID

Returns ID
Id of the current instance

getCurrentProduct#

Returns the id of the current product

Declaration

() => ID

Returns ID

getCylindricalConstraint#

Returns the cylindrical constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<CylindricalConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<CylindricalConstraintType>
Found cylindrical constraint as object.

getDrawing#

Returns the drawing of the current headless-session

Declaration

() => DrawingState

Returns DrawingState
DrawingState

Example

const drawing = api.getDrawing()
// Get all graphic containers
const containers = Object.values(drawing.graphic.containers)
containers.forEach(container => {
// Get all surfaces
const surfaces = container.meshes.map(mesh => mesh.properties.surface)
// Filter non cylindric
const cylinders = surfaces.filter(surface => surface.type === 'cylinder')
// Check if all cylinders have a radius greater than 4
cylinders.forEach(meta => expect(meta.radius).toBeGreaterThanOrEqual(4))
})

getDrawingId#

Returns the drawing id of the current headless-session

Declaration

() => DrawingID

Returns DrawingID
DrawingID

Example

const drawingId = api.getDrawingId()

getFastenedConstraint#

Returns the fastened constraint of given instance or assembly id with specified name.

Declaration

(id: VID, constrName: string) => Promise<FastenedConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<FastenedConstraintType>
Found fastened constraint as object.

getFastenedOriginConstraint#

Returns the fastened origin constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<FastenedOriginConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<FastenedOriginConstraintType>
Found fastened origin constraint as object.

getFeatureByName#

Returns the id of the feature / operation with name = featureName. The feature can then be used for further operations, like boolean, transformations and so on.

Declaration

(partId: VID, featureName: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where to look for the feature / operation
featureNamestringName of the feature to look for

Returns ID
Id of the feature / operation

getGeometryInformation#

Returns an object containing the center of gravity and the volume of the given product, instance or solid. 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

(id: VID) => Promise<ModelInfo | null>

Params

NameTypeDefaultDescription
idVIDId of the part, assembly, instance or solid we want the information from

Returns Promise<ModelInfo | null>
Object containing the geometry information

getInstance#

Returns an instance or all instances of a node, depending on whether a name is given or not. The node is the parent of the instance/instances we're looking for and can be a root assembly, another instance or an assembly template.

Declaration

(id: VID, instanceName?: string) => IDs

Params

NameTypeDefaultDescription
idVIDId of the node from which we are searching the children for instances that have the name we are looking for.
instanceName?stringName of the instance we are looking for

Returns IDs
Array containing the ids of the found instances

getMatePath#

Creates and returns the mate path as array from the given instance id up to the current instance. This helps to get the right path to set constraints between instances which are located in nested assemblies.

Declaration

(instanceId: VID | ObjectIdent) => Promise<ObjectID[]>

Params

NameTypeDefaultDescription
instanceIdVID l ObjectIdentId of the instance to get the mate path from

Returns Promise<ObjectID[]>
Array containing the ids as a path from given instance to current instance

getParallelConstraint#

Returns the parallel constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<ParallelConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<ParallelConstraintType>
Found parallel constraint as object.

getPartTemplate#

Returns the part template with given name from part container. If partName is empty, all parts from part container will be returned.

Declaration

(partName?: string) => IDs

Params

NameTypeDefaultDescription
partName?stringName of part to look for

Returns IDs
Array containing ids of part templates

getPlanarConstraint#

Returns the planar constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<PlanarConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<PlanarConstraintType>
Found planar constraint as object.

getProductsOfInstances#

Returns the product ids of the given instance ids.

Declaration

(instanceIds: VID[]) => IDs

Params

NameTypeDefaultDescription
instanceIdsVID[]Ids of the instances to get the product ids from

Returns IDs
Array containing the product ids of the given instance ids

getRevoluteConstraint#

Returns the revolute constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<RevoluteConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<RevoluteConstraintType>
Found revolute constraint as object.

getSketchRegion#

Returns the sketch region with the given sketchRegionName from the given instance or part id. If sketchRegionName is not set, all sketch regions of the reference will be returned.

Declaration

(id: VID, sketchRegionName?: string) => IDs

Params

NameTypeDefaultDescription
idVIDId of the instance or part to look for the sketch region
sketchRegionName?string

Returns IDs
Array containing ids of the sketch regions

getSliderConstraint#

Returns the slider constraint of given instance or assembly with specified name.

Declaration

(id: VID, constrName: string) => Promise<SliderConstraintType>

Params

NameTypeDefaultDescription
idVIDId of the instance or assembly to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<SliderConstraintType>
Found slider constraint as object.

getState#

Returns the state tree of the current headless-session

Declaration

() => BuerliState

Returns BuerliState
BuerliState

Example

const state = api.getState()

getTransformation#

Returns the global transformation of the given id. Currently only ids of instances supported.

Declaration

(id: VID) => Promise<number[][]>

Params

NameTypeDefaultDescription
idVIDId of the object to get the global transformation from

Returns Promise<number[][]>
Transformation of instance as two-dimensional array containing origin position and direction for x, y and z [ [origin.x, origin.y, origin.z], [xVec.x, xVec.y, xVec.z], [yVec.x, yVec.y, yVec.z], [zVec.x, zVec.y, zVec.z] ]

getWorkCoordSystem#

DEPRECATED use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.

Returns the work coord system with the given wcsName from the given reference. If wcsName is not set, all work coord systems of the reference will be returned.

Declaration

(id: VID, wcsName?: string) => IDs

Params

NameTypeDefaultDescription
idVID
wcsName?stringName of the work coord system to look for

Returns IDs
Array containing ids of work coordinate systems

Example

// Adds a loaded part to an assembly. To set the part to the origin of the
// assembly with a constraint, the work coord system can be get from part by name.
const pt0 = { x: 0, y: 0, z: 0 }
const xDir = { x: 1, y: 0, z: 0 }
const yDir = { x: 0, y: 1, z: 0 }
const nutBoltAsm = await api.createRootAssembly('NutBolt_Asm')
const bolt = await api.loadProduct(arraybuffer, 'ofb')
const boltRefId = await api.addInstances(bolt, nutBoltAsm, [pt0, xDir, yDir])
const wcsIdOrigin = await api.getWorkCoordSystem(boltRefId, 'WCS_Origin')
await api.createFastenedOriginConstraint(nutBoltAsm, { refId: boltRefId, wcsId: wcsIdOrigin[0] }, 0, 0, 0, 0, 0, 'FOC')
const geoms = await api.createBufferGeometry(nutBoltAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

getWorkGeometry#

Returns the work geometry of given type with given name from the given instance or part id. If the name of the work geometry is empty, all found work geometry of given type is returned

Declaration

(id: VID, type: WorkGeomType, wgName?: string) => IDs

Params

NameTypeDefaultDescription
idVIDId of the instance or part to look for the work geometry
typeWorkGeomTypeType of the work geometry to look for
wgName?stringOptional name of the work geometry to look for

Returns IDs
Array containing ids of the work geometry

importFeature#

Creates a import feature operation and appends geometry to it. This method can be used to import specific geometry which can be used for further operations like boolean, translations and so on.

Declaration

(partId: VID, content: ArrayBuffer, format: 'stp' | 'step', name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where to add the new feature
contentArrayBufferData buffer to add to the import feature
format'stp' l 'step'The content format
name?stringOptional name for the feature, default = 'Import'

Returns ID
Id of the import feature operation

linearPattern#

Creates a linear pattern operation

Declaration

(partId: VID, operations: VID[], references1: VID[], params1: {
inverted: 0 | 1;
distance: number | string;
count: number | string;
merged: 0 | 1;
}, references2?: VID[], params2?: {
inverted: 0 | 1;
distance: number | string;
count: number | string;
}) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to create the linear pattern in.
operationsVID[]Ids of the operations which are used for this linear pattern operation, e.g. box, extrusion, chamfer operation
references1VID[]References for the first axis of the pattern. E.g. edge / work axis or 2 vertices / work points
params1.inverted0 l 1
params1.distancenumber l string
params1.countnumber l string
params1.merged0 l 1
references2?VID[]Optional references for the second axis of the pattern.
params2.inverted0 l 1
params2.distancenumber l string
params2.countnumber l string

Returns ID
Id of the linear pattern operation

load#

Loads the given buffer.

Declaration

(content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
ident?: ObjectIdent;
}) => Promise<number[] | null>

Params

NameTypeDefaultDescription
contentArrayBufferData as arraybuffer
type'ofb' l 'stp'Type of the data to load
options.ident?ObjectIdent

Returns Promise<number[] | null>
Array containing the id of the loaded product in the file

loadFromUrl#

Loads from the given url.

Declaration

(url: string, filetype: 'ofb' | 'stp', options?: {
ident?: ObjectIdent;
}) => Promise<number[] | null>

Params

NameTypeDefaultDescription
urlstringThe url to load data from.
filetype'ofb' l 'stp'The type of data delivered by the url (ofb, stp).
options.ident?ObjectIdent

Returns Promise<number[] | null>
Array containing the id of the loaded product from url

loadProduct#

Loads a product into the current drawing and adds it to the part- or assembly container.

Declaration

(content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
ident?: ObjectIdent;
}) => Promise<number[] | null>

Params

NameTypeDefaultDescription
contentArrayBufferData as arraybuffer
type'ofb' l 'stp'Type of the data to load
options.ident?ObjectIdent

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

Example

// Loads an existing product
const part = api.loadProduct(arraybuffer, 'ofb')
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

loadProductFromUrl#

Loads a product from the given URL into the current drawing and adds it to the part- or assembly container.

Declaration

(url: string, filetype: 'ofb' | 'stp', options?: {
ident?: ObjectIdent;
}) => Promise<number[] | null>

Params

NameTypeDefaultDescription
urlstringThe url to load data from.
filetype'ofb' l 'stp'The type of data delivered by the url ('ofb', 'stp').
options.ident?ObjectIdent

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

loadSketch#

Loads a sketch from a ofb filestream and adds its elements to a new sketch. The id of this new created sketch will be returned.

Declaration

(partId: VID, strm: ArrayBuffer, planeId: VID, name?: string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part we want to create the new sketch and copy the sketch elements into it
strmArrayBufferStream of ofb file which contains the sketch
planeIdVIDId of the face or workplane to set the new sketch on
name?stringOptional name of the sketch to load from filestream

Returns ID
Id of the new sketch, containing the sketch elements from loaded sketch

mirror#

Creates a mirror operation. Mirrors the entities of an operation at the position of the plane reference

Declaration

(partId: VID, operations: VID[], references: VID[]) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
partIdVIDId of the part where the mirror will be created
operationsVID[]Ids of the operations which are used for this mirror operation, e.g. box, extrusion, chamfer operation
referencesVID[]Id of the references which will be used to mirror (e.g. Workplane)

Returns Promise<ObjectID | null>

pick#

DEPRECATED use findGeometry() instead, pick() will be removed in a future release.

Returns found vertices, edges or faces depending on given type and points. Given points define where to look for elements.

Declaration

(partId: VID, type: 'vertex' | 'edge' | 'face', points: Vec[]) => IDs

Params

NameTypeDefaultDescription
partIdVIDId of the part to pick elements
type'vertex' l 'edge' l 'face'Type of element to pick
pointsVec[]Points containing 3D coordinates to look for possible element

Returns IDs
Array containing ids of found geometries

Example

// Creates a cylinder an puts a fillet on the top edge
const part = api.createPart('Part')
api.cylinder(part, [], 10, 100)
const edges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
api.fillet(part, edges, 2)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

place2DViews#

Place the 2D views relatively to the origin.

Declaration

(productId: VID, viewPositions: {
viewType: ViewType;
vector: Vec;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
productIdVIDId of the product where the views will be placed in
viewPositions{ viewType: ViewType vector: Vec }[]Array of objects, containing the viewType and a vector which defines the moving vector of the given view

Returns Promise<void>

Example

// After the views have been created, see create2DViews(), you can place them relatively to origin {0,0,0}
await api.place2DViews(productId, [
{ viewType: 'Iso', vector: { x: 500, y: 500, z: 0 } },
{ viewType: 'Right_90°', vector: { x: 500, y: 0, z: 0 } },
])

placeSketch#

Place/position the sketch with plane, axis and origin references.

Declaration

(sketchId: VID, planeId: VID, invertPlane: boolean, axisId: VID, isXAxis: boolean, invertAxis: boolean, originId: VID) => Promise<void>

Params

NameTypeDefaultDescription
sketchIdVIDId of the sketch to place
planeIdVIDId of a face or a workplane. This will be the plane where the sketch lies on. If a plane reference already exists, planeId is optional
invertPlanebooleanIf true, the normal of the plane will be inverted
axisIdVIDOptional id of an edge or workaxis. This will be the x-Axis
isXAxisbooleanIf true, the axisId will be the x-axis of the sketch, else the x-Axis will be the crossvector of the normal and the axisId
invertAxisbooleanIf true, the direction of the axis will be inverted
originIdVIDOptional point or vertex of the sketch's origin reference

Returns Promise<void>

removeDimensions#

Remove existing dimensions from the view.

Declaration

(dimensionIds: VID[]) => Promise<void>

Params

NameTypeDefaultDescription
dimensionIdsVID[]Ids of the dimensions to be removed

Returns Promise<void>

Example

// You can remove existing dimensions
await api.removeDimensions(dimensionIds)

removeInstances#

Removes instances from root assembly, other instances or assembly templates.

Declaration

(...instances: {
id: VID | ObjectIdent;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
instances{ id: VID l ObjectIdent }[]Array of instance objects. See following parameter descriptions.

Returns Promise<void>

removeOperations#

Removes the given operations or the operations which are added after 'toOperation' in history, depending on whether operations or toOperation parameter is given.

Declaration

(operations: VID[], toOperation: VID) => Promise<void>

Params

NameTypeDefaultDescription
operationsVID[]Ids of all to remove operations. First element in the array will be removed first. This means operations which depend on each other, need to be removed from newest to oldest.
toOperationVIDAll operations, from rollback bar until the id of this operation, will be deleted

Returns Promise<void>

revolve#

Creates a revolve operation

Declaration

(partId: VID, sketchOrRegionIds: VID | VIDs, axisIds: VID[], angle1: number | string, angle2: number | string, inverted: 0 | 1) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part to create the revolve in.
sketchOrRegionIdsVID l VIDsId of the sketch to extrude or multiple ids of sketch regions
axisIdsVID[]Array of ids, either [lineId] or [point1Id, point2Id], ids can be both ccId or graphicId
angle1number l stringStart of revolve in degrees
angle2number l stringEnd of revolve in degrees
inverted0 l 1Flag, whether to invert the axis or not

Returns ID
Id of the revolve operation

save#

Writes the current drawing to a stream and returns the 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

(type: 'ofb' | 'stp') => Promise<Uint8Array | null>

Params

NameTypeDefaultDescription
type'ofb' l 'stp'Type to write

Returns Promise<Uint8Array | null>
Stream data

saveToUrl#

Writes the current drawing to a stream and POSTs the result to the given url.

Declaration

(url: string, filetype: 'ofb' | 'stp') => Promise<boolean>

Params

NameTypeDefaultDescription
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 successful

selectGeometry#

Important note: To use this method, you need to add the BuerliGeometry component to your application. Otherwise the selection of geometry won't work. See this link to buerli geometry

Lets the user select geometry in graphical interface. As soon as the geometry of given type has been selected, the method will return necessary information about it. See this link to selections

The userData of the returned object contains additional information about the selected geometry. All geometric information in the userData is already transformed to the correct position. This is especially important for assemblies.

Declaration

<T = GeometryElement>(types: GrT[], count?: number) => Promise<InteractionInfo<T>[]>

Params

NameTypeDefaultDescription
typesGrT[]Array of types to filter user selection.
count?numberOptional number of selections to make (count must be >= 1). Default = 1.

Returns Promise<InteractionInfo<T>[]>
Array of objects containing information about selected geometries

setCurrentInstance#

Sets the instance with id to the new current instance

Declaration

(id: VID) => Promise<void>

Params

NameTypeDefaultDescription
idVIDId of the instance to set as the current

Returns Promise<void>

setCurrentProduct#

Sets the product with productId to the new current product

Declaration

(productId: VID) => Promise<void>

Params

NameTypeDefaultDescription
productIdVIDId of the product to set as the current

Returns Promise<void>

setExpressions#

Updates multiple expressions in different parts at once

Declaration

(...expressions: {
partId: VID | ObjectIdent;
members: {
name: string;
value: number | string;
}[];
}[]) => Promise<boolean>

Params

NameTypeDefaultDescription
expressions{ partId: VID l ObjectIdent members: { name: string; value: number l string }[] }[]Array of expression objects containing the part id and the expression to set

Returns Promise<boolean>
True, if updating expressions in all parts was successfull

setFacetingParameters#

Sets the global faceting parameters that will stick for this drawing. This defines how detailed solids will be displayed and can yield smaller payloads.

Declaration

(distanceTol: number, angleTol: number) => Promise<void>

Params

NameTypeDefaultDescription
distanceTolnumberDistance tolerance
angleTolnumberAngle tolerance

Returns Promise<void>
Void

Example

api.setFacetingParameters(0.1, 0)

slice#

Creates a slice operation. Slices the entities of the given operations by the given reference.

Declaration

(partId: VID, operations: VID[], reference: VID, sideFlag: boolean) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the slice will be created
operationsVID[]Ids of the operations which are used for this slice operation, e.g. box, extrusion, chamfer operation
referenceVIDId of the workplane reference to use for the slice
sideFlagbooleanFlag to toggle which side of the slice will be kept

Returns ID
Id of the slice operation

sliceBySheet#

Creates a slice by sheet operation. Slices the entity of an operation with a sheet entity of another operation

Declaration

(partId: VID, operationToSlice: VID, operationOfSheet: VID, sideFlag: boolean) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the slice will be created
operationToSliceVIDId of the operation which will be sliced in this slice by sheet operation
operationOfSheetVIDId of the operation which is used as the slice
sideFlagbooleanFlag to toggle which side of the slice will be kept

Returns ID
Id of the slice by sheet operation

sphere#

Creates a sphere operation

Declaration

(partId: VID, references: VID[], radius: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId of the part where the sphere will be created
referencesVID[]Reference of work coordinate system to place the cone at
radiusnumber l stringBottom diameter of the cone

Returns ID
Id of the sphere operation

Example

// Creates a sphere with radius = 20
const part = api.createPart('Part')
api.sphere(part, [], 20)
const geoms = await api.createBufferGeometry(part)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

transformInstances#

Transforms instances by the given transformation. The transformations are local to the instances parent, which is an assembly.

Declaration

(...instances: {
id: VID | ObjectIdent;
transformation: Transform;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
instances{ id: VID l ObjectIdent transformation: Transform }[]Array of instance objects. See following descriptions.

Returns Promise<void>

translate#

Creates a translate operation

Declaration

(partId: VID, operations: VID[], references: VID[], inverted: 0 | 1, distance: number | string) => ID

Params

NameTypeDefaultDescription
partIdVIDId ot the part where features will be translated
operationsVID[]Ids of the operations which are used for this translate operation, e.g. box, extrusion, chamfer operation
referencesVID[]References which define the direction of translation. E.g workaxis, 2 workpoints,..
inverted0 l 1Flag if direction is inverted or not
distancenumber l stringDistance of translation

Returns ID
Id of the translate operation

update3dConstraintValues#

Updates limited value specified (with 'paramName') of multiple constraints

Declaration

(...constrValues: {
constrId: VID;
paramName: LimitedValue;
value: number;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constrValues{ constrId: VID paramName: LimitedValue value: number }[]Array of constraint value objects. See following parameter description for that.

Returns Promise<void>

updateCylindricalConstraints#

Updates multiple cylindrical constraints.

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
zOffsetLimits: LimitsParam;
zRotationLimits: LimitsParam;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam zOffsetLimits: LimitsParam zRotationLimits: LimitsParam }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updateFastenedConstraints#

Updates multiple fastened constraints

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
xOffset: number | string;
yOffset: number | string;
zOffset: number | string;
xRotation?: number | string;
yRotation?: number | string;
zRotation?: number | string;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam xOffset: number l string yOffset: number l string zOffset: number l string xRotation?: number l string yRotation?: number l string zRotation?: number l string }[]Array of constraint parameter objects. See following parameter descriptions.

Returns Promise<void>

updateFastenedOriginConstraints#

Updates multiple fastened origin constraints

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
xOffset: number | string;
yOffset: number | string;
zOffset: number | string;
xRotation?: number | string;
yRotation?: number | string;
zRotation?: number | string;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam xOffset: number l string yOffset: number l string zOffset: number l string xRotation?: number l string yRotation?: number l string zRotation?: number l string }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updateParallelConstraints#

Updates multiple parallel constraints.

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
xOffsetLimits: LimitsParam;
yOffsetLimits: LimitsParam;
zOffsetLimits: LimitsParam;
zRotationLimits: LimitsParam;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam xOffsetLimits: LimitsParam yOffsetLimits: LimitsParam zOffsetLimits: LimitsParam zRotationLimits: LimitsParam }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updatePlanarConstraints#

Updates multiple planar constraints.

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
zOffset: number | string;
xOffsetLimits: LimitsParam;
yOffsetLimits: LimitsParam;
zRotationLimits: LimitsParam;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam zOffset: number l string xOffsetLimits: LimitsParam yOffsetLimits: LimitsParam zRotationLimits: LimitsParam }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updateRevoluteConstraints#

Updates multiple revolute constraints.

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
zOffset: number | string;
zRotationLimits: LimitsParam;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam zOffset: number l string zRotationLimits: LimitsParam }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updateSliderConstraints#

Updates multiple slider constraints.

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
xOffset: number | string;
yOffset: number | string;
zOffsetLimits: LimitsParam;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
constraints{ constrId: VID mate1: MateParam mate2: MateParam xOffset: number l string yOffset: number l string zOffsetLimits: LimitsParam }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

updateTranslate#

DEPRECATED use translate() instead, updateTranslate() will be removed in a future release.

Updates a already created translation. To update value will be distance of translation

Declaration

(translationId: VID, distance: number) => Promise<void>

Params

NameTypeDefaultDescription
translationIdVIDId of the translation (feature id) which will be updated
distancenumberNew value for distance

Returns Promise<void>

Transform#

Array type containing three points of type Point = {x: number, y: number, z: number}.

  • [0] = origin position containing x-, y- and z-coordinates
  • [1] = x-direction vector
  • [2] = y-direction vector

DimensionType#

ViewOptionsType#

Members

NameTypeDescription
colornumberoptional color (autocad color index) to set for the 2d view, if color = 256 then color will be taken from layer definition
layerstringoptional layer to set for the 2d view, layers are defined in the dxf file

FastenedOriginConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
xOffsetnumber l stringoffset in x-direction
yOffsetnumber l stringoffset in y-direction
zOffsetnumber l stringoffset in z-direction
xRotationnumber l stringrotation around x-axis
yRotationnumber l stringrotation around y-axis
zRotationnumber l stringrotation around z-axis

FastenedConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
xOffsetnumber l stringoffset in x-direction
yOffsetnumber l stringoffset in y-direction
zOffsetnumber l stringoffset in z-direction
xRotationnumber l stringrotation around x-axis
yRotationnumber l stringrotation around y-axis
zRotationnumber l stringrotation around z-axis

RevoluteConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
zOffsetnumber l stringoffset in z-direction
zRotationLimitsLimitsParammin and max limit for the rotation around z-Axis

SliderConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
xOffsetnumber l stringoffset in x-direction
yOffsetnumber l stringoffset in y-direction
zOffsetLimitsLimitsParammin and max limit for the z-offset

PlanarConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
zOffsetnumber l stringoffset in z-direction
xOffsetLimitsLimitsParammin and max limit for the x-offset
yOffsetLimitsLimitsParammin and max limit for the y-offset
zRotationLimitsLimitsParammin and max limit for the rotation around z-Axis

ParallelConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
xOffsetLimitsLimitsParammin and max limit for the x-offset
yOffsetLimitsLimitsParammin and max limit for the y-offset
zOffsetLimitsLimitsParammin and max limit for the z-offset
zRotationLimitsLimitsParammin and max limit for the rotation around z-Axis

CylindricalConstraintType#

Members

NameTypeDescription
constrIdVIDid of the constraint
mate1MateParamfirst mate constraint
mate2MateParamsecond mate constraint
zOffsetLimitsLimitsParammin and max limit for the z-offset
zRotationLimitsLimitsParammin and max limit for the rotation around z-Axis

ConstraintType#

Information about constraint. [ constraintId, [ path to product reference, workcoordsystem id of 1st mate, flip type of 1st mate, reoriented type of 1st mate ], [ path to product reference, workcoordsystem id of 2nd mate, flip type of 2nd mate, reoriented type of 2nd mate ], xOffset, yOffset, zOffset ]

Vec#

General, generic vector type representing following types:

Members

NameTypeDescription
xValue
yValue
zValue