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
})

addNodes#

Adds multiple products as nodes to an existing assembly at once

Declaration

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

Params

NameTypeDefaultDescription
nodes{ productId: VID ownerId: VID transformation: Transform name?: string }[]Array of node parameter objects. See following descriptions.

Returns Promise<ObjectID[] | null>

addDimensions#

Adds multiple dimensions to products in the 3D view

Declaration

(...dimensions: {
productId: VID;
dimParam: {
dimType: 'LinearDimension';
dimName?: string;
dimLabel: string;
dimValue?: number | null;
dimStartPos: PointMemValue;
dimEndPos: PointMemValue;
dimTextPos: PointMemValue;
dimTextAngle: number;
dimOrientation: OrientationType;
dimColor?: number;
dimLayer?: string;
};
dxfView: ViewType;
}[]) => Promise<ObjectID[] | null>

Params

NameTypeDefaultDescription
dimensions{ productId: VID dimParam: { dimType: 'LinearDimension' dimName?: string dimLabel: string dimValue?: number l null dimStartPos: PointMemValue dimEndPos: PointMemValue dimTextPos: PointMemValue dimTextAngle: number dimOrientation: OrientationType dimColor?: number dimLayer?: string } dxfView: ViewType }[]Dimensions to be added to products

Returns Promise<ObjectID[] | null>

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)

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

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'})

getBoundaryBoxFromViews#

This method returns the boundary box of the given views.

Declaration

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

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<[PointMemValue, PointMemValue][]>

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}], [...], [...]]

place2DViews#

Place the 2D views relatively to the origin.

Declaration

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

Params

NameTypeDefaultDescription
productIdVIDId of the product where the views will be placed in
viewPositions{ viewType: ViewType vector: PointMemValue }[]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 } },
])

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)

removeDimensions#

Remove existing dimensions from the view.

Declaration

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

Params

NameTypeDefaultDescription
dimensionIdsVID[]

Returns Promise<void>

Example

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

linearPattern#

Creates a linear pattern

Declaration

(partId: VID, entities: 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.
entitiesVID[]Included entities of linear 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

circularPattern#

Creates a circular pattern

Declaration

(partId: VID, entities: 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.
entitiesVID[]Included entities of circular 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

extrusion#

Creates an extrusion

Declaration

(partId: VID, sketchOrRegionIds: VID | VIDs, type: ExtrusionType, limit1: number | string, limit2: number | string, taperAngle: number | string, direction: PointMemValue, 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
directionPointMemValueDirection of extrusion
capEnds0 l 1If true, ends will be capped, else a sheet will be created

Returns ID

revolve#

Creates a revolve

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

boolean#

Creates a boolean operation.

Declaration

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

Params

NameTypeDefaultDescription
partIdVIDId of the part where the operation will be created on
typeBooleanOperationTypeType of boolean operation.
entitiesVID[]Included entities of boolean operation, first entity is base entity

Returns ID

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 simple box entity

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

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()))

cylinder#

Creates a simple cylinder entity

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

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()))

chamfer#

Creates a chamfer at the given edge references.

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

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()))

cone#

Creates a simple cone entity.

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

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()))

createFastenedConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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

Returns Promise<ObjectID | null>

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, 'Custom', [], offset1, rot, 0, false, 'wcs1')
const wcs3 = await api.createWorkCoordSystem(partTempl1, 'Custom', [], offset3, rot, 0, 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, 'Custom', [], offset2, rot, 0, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as nodes to the root assembly
const prt1 = await api.addNode(partTempl1, rootAsm, [orig, xDir, yDir])
const prt2 = await api.addNode(partTempl2, rootAsm, [orig, xDir, yDir])
// Creates a fastened constraint between the nodes
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()))

updateFastenedConstraints#

Updates multiple fastened constraints

Declaration

(...constraints: {
constrId: VID;
mate1: MateParam;
mate2: MateParam;
xOffset: number | string;
yOffset: number | string;
zOffset: 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 }[]Array of constraint parameter objects. See following descriptions.

Returns Promise<void>

createFastenedOriginConstraint#

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

Declaration

(asmId: VID, mate1: MateParam, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string) => Promise<ObjectID | null>

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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

Returns Promise<ObjectID | null>

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, 'Custom', [], offset1, rot, 0, false, 'wcs')
const wcs2 = await api.createWorkCoordSystem(partTempl, 'Custom', [], offset2, rot, 0, false, 'wcs')
api.box(partTempl, [wcs1], 30, 30, 30)
// Adds the created part template as a node to the root assembly
const prt = await api.addNode(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, 0, 0, 'FOC')
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial({ transparent: true, opacity: 0.5 })))

updateFastenedOriginConstraints#

Updates multiple fastened origin constraints

Declaration

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

Params

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

Returns Promise<void>

createCylindricalConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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>

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>

createRevoluteConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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>

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>

createSliderConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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>

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>

createPlanarConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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>

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>

createParallelConstraint#

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

Declaration

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

Params

NameTypeDefaultDescription
asmIdVIDId of the assembly 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>

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>

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 }[]

Returns Promise<void>

createBufferGeometry#

Creates the buffer geometry of the 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>

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()))

createScene#

Creates ThreeJS scene from current product

Declaration

(productId: VID, options?: {
meshPerGeometry?: boolean;
}) => Promise<{
scene: Scene;
nodes: Group[];
solids: Group[];
meshes: Mesh[];
}>

Params

NameTypeDefaultDescription
productIdVIDId of the product to create scene from
options.meshPerGeometry?boolean

Returns Promise<{ scene: Scene; nodes: Group[]; solids: Group[]; meshes: Mesh[] }>

createExpressions#

Creates one or more expressions.

Declaration

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

Params

NameTypeDefaultDescription
partIdVIDId of part where to create the expression
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>

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()))

createAssemblyAsTemplate#

Creates a new assembly template. This template can be used multiple times as a sub assembly in the root assembly.

Declaration

(name?: string) => ID

Params

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

Returns ID

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, 'Custom', [], offset1, rot, 0, 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, 'Custom', [], offset2, rot, 0, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as nodes to the assembly
// and the assembly itself multiple times to the root assembly
const prt1 = await api.addNode(partTempl1, asmTempl, [orig, xDir, yDir])
const prt2 = await api.addNode(partTempl2, asmTempl, [orig, xDir, yDir])
const asm1 = await api.addNode(asmTempl, rootAsm, [orig, xDir, yDir])
const asm2 = await api.addNode(asmTempl, rootAsm, [offset3, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createRootAssembly#

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

Declaration

(name?: string) => ID

Params

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

Returns ID

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, 'Custom', [], offset, rot, 0, false, 'wcs')
api.box(partTempl, [wcs], 30, 30, 10)
// Adds the created part template as a node to the root assembly
const partRef = await api.addNode(partTempl, rootAsm, [orig, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createPart#

Creates a new part.

Declaration

(name?: string) => ID

Params

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

Returns ID

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 can be used multiple times to build assemblies.

Declaration

(name?: string) => ID

Params

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

Returns ID

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, 'Custom', [], offset, rot, 0, false, 'wcs')
api.box(partTempl, [wcs], 30, 30, 10)
// Adds the created part template as a node to the root assembly
const partRef = await api.addNode(partTempl, rootAsm, [orig, xDir, yDir])
const geoms = await api.createBufferGeometry(rootAsm)
return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))

createWorkAxis#

Creates a new work axis for the given part

Declaration

(partId: VID, type: WorkAxisType, references: VID[], position: PointMemValue, direction: PointMemValue, 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'
positionPointMemValuePosition of axis, only needed if type = 'Custom'
directionPointMemValueDirection 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

createWorkCoordSystem#

Creates a new work coordinate system for the given part.

Declaration

(partId: VID, type: WorkCoordSystemType, references: VID[], coordinateSystem: PointMemValue[], offset: PointMemValue, rotation: PointMemValue, inverted: 0 | 1, local: 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)
coordinateSystemPointMemValue[]
offsetPointMemValueOffset from work coordinate system in x-, y- and z-direction
rotationPointMemValueRotation around x-, y- and z-axis from work coordinate system
inverted0 l 1Inverts the constraint between mate1 and mate2
localbooleanIf true, work coordinate system is set in local coordinates of part???
name?stringName of the work coordinate system, if not set default name = 'WorkCoordSystem'

Returns ID

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, 0, false, 'wcs1')
const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, 0, 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, 0, false, 'wcs2')
api.cone(partTempl2, [wcs2], 30, 0.1, 30)
// Adds the created part templates as nodes to the root assembly
const prt1 = await api.addNode(partTempl1, rootAsm, [orig, xDir, yDir])
const prt2 = await api.addNode(partTempl2, rootAsm, [orig, xDir, yDir])
// Creates a fastened constraint between the nodes
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: PointMemValue, normal: PointMemValue, 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'
positionPointMemValuePosition of plane, only needed if type = 'Custom'
normalPointMemValueNormal 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

createWorkPoint#

Creates a new work point for the given part

Declaration

(partId: VID, type: WorkPointType, references: VID[], position: PointMemValue, 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'
positionPointMemValuePosition 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

deleteExpressions#

Deletes an existing expression.

Declaration

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

Params

NameTypeDefaultDescription
partIdVIDId of part to delete expressions from
membersstring[]Name of members to delete

Returns Promise<boolean>

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()))

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

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

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>

sphere#

Creates a simple sphere entity.

Declaration

(partId: VID, references: VID[], radius: 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
radiusnumber l stringBottom diameter of the cone

Returns ID

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()))

fillet#

Creates a fillet at the given edge references.

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

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()))

findOrSelect#

Find geometry (vertices, edges, faces, loops) by given positions or selection. If positions parameter is null, user can select geometry in graphical interface. For all selected geometries this function logs its relevant points into console, to find the geometry later by points

Declaration

(partId: VID, type: BrepElemType, length: number, positions: PointMemValue[][] | null) => IDs

Params

NameTypeDefaultDescription
partIdVIDId of the part looking for geometry in or selecting them
typeBrepElemTypeType of geometry to find or select
lengthnumberNumber of selections to make before resolving the selection
positionsPointMemValue[][] l nullArray of point arrays where to look for geometry or null if the geometry wants to be selected

Returns IDs

getAssemblyFromContainer#

Returns the assembly 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

getAssemblyNode#

Returns the direct node with given name of given reference with specified name. If nodeName is empty, all nodes of given reference will be returned.

Declaration

(refId: VID, nodeName?: string) => IDs

Params

NameTypeDefaultDescription
refIdVIDReference of the assembly to look for the node
nodeName?stringName of the node to look for

Returns IDs

getCurrentProduct#

Returns the id of the current product

Declaration

() => ID

Returns ID

setCurrentNode#

Sets the node with refId to the new current node

Declaration

(refId: VID) => Promise<void>

Params

NameTypeDefaultDescription
refIdVIDReference id of the node 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>

getCurrentNode#

Returns the id of the current node

Declaration

() => ID

Returns ID

getCoordSysFromNode#

Returns the coordinate system of the node with the given refId. Where the node is an instance in the expanded tree of any product template

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDReference id of the node to get the coordinate system from

Returns Promise<number[][]>

getPartFromContainer#

Returns the part 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

getWorkCoordSystem#

Declaration

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

Params

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

Returns IDs

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.addNode(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()))

getSketchRegion#

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

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the sketch region
sketchRegionName?string

Returns IDs

getWorkGeometry#

Returns the work geometry of given type with given name. If the name of the work geometry is empty, all found work geometry of given type is returned

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference 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

getConstraint#

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>
[ 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 ]

getFastenedConstraint#

Returns the fastened constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference 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 reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

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

getRevoluteConstraint#

Returns the revolute constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<RevoluteConstraintType>
Found revolute constraint as object.

getSliderConstraint#

Returns the slider constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<SliderConstraintType>
Found slider constraint as object.

getPlanarConstraint#

Returns the planar constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<PlanarConstraintType>
Found planar constraint as object.

getParallelConstraint#

Returns the parallel constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<ParallelConstraintType>
Found parallel constraint as object.

getCylindricalConstraint#

Returns the cylindrical constraint of given reference with specified name.

Declaration

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

Params

NameTypeDefaultDescription
refIdVIDId of the reference to look for the constraint
constrNamestringName of the constraint to look for

Returns Promise<CylindricalConstraintType>
Found cylindrical constraint as object.

getFeatureByName#

Returns the id of the feature 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
featureNamestringName of the feature to look for

Returns ID

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>

saveToUrl#

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>

load#

Loads the given buffer.

Declaration

(content: ArrayBuffer, type: 'ofb' | 'stp') => Promise<number[] | null>

Params

NameTypeDefaultDescription
contentArrayBufferData as arraybuffer
type'ofb' l 'stp'Type of the data to load

Returns Promise<number[] | null>

loadFromUrl#

Loads from the given url.

Declaration

(url: string, filetype: 'ofb' | 'stp') => 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).

Returns Promise<number[] | null>

loadProduct#

Loads a product into the current drawing.

Declaration

(content: ArrayBuffer, type: 'ofb' | 'stp') => Promise<number[] | null>

Params

NameTypeDefaultDescription
contentArrayBufferData as arraybuffer
type'ofb' l 'stp'Type of the data to load

Returns Promise<number[] | null>

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.

Declaration

(url: string, filetype: 'ofb' | 'stp') => 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').

Returns Promise<number[] | null>

importFeature#

Creates a new feature 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

removeNodes#

Removes multiple nodes from an assembly node at once

Declaration

(...nodes: {
referenceId: VID;
ownerId: VID;
}[]) => Promise<void>

Params

NameTypeDefaultDescription
nodes{ referenceId: VID ownerId: VID }[]Array of node parameter objects. See following descriptions.

Returns Promise<void>

transformNode#

Transforms the node with referenceId with the given transformation within an assembly

Declaration

(referenceId: VID, ownerId: VID, transformation: Transform) => Promise<void>

Params

NameTypeDefaultDescription
referenceIdVIDId of the node to transform
ownerIdVIDId of the owner (parent) of node we want to transform
transformationTransformArray of three vectors [origin, xAxis, yAxis]

Returns Promise<void>

translate#

Translates a feature along a given axis.

Declaration

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

Params

NameTypeDefaultDescription
partIdVIDId ot the part where features will be translated
featureIdsVID[]Ids of the features which will be translated
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

updateTranslate#

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>

pick#

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

Declaration

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

Params

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

Returns IDs

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()))

setExpressions#

Updates multiple expressions in different parts at once

Declaration

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

Params

NameTypeDefaultDescription
expressions{ partId: number 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

mirror#

Mirrors the entities of a feature at the position of the plane reference

Declaration

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

Params

NameTypeDefaultDescription
partIdVIDId of the part where the mirror will be created
entitiesVID[]Id of the feature/operation we want to use entities from
referencesVID[]Id of the references which will be used to mirror (e.g. Workplane)

Returns Promise<ObjectID | null>

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 eacht 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>

Transform#

DimensionType#

productId#

dimParam#

dimParam.dimType#

dimParam.dimName#

dimParam.dimLabel#

dimParam.dimValue#

dimParam.dimStartPos#

dimParam.dimEndPos#

dimParam.dimTextPos#

dimParam.dimTextAngle#

dimParam.dimOrientation#

dimParam.dimColor#

dimParam.dimLayer#

dxfView#

ViewOptionsType#

Members

NameTypeDescription
colornumber
layerstring

FastenedOriginConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
xOffsetnumber l string
yOffsetnumber l string
zOffsetnumber l string

FastenedConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
xOffsetnumber l string
yOffsetnumber l string
zOffsetnumber l string

RevoluteConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
zOffsetnumber l string
zRotationLimitsLimitsParam

SliderConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
xOffsetnumber l string
yOffsetnumber l string
zOffsetLimitsLimitsParam

PlanarConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
zOffsetnumber l string
xOffsetLimitsLimitsParam
yOffsetLimitsLimitsParam
zRotationLimitsLimitsParam

ParallelConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
xOffsetLimitsLimitsParam
yOffsetLimitsLimitsParam
zOffsetLimitsLimitsParam
zRotationLimitsLimitsParam

CylindricalConstraintType#

Members

NameTypeDescription
constrIdVID
mate1MateParam
mate2MateParam
zOffsetLimitsLimitsParam
zRotationLimitsLimitsParam

ConstraintType#

Information about constraint. [ constraintId, [ path to product reference, workcoordsystem id of first mate, flip type of first mate, reoriented type of first mate ], [ path to product reference, workcoordsystem id of second mate, flip type of second mate, reoriented type of second mate ], xOffset, yOffset, zOffset ]