@buerli.io/headless 0.13.0 → 0.13.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1830 +1,1832 @@
1
- import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, ExtrusionType, WorkGeomType, SVGModusType, LimitsParam, DimensionParam, LimitedValue } from '@buerli.io/classcad';
2
- import { DrawingID, ObjectIdent, ObjectID, GraphicType, InteractionInfo, GeometryElement, DrawingState, BuerliState } from '@buerli.io/core';
3
- import { BufferGeometry, Material, Object3D, Scene } from 'three';
4
- /**
5
- * History based modeling is similar to solid modeling, but it is non-destructive and
6
- * parametric. You can move back and forth in the modeling history and create feature
7
- * expressions which you can alter at a later time, prompting your model to re-calculate.
8
- * Use this for assembly and variant configurators.
9
- *
10
- * > The history modeling approach relies heavily on the underlying `assemblyBuilder ClassCAD API`.
11
- * Since this part of the API is still under construction, the interfaces of the history functions
12
- * can still change.
13
- *
14
- * ```sh
15
- * npm install @buerli.io/headless
16
- * ```
17
- *
18
- * ```js
19
- * import { History } from '@buerli.io/headless'
20
- * const cad = new History(url)
21
- * cad.init(async api => {
22
- * // Your code goes here
23
- * })
24
- * ```
25
- */
26
- export declare type ApiHistory = {
27
- /**
28
- * Returns the drawing id of the current headless-session
29
- * @returns DrawingID
30
- * @example
31
- * const drawingId = api.getDrawingId()
32
- */
33
- getDrawingId: () => DrawingID;
34
- /**
35
- * Returns the drawing of the current headless-session
36
- * @returns DrawingState
37
- * @example
38
- * const drawing = api.getDrawing()
39
- * // Get all graphic containers
40
- * const containers = Object.values(drawing.graphic.containers)
41
- * containers.forEach(container => {
42
- * // Get all surfaces
43
- * const surfaces = container.meshes.map(mesh => mesh.properties.surface)
44
- * // Filter non cylindric
45
- * const cylinders = surfaces.filter(surface => surface.type === 'cylinder')
46
- * // Check if all cylinders have a radius greater than 4
47
- * cylinders.forEach(meta => expect(meta.radius).toBeGreaterThanOrEqual(4))
48
- * })
49
- */
50
- getDrawing: () => DrawingState;
51
- /**
52
- * Returns the state tree of the current headless-session
53
- * @returns BuerliState
54
- * @example
55
- * const state = api.getState()
56
- */
57
- getState: () => BuerliState;
58
- /**
59
- * Sets the global faceting parameters that will stick for this drawing.
60
- * This defines how detailed solids will be displayed and can yield smaller payloads.
61
- * @param distanceTol distance tolerance
62
- * @param angleTol angle tolerance
63
- * @returns void
64
- * @example
65
- * api.setFacetingParameters(0.1, 0)
66
- */
67
- setFacetingParameters: (distanceTol: number, angleTol: number) => Promise<void>;
68
- /**
69
- * Adds products as instances to root assembly, assembly instance or assembly template.
70
- * - If the owner is an instance in the expanded tree, its template in the assembly container will also be updated.
71
- * - If the onwer is an assembly template, all instances of the template will also be updated
72
- * @param instances array of objects containing the information of "to add" instances. See following parameter descriptions.
73
- * @param productId id, identifier or name of the product to instantiate
74
- * @param ownerId id, identifier or name of the owner of to adding instance, owner can be root assembly, assembly instance or assembly template.
75
- * @param transformation transformation (origin, x-Dir, y-Dir) of the instance
76
- * @param name optional name for the instance
77
- * @param options optional object containing ident property, to define a identifier for the adding instance
78
- * @return array containing the ids of added instances direct to owner
79
- * @example // tbd
80
- */
81
- addInstances: (...instances: {
82
- productId: VID | ObjectIdent;
83
- ownerId: VID | ObjectIdent;
84
- transformation: Transform;
85
- name?: string;
86
- options?: {
87
- ident?: ObjectIdent;
88
- };
89
- }[]) => Promise<ObjectID[] | null>;
90
- /**
91
- * Adds multiple dimensions to products in the 3D view
92
- * @param dimensions dimensions to be added to products
93
- * @example
94
- * // Get the current product
95
- * const productId = await api.getCurrentProduct()
96
- *
97
- * // Create dimensions
98
- * const dimension1: DimensionType = {
99
- * productId: productId,
100
- * dimParam: {
101
- * dimType: 'LinearDimension',
102
- * dimLabel: 'Breite = ',
103
- * dimStartPos: { x: 0, y: 0, z: 0 },
104
- * dimEndPos: { x: 100, y: 0, z: 0 },
105
- * dimTextPos: { x: 50, y: -10, z: 0 },
106
- * dimTextAngle: 0,
107
- * dimOrientation: 'Horizontal',
108
- * },
109
- * dxfView: 'Top',
110
- * }
111
- *
112
- * const dimension2: DimensionType = {
113
- * productId: productId,
114
- * dimParam: {
115
- * dimType: 'LinearDimension',
116
- * dimLabel: 'Laenge = ',
117
- * dimStartPos: { x: 0, y: 0, z: 0 },
118
- * dimEndPos: { x: 0, y: 100, z: 0 },
119
- * dimTextPos: { x: 10, y: 50, z: 0 },
120
- * dimTextAngle: 0,
121
- * dimOrientation: 'Horizontal',
122
- * },
123
- * dxfView: 'Top',
124
- * }
125
- *
126
- * // Add the dimensions
127
- * const dimensionIds = await api.addDimensions(dimension1, dimension2)
128
- * @return array containing the ids of added dimensions
129
- */
130
- addDimensions: (...dimensions: DimensionType[]) => Promise<ObjectID[] | null>;
131
- /**
132
- * Creates different 2D views, depending on the given view types, in the given product.
133
- * @param productId id of the product where the view will be created in
134
- * @param viewTypes array of view types. E.g. [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO, ...
135
- * @param viewOptions optional object of options (currently color and layer) to set for the views.
136
- * - color: number value 0 - 256, see AutoCAD Color Index (ACI). 256 = color defined by layer
137
- * - layer: string value, defines the view's layer
138
- * - Default = { color: 256, layer: '0'}
139
- * @example
140
- * // Optionally add dimensions to the product, see addDimension() or addDimensions()
141
- * await api.addDimensions(...)
142
- *
143
- * // Create the wanted views
144
- * await api.create2DViews(productId, [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO], { color: 2, layer: '6'})
145
- * @return array containing the ids of created views
146
- */
147
- create2DViews: (productId: VID, viewTypes: ViewType[], viewOptions?: ViewOptionsType) => IDs;
148
- /**
149
- * This method returns the boundary box of the given views.
150
- * @param productId id of the product from where the boundary box will returned
151
- * @param viewTypes array of view types. E.g. 'Top', 'Front', 'Iso', ...
152
- * @example
153
- * // After views have been created, see create2DViews(), you can get boundary boxes
154
- * const bbs = await api.getBoundaryBoxFromViews(productId, ['Top', 'Right_90°', 'Iso'])
155
- *
156
- * // Returns for each view a min and max point
157
- * console.info(bbs) // [[{x: -105, y: -89, z: 0}, {x: 105, y: 55, z: 0}], [...], [...]]
158
- * @return 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.
159
- */
160
- getBoundaryBoxFromViews: (productId: VID, viewTypes?: ViewType[]) => Promise<[Vec, Vec][]>;
161
- /**
162
- * Place the 2D views relatively to the origin.
163
- * @param productId id of the product where the views will be placed in
164
- * @param viewPositions array of objects, containing the viewType and a vector which defines the moving vector of the given view
165
- * @example
166
- * // After the views have been created, see create2DViews(), you can place them relatively to origin {0,0,0}
167
- * await api.place2DViews(productId, [
168
- * { viewType: 'Iso', vector: { x: 500, y: 500, z: 0 } },
169
- * { viewType: 'Right_90°', vector: { x: 500, y: 0, z: 0 } },
170
- * ])
171
- */
172
- place2DViews: (productId: VID, viewPositions: {
173
- viewType: ViewType;
174
- vector: Vec;
175
- }[]) => Promise<void>;
176
- /**
177
- * Export the placed views as dxf file.
178
- * @param productId id of the product where the views exist for export
179
- * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
180
- * @example
181
- * // After creating and placing the views, see place2DViews(), you can export them
182
- * // You will get the dxf stream back
183
- * await api.exportDXF(productId)
184
- */
185
- exportDXF: (productId: VID, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
186
- /**
187
- * Exports the placed views as dxf and converts it into svg stream.
188
- * @param productId id of the product where the views exist for export
189
- * @param modus optional modus to define how drawing will fit into svg file,
190
- * - SVGModusType.WHOLE_DRAWING or SVGModusType.FIT_WHOLE_DRAWING
191
- * - Default = SVGModusType.FIT_WHOLE_DRAWING
192
- * @param renderSize optional rendered size [x, y] of the drawing.
193
- * - x = horizontal size, y = vertical size
194
- * - Default = 1024 x 768
195
- * - Effects only if modus = SVGModusType.WHOLE_DRAWING
196
- * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
197
- * @example
198
- * // After creating and placing the views, see place2DViews(), you can export them
199
- * // You will get the svg stream back
200
- * await api.exportSVG(productId)
201
- */
202
- exportSVG: (productId: VID, modus?: SVGModusType, renderSize?: {
203
- x: number;
204
- y: number;
205
- }, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
206
- /**
207
- * Remove existing dimensions from the view.
208
- * @param dimensionIds ids of the dimensions to be removed
209
- * @example
210
- * // You can remove existing dimensions
211
- * await api.removeDimensions(dimensionIds)
212
- */
213
- removeDimensions: (dimensionIds: VID[]) => Promise<void>;
214
- /**
215
- * Creates a linear pattern operation
216
- * @param partId Id of the part to create the linear pattern in.
217
- * @param operations ids of the operations which are used for this linear pattern operation,
218
- * e.g. box, extrusion, chamfer operation
219
- * @param references1 references for the first axis of the pattern. E.g. edge / work axis or 2 vertices / work points
220
- * @param params1 parameter object which includes inverted flag, distance, count and merged flag
221
- * for the first direction of the pattern.
222
- * @param references2 optional references for the second axis of the pattern.
223
- * @param params2 optional parameter object for second direction of pattern.
224
- * @return id of the linear pattern operation
225
- */
226
- linearPattern: (partId: VID, operations: VID[], references1: VID[], params1: {
227
- inverted: 0 | 1;
228
- distance: number | string;
229
- count: number | string;
230
- merged: 0 | 1;
231
- }, references2?: VID[], params2?: {
232
- inverted: 0 | 1;
233
- distance: number | string;
234
- count: number | string;
235
- }) => ID;
236
- /**
237
- * Creates a circular pattern operation
238
- * @param partId Id of the part to create the circular pattern in.
239
- * @param operations ids of the operations which are used for this circular pattern operation,
240
- * e.g. box, extrusion, chamfer operation
241
- * @param references references for the rotation axis of the pattern. E.g. edge / work axis or 2 vertices / work points
242
- * @param params parameter object which includes inverted flag, angle, count and merged flag.
243
- * @return id of the circular pattern operation
244
- */
245
- circularPattern: (partId: VID, operations: VID[], references: VID[], params: {
246
- inverted: 0 | 1;
247
- angle: number | string;
248
- count: number | string;
249
- merged: 0 | 1;
250
- }) => ID;
251
- /**
252
- * Creates an extrusion operation
253
- * @param partId Id of the part to create the extrusion in.
254
- * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
255
- * @param type Type of extrusion (up, down, symmetric, custom)
256
- * @param limit1 Start of extrusion (0 = start at sketch, only for type custom necessary)
257
- * @param limit2 End of extrusion, which is actually the height
258
- * @param taperAngle Angle of taper for extrusion
259
- * @param direction Direction of extrusion
260
- * @param capEnds If true, ends will be capped, else a sheet will be created
261
- * @return id of the extrusion operation
262
- */
263
- extrusion: (partId: VID, sketchOrRegionIds: VID | VIDs, type: ExtrusionType, limit1: number | string, limit2: number | string, taperAngle: number | string, direction: Vec<number | string>, capEnds: 0 | 1) => ID;
264
- /**
265
- * Creates a revolve operation
266
- * @param partId Id of the part to create the revolve in.
267
- * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
268
- * @param axisIds Array of ids, either [lineId] or [point1Id, point2Id], ids can be both ccId or graphicId
269
- * @param angle1 Start of revolve in degrees
270
- * @param angle2 End of revolve in degrees
271
- * @param inverted flag, whether to invert the axis or not
272
- * @return id of the revolve operation
273
- */
274
- revolve: (partId: VID, sketchOrRegionIds: VID | VIDs, axisIds: VID[], angle1: number | string, angle2: number | string, inverted: 0 | 1) => ID;
275
- /**
276
- * Creates a boolean operation.
277
- * @param partId id of the part where the operation will be created on
278
- * @param type type of boolean operation.
279
- * @param operations ids of the operations for this boolean operation, e.g. Box, Chamfer.
280
- * At least two operations are needed. First operation in the array is the basic operation,
281
- * all following are the tool operations, which will be unified, subtract or intersect with/from the first operation.
282
- * @example
283
- * // Creates a box and subtracts a cylinder from it
284
- * const part = api.createPart('Part')
285
- * const cyl = api.cylinder(part, [], 10, 100)
286
- * const box = api.box(part, [], 20, 20, 20)
287
- * api.boolean(part, BooleanOperationType.Subtraction, [box, cyl])
288
- * const geoms = await api.createBufferGeometry(part)
289
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
290
- * @return id of the boolean operation
291
- */
292
- boolean: (partId: VID, type: BooleanOperationType, operations: VID[]) => ID;
293
- /**
294
- * Creates a box operation
295
- * @param partId id of the part where the box will be created
296
- * @param references reference of work coordinate system to place the box at
297
- * @param length length of the box (x-axis)
298
- * @param width width of the box (y-axis)
299
- * @param height height of the box (z-axis)
300
- * @example
301
- * // Creates a box with a length, width and height of 20
302
- * const part = api.createPart('Part')
303
- * const box = api.box(part, [], 20, 20, 20)
304
- * const geoms = await api.createBufferGeometry(part)
305
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
306
- * @return id of the box operation
307
- */
308
- box: (partId: VID, references: VID[], width: number | string, length: number | string, height: number | string) => ID;
309
- /**
310
- * Creates a cylinder operation
311
- * @param partId id of the part where the cylinder will be created
312
- * @param references reference of work coordinate system to place the cylinder at
313
- * @param diameter diameter of the cylinder (x/y-axis)
314
- * @param height height of the cylinder (z-axis)
315
- * @example
316
- * // Creates a cylinder with height = 50 and diameter = 20
317
- * const part = api.createPart('Part')
318
- * api.cylinder(part, [], 20, 50)
319
- * const geoms = await api.createBufferGeometry(part)
320
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
321
- * @return id of the cylinder operation
322
- */
323
- cylinder: (partId: VID, references: VID[], diameter: number | string, height: number | string) => ID;
324
- /**
325
- * Creates a chamfer operation
326
- * @param partId id of the part where the chamfers will be created
327
- * @param type type of chamfer operation.
328
- * @param references edge references where the chmamfers will be created on
329
- * @param dist1 1st distance of the chamfer from the edge
330
- * @param dist2 2nd distance of the chamfer from the edge. Optional if type = Equal_Distance or Distance_And_Angle
331
- * @param angle angle of the chamfer. Optional if type = Equal_Distance or Two_Distances
332
- * @example
333
- * // Creates a cylinder and puts a chamfer at the bottom edge
334
- * const part = api.createPart('Part')
335
- * api.cylinder(part, [], 10, 100)
336
- * const bottomEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 0 }])
337
- * api.chamfer(part, ChamferType.Equal_Distance, bottomEdges, 2, 0, 0)
338
- * const geoms = await api.createBufferGeometry(part)
339
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
340
- * @return id of the chamfer operation
341
- */
342
- chamfer: (partId: VID, type: ChamferType, references: VIDs, dist1: number | string, dist2: number | string, angle: number | string) => ID;
343
- /**
344
- * Creates a cone operation.
345
- * @param partId id of the part where the cone will be created
346
- * @param references reference of work coordinate system to place the cone at
347
- * @param bDiameter bottom diameter of the cone
348
- * @param tDiameter top diameter of the cone
349
- * @param height height of the cone
350
- * @example
351
- * // Creates a cone with bottom diameter = 20, top diameter = 0 and height = 20
352
- * const part = api.createPart('Part')
353
- * api.cone(part, [], 20, 0, 20)
354
- * const geoms = await api.createBufferGeometry(part)
355
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
356
- * @return id of the cone operation
357
- */
358
- cone: (partId: VID, references: VID[], bDiameter: number | string, tDiameter: number | string, height: number | string) => ID;
359
- /**
360
- * Creates a fastened constraint between mate1 and mate2 within an assembly.
361
- * @param id id of the root assembly or an assembly template to create constraints on
362
- * @param mate1 contains 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
363
- * @param mate2 contains 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
364
- * @param xOffset defines a offset in x-axis from mate1 to mate2
365
- * @param yOffset defines a offset in y-axis from mate1 to mate2
366
- * @param zOffset defines a offset in z-axis from mate1 to mate2
367
- * @param name name of the constraint
368
- * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
369
- * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
370
- * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
371
- * @example
372
- * // Defines some consts
373
- * const orig = { x: 0, y: 0, z: 0 }
374
- * const xDir = { x: 1, y: 0, z: 0 }
375
- * const yDir = { x: 0, y: 1, z: 0 }
376
- * const rot = { x: 0, y: 0, z: 0 }
377
- * const offset1 = { x: 0, y: 0, z: 0 }
378
- * const offset2 = { x: 0, y: 0, z: 0 }
379
- * const offset3 = { x: 15, y: 15, z: 30 }
380
- *
381
- * // Creates the root assembly first
382
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
383
- *
384
- * // Creates a part template and adds geometry to it
385
- * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
386
- * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
387
- * const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
388
- * api.box(partTempl1, [wcs1], 30, 30, 30)
389
- *
390
- * // Creates another part template and adds geometry to it
391
- * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
392
- * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
393
- * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
394
- *
395
- * // Adds the created part templates as instances to the root assembly
396
- * const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
397
- * const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
398
- *
399
- * // Creates a fastened constraint between the instances
400
- * await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 'FC', 0, 0, 0)
401
- * const geoms = await api.createBufferGeometry(rootAsm)
402
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
403
- * @return id of the fastened constraint
404
- */
405
- createFastenedConstraint: (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>;
406
- /**
407
- * Updates multiple fastened constraints
408
- * @param constraints array of constraint parameter objects. See following parameter descriptions.
409
- * @param mate1 contains 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
410
- * @param mate2 contains 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
411
- * @param xOffset defines a offset in x-axis from mate1 to mate2
412
- * @param yOffset defines a offset in y-axis from mate1 to mate2
413
- * @param zOffset defines a offset in z-axis from mate1 to mate2
414
- * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
415
- * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
416
- * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
417
- * @example // tbd
418
- */
419
- updateFastenedConstraints: (...constraints: {
420
- constrId: VID;
421
- mate1: MateParam;
422
- mate2: MateParam;
423
- xOffset: number | string;
424
- yOffset: number | string;
425
- zOffset: number | string;
426
- xRotation?: number | string;
427
- yRotation?: number | string;
428
- zRotation?: number | string;
429
- }[]) => Promise<void>;
430
- /**
431
- * Creates a fastened origin constraint for mate1 to the origin (0, 0, 0).
432
- * @param id id of the root assembly or an assembly template to create constraints on
433
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
434
- * @param xOffset defines a offset in x-axis from mate1 to mate2
435
- * @param yOffset defines a offset in y-axis from mate1 to mate2
436
- * @param zOffset defines a offset in z-axis from mate1 to mate2
437
- * @param name name of the constraint
438
- * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
439
- * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
440
- * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
441
- * @example
442
- * // Defines some consts
443
- * const orig = { x: 0, y: 0, z: 0 }
444
- * const xDir = { x: 1, y: 0, z: 0 }
445
- * const yDir = { x: 0, y: 1, z: 0 }
446
- * const rot = { x: 0, y: 0, z: 0 }
447
- * const offset1 = { x: 0, y: 0, z: 0 }
448
- * const offset2 = { x: 15, y: 15, z: 15 }
449
- *
450
- * // Creates the root assembly first
451
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
452
- *
453
- * // Creates a part template and adds geometry to it
454
- * const partTempl = await api.createPartAsTemplate('Part_Template')
455
- * const wcs1 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs')
456
- * const wcs2 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs')
457
- * api.box(partTempl, [wcs1], 30, 30, 30)
458
- *
459
- * // Adds the created part template as an instance to the root assembly
460
- * const prt = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
461
- *
462
- * // Creates a fastened origin constraint. The box of the part will be centered in origin
463
- * await api.createFastenedOriginConstraint(rootAsm, { matePath: [prt], wcsId: wcs2 }, 0, 0, 0, 'FOC', 0, 0, 0)
464
- *
465
- * const geoms = await api.createBufferGeometry(rootAsm)
466
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial({ transparent: true, opacity: 0.5 })))
467
- * @return id of the fastened origin constraint
468
- */
469
- createFastenedOriginConstraint: (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>;
470
- /**
471
- * Updates multiple fastened origin constraints
472
- * @param constraints array of constraint parameter objects. See following descriptions.
473
- * @param mate1 contains 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
474
- * @param xOffset defines a offset in x-axis from mate1 to mate2
475
- * @param yOffset defines a offset in y-axis from mate1 to mate2
476
- * @param zOffset defines a offset in z-axis from mate1 to mate2
477
- * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
478
- * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
479
- * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
480
- * @example // tbd
481
- */
482
- updateFastenedOriginConstraints: (...constraints: {
483
- constrId: VID;
484
- mate1: MateParam;
485
- xOffset: number | string;
486
- yOffset: number | string;
487
- zOffset: number | string;
488
- xRotation?: number | string;
489
- yRotation?: number | string;
490
- zRotation?: number | string;
491
- }[]) => Promise<void>;
492
- /**
493
- * Creates a cylindrical constraint between mate1 and mate2 within an assembly.
494
- * @param id id of the root assembly or an assembly template to create constraints on
495
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
496
- * @param mate2 contains 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
497
- * @param zOffsetLimits min and max value of offset along z
498
- * @param zRotationLimits min and max value of rotation around z
499
- * @param name name of the constraint
500
- * @example // tbd
501
- * @return id of the cylindrical constraint
502
- */
503
- createCylindricalConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
504
- /**
505
- * Updates multiple cylindrical constraints.
506
- * @param constraints array of constraint parameter objects. See following descriptions.
507
- * @param constrId id of the constraint to update
508
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
509
- * @param mate2 contains 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
510
- * @param zOffsetLimits min and max value of offset along z
511
- * @param zRotationLimits min and max value of rotation around z
512
- * @example // tbd
513
- */
514
- updateCylindricalConstraints: (...constraints: {
515
- constrId: VID;
516
- mate1: MateParam;
517
- mate2: MateParam;
518
- zOffsetLimits: LimitsParam;
519
- zRotationLimits: LimitsParam;
520
- }[]) => Promise<void>;
521
- /**
522
- * Creates a revolute constraint between mate1 and mate2 within an assembly.
523
- * @param id id of the root assembly or an assembly template to create constraints on
524
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
525
- * @param mate2 contains 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
526
- * @param zOffset defines a offset in z-axis from mate1 to mate2
527
- * @param zRotationLimits min and max value of rotation around z
528
- * @param name name of the constraint
529
- * @example // tbd
530
- * @return id of the revolute constraint
531
- */
532
- createRevoluteConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
533
- /**
534
- * Updates multiple revolute constraints.
535
- * @param constraints array of constraint parameter objects. See following descriptions.
536
- * @param constrId id of the constraint to update
537
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
538
- * @param mate2 contains 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
539
- * @param zOffset defines a offset in z-axis from mate1 to mate2
540
- * @param zRotationLimits min and max value of rotation around z
541
- * @example // tbd
542
- */
543
- updateRevoluteConstraints: (...constraints: {
544
- constrId: VID;
545
- mate1: MateParam;
546
- mate2: MateParam;
547
- zOffset: number | string;
548
- zRotationLimits: LimitsParam;
549
- }[]) => Promise<void>;
550
- /**
551
- * Creates a slider constraint between mate1 and mate2 within an assembly.
552
- * @param id id of the root assembly or an assembly template to create constraints on
553
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
554
- * @param mate2 contains 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
555
- * @param xOffset defines a offset in x-axis from mate1 to mate2
556
- * @param yOffset defines a offset in y-axis from mate1 to mate2
557
- * @param zOffsetLimits min and max value of offset along z
558
- * @param name name of the constraint
559
- * @example // tbd
560
- * @return id of the slider constraint
561
- */
562
- createSliderConstraint: (id: VID, mate1: MateParam, mate2: MateParam, xOffset: number | string, yOffset: number | string, zOffsetLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
563
- /**
564
- * Updates multiple slider constraints.
565
- * @param constraints array of constraint parameter objects. See following descriptions.
566
- * @param constrId id of the constraint to update
567
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
568
- * @param mate2 contains 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
569
- * @param xOffset defines a offset in x-axis from mate1 to mate2
570
- * @param yOffset defines a offset in y-axis from mate1 to mate2
571
- * @param zOffsetLimits min and max value of offset along z
572
- * @example // tbd
573
- */
574
- updateSliderConstraints: (...constraints: {
575
- constrId: VID;
576
- mate1: MateParam;
577
- mate2: MateParam;
578
- xOffset: number | string;
579
- yOffset: number | string;
580
- zOffsetLimits: LimitsParam;
581
- }[]) => Promise<void>;
582
- /**
583
- * Creates a planar constraint between mate1 and mate2 within an assembly.
584
- * @param id id of the root assembly or an assembly template to create constraints on
585
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
586
- * @param mate2 contains 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
587
- * @param zOffset defines a offset in z-axis from mate1 to mate2
588
- * @param xOffsetLimits min and max value of offset along x
589
- * @param yOffsetLimits min and max value of offset along y
590
- * @param zRotationLimits min and max value of rotation around z
591
- * @param name name of the constraint
592
- * @example // tbd
593
- * @return id of the planar constraint
594
- */
595
- createPlanarConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
596
- /**
597
- * Updates multiple planar constraints.
598
- * @param constraints array of constraint parameter objects. See following descriptions.
599
- * @param constrId id of the constraint to update
600
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
601
- * @param mate2 contains 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
602
- * @param zOffset defines a offset in z-axis from mate1 to mate2
603
- * @param xOffsetLimits min and max value of offset along x
604
- * @param yOffsetLimits min and max value of offset along y
605
- * @param zRotationLimits min and max value of rotation around z
606
- * @example // tbd
607
- */
608
- updatePlanarConstraints: (...constraints: {
609
- constrId: VID;
610
- mate1: MateParam;
611
- mate2: MateParam;
612
- zOffset: number | string;
613
- xOffsetLimits: LimitsParam;
614
- yOffsetLimits: LimitsParam;
615
- zRotationLimits: LimitsParam;
616
- }[]) => Promise<void>;
617
- /**
618
- * Creates a parallel constraint between mate1 and mate2 within an assembly.
619
- * @param id id of the root assembly or an assembly template to create constraints on
620
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
621
- * @param mate2 contains 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
622
- * @param xOffsetLimits min and max value of offset along x
623
- * @param yOffsetLimits min and max value of offset along y
624
- * @param zOffsetLimits min and max value of offset along z
625
- * @param zRotationLimits min and max value of rotation around z
626
- * @param name name of the constraint
627
- * @example // tbd
628
- * @return id of the parallel constraint
629
- */
630
- createParallelConstraint: (id: VID, mate1: MateParam, mate2: MateParam, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
631
- /**
632
- * Updates multiple parallel constraints.
633
- * @param constraints array of constraint parameter objects. See following descriptions.
634
- * @param constrId id of the constraint to update
635
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
636
- * @param mate2 contains 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
637
- * @param xOffsetLimits min and max value of offset along x
638
- * @param yOffsetLimits min and max value of offset along y
639
- * @param zOffsetLimits min and max value of offset along z
640
- * @param zRotationLimits min and max value of rotation around z
641
- * @example // tbd
642
- */
643
- updateParallelConstraints: (...constraints: {
644
- constrId: VID;
645
- mate1: MateParam;
646
- mate2: MateParam;
647
- xOffsetLimits: LimitsParam;
648
- yOffsetLimits: LimitsParam;
649
- zOffsetLimits: LimitsParam;
650
- zRotationLimits: LimitsParam;
651
- }[]) => Promise<void>;
652
- /**
653
- * Creates a group constraint between selected instances within an assembly.
654
- * @param id id of the root assembly or an assembly template to create constraints on
655
- * @param instanceIds ids of instances to be grouped
656
- * @param name name of the constraint
657
- * @example // tbd
658
- * @return id of the group constraint
659
- */
660
- createGroupConstraint: (id: VID, instanceIds: VID[], name: string) => Promise<ObjectID | null>;
661
- /**
662
- * Updates multiple group constraints.
663
- * @param constraints array of constraint parameter objects. See following descriptions.
664
- * @param constrId id of the constraint to update
665
- * @param instanceIds ids of instances to be grouped
666
- * @example // tbd
667
- */
668
- updateGroupConstraints: (...constraints: {
669
- constrId: VID;
670
- instanceIds: VID[];
671
- }[]) => Promise<void>;
672
- /**
673
- * Makes copies of a selected instance and creates a linear pattern constraint between them.
674
- * @param id id of the root assembly or an assembly template to create constraints on
675
- * @param instanceId id of the instance to be copied
676
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
677
- * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
678
- * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
679
- * @param name name of the constraint
680
- * @param mate2 [optional] contains 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; should belong to the selected instance
681
- * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
682
- * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
683
- * @example // tbd
684
- * @return id of the linear pattern constraint
685
- */
686
- createLinearPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, firstDirInstanceCount: number | string, firstDirDistance: number | string, name: string, mate2?: MateParam, secondDirInstanceCount?: number | string, secondDirDistance?: number | string) => Promise<ObjectID | null>;
687
- /**
688
- * Updates multiple linear pattern constraints.
689
- * @param constraints array of constraint parameter objects. See following descriptions.
690
- * @param constrId id of the constraint to update
691
- * @param instanceId id of the instance to be copied
692
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
693
- * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
694
- * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
695
- * @param mate2 [optional] contains 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; should belong to the selected instance
696
- * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
697
- * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
698
- * @example // tbd
699
- */
700
- updateLinearPatternConstraints: (...constraints: {
701
- constrId: VID;
702
- instanceId: VID;
703
- mate1: MateParam;
704
- firstDirInstanceCount: number | string;
705
- firstDirDistance: number | string;
706
- mate2?: MateParam;
707
- secondDirInstanceCount?: number | string;
708
- secondDirDistance?: number | string;
709
- }[]) => Promise<void>;
710
- /**
711
- * Makes copies of a selected instance and creates a circular pattern constraint between them.
712
- * @param id id of the root assembly or an assembly template to create constraints on
713
- * @param instanceId id of the instance to be copied
714
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
715
- * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
716
- * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
717
- * @param offset offset between copies (set by z-axis of mate2)
718
- * @param name name of the constraint
719
- * @example // tbd
720
- * @return id of the circular pattern constraint
721
- */
722
- createCircularPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, instanceCount: number | string, angle: number | string, offset: number | string, name: string) => Promise<ObjectID | null>;
723
- /**
724
- * Updates multiple circular pattern constraints.
725
- * @param constraints array of constraint parameter objects. See following descriptions.
726
- * @param constrId id of the constraint to update
727
- * @param instanceId id of the instance to be copied
728
- * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
729
- * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
730
- * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
731
- * @param offset offset between copies (set by z-axis of mate2)
732
- * @example // tbd
733
- */
734
- updateCircularPatternConstraints: (...constraints: {
735
- constrId: VID;
736
- instanceId: VID;
737
- mate1: MateParam;
738
- instanceCount: number | string;
739
- angle: number | string;
740
- offset: number | string;
741
- }[]) => Promise<void>;
742
- /**
743
- * Updates limited value specified (with 'paramName') of multiple constraints
744
- * @param constrValues array of constraint value objects. See following parameter description for that.
745
- * @param constrId id of the constraint to update the limited value
746
- * @param paramName name of the limited parameter
747
- * @param value new value to set
748
- */
749
- update3dConstraintValues: (...constrValues: {
750
- constrId: VID;
751
- paramName: LimitedValue;
752
- value: number;
753
- }[]) => Promise<void>;
754
- /**
755
- * Creates the buffer geometry of any product (part or assembly).
756
- * @param productId id of the product to create buffer geometry from
757
- * @example
758
- * // Creates a cone with bottom diameter = 20, top diameter = 0 and height = 30
759
- * const part = api.createPart('Part')
760
- * api.cone(part, [], 20, 0, 30)
761
- * const geoms = await api.createBufferGeometry(part)
762
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
763
- * @return array of buffer geometry
764
- */
765
- createBufferGeometry: (productId: VID) => Promise<BufferGeometry[] | undefined>;
766
- /**
767
- * Creates the threeJS scene of any product (part or assembly).
768
- * @param productId id of the product to create scene from
769
- * @param options optional object to define different settings.
770
- * @param meshPerGeometry boolean flag to define if a part/solid will have a mesh for each
771
- * geometry element or if the elements will be merged to one mesh
772
- * @return object containing all the created THREE objects like scene, nodes and materials
773
- * @example // tbd
774
- */
775
- createScene: (productId?: VID, options?: {
776
- meshPerGeometry?: boolean;
777
- structureOnly?: boolean;
778
- }) => Promise<{
779
- scene: Scene;
780
- nodes: {
781
- [key: string]: Object3D;
782
- };
783
- materials: {
784
- [key: string]: Material;
785
- };
786
- }>;
787
- /**
788
- * Creates one or more expressions.
789
- * @param partId id or identifier of the part to create the expressions in
790
- * @param members array of members which contain a name and a value. Value can be an expression, e.g. '2 * laenge'
791
- * @example
792
- * // Creates an expression and links it with the width of the box
793
- * const part = api.createPart('Part')
794
- * api.createExpressions(part, { name: 'width', value: 20 })
795
- * api.box(part, [], 'ExpressionSet.width', 20, 20)
796
- * const geoms = await api.createBufferGeometry(part)
797
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
798
- * @return true or false, depending on whether creating the expressions was successful or not
799
- */
800
- createExpressions: (partId: VID | ObjectIdent, ...members: {
801
- name: string;
802
- value: number | string;
803
- }[]) => Promise<boolean>;
804
- /**
805
- * Creates a new assembly template. This template will be added to the assembly container
806
- * and can be instantiated multiple times as a sub assembly in the root assembly or in other assembly template.
807
- * Assembly templates can only be created if the root is already an assembly.
808
- * @param name [optional] name of the assembly template. Default = 'Assembly'
809
- * @example
810
- * // Defines some consts
811
- * const orig = { x: 0, y: 0, z: 0 }
812
- * const xDir = { x: 1, y: 0, z: 0 }
813
- * const yDir = { x: 0, y: 1, z: 0 }
814
- * const rot = { x: 0, y: 0, z: 0 }
815
- * const offset1 = { x: 0, y: 0, z: 0 }
816
- * const offset2 = { x: 0, y: 0, z: 0 }
817
- * const offset3 = { x: 50, y: 0, z: 0 }
818
- *
819
- * // Creates the root assembly first
820
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
821
- *
822
- * // Creates a assembly template
823
- * const asmTempl = await api.createAssemblyAsTemplate('Assembly_Template')
824
- *
825
- * // Creates a part template and adds geometry to it
826
- * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
827
- * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
828
- * api.box(partTempl1, [wcs1], 30, 30, 30)
829
- *
830
- * // Creates another part template and adds geometry to it
831
- * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
832
- * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
833
- * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
834
- *
835
- * // Adds the created part templates as instances to the assembly
836
- * // and the assembly itself multiple times to the root assembly
837
- * const prt1 = await api.addInstances(partTempl1, asmTempl, [orig, xDir, yDir])
838
- * const prt2 = await api.addInstances(partTempl2, asmTempl, [orig, xDir, yDir])
839
- * const asm1 = await api.addInstances(asmTempl, rootAsm, [orig, xDir, yDir])
840
- * const asm2 = await api.addInstances(asmTempl, rootAsm, [offset3, xDir, yDir])
841
- *
842
- * const geoms = await api.createBufferGeometry(rootAsm)
843
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
844
- * @return id of the assembly template
845
- */
846
- createAssemblyAsTemplate: (name?: string) => ID;
847
- /**
848
- * Creates a new root assembly. This is the top level assembly.
849
- * @param name [optional] name of the root assembly. Default = 'AssemblyRoot'
850
- * @param options optional object containing ident property to define an identifier for the created root assembly
851
- * @example
852
- * // Defines some consts
853
- * const orig = { x: 0, y: 0, z: 0 }
854
- * const xDir = { x: 1, y: 0, z: 0 }
855
- * const yDir = { x: 0, y: 1, z: 0 }
856
- * const rot = { x: 0, y: 0, z: 0 }
857
- * const offset = { x: 20, y: 0, z: 0 }
858
- *
859
- * // Creates the root assembly first
860
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
861
- *
862
- * // Creates a part template and adds geometry to it
863
- * const partTempl = await api.createPartAsTemplate('Part_Template')
864
- * const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
865
- * api.box(partTempl, [wcs], 30, 30, 10)
866
- *
867
- * // Adds the created part template as an instance to the root assembly
868
- * const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
869
- * const geoms = await api.createBufferGeometry(rootAsm)
870
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
871
- * @return id of the root assembly
872
- */
873
- createRootAssembly: (name?: string, options?: {
874
- ident?: ObjectIdent;
875
- }) => ID;
876
- /**
877
- * Creates a new root part. This is the top level part.
878
- * @param name [optional] name of the part. Default = 'Part'
879
- * @example
880
- * // Creates a box and subtracts a cylinder from it
881
- * const part = api.createPart('Part')
882
- * api.cylinder(part, [], 10, 100)
883
- * const geoms = await api.createBufferGeometry(part)
884
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
885
- * @return id of the root part
886
- */
887
- createPart: (name?: string) => ID;
888
- /**
889
- * Creates a new part template. This template will be added to the part container
890
- * and can be instantiated multiple times in the root assembly or in assembly templates.
891
- * Part templates can only be created if the root is already an assembly.
892
- * @param name [optional] name of the part. Default = 'Part'
893
- * @example
894
- * // Defines some consts
895
- * const orig = { x: 0, y: 0, z: 0 }
896
- * const xDir = { x: 1, y: 0, z: 0 }
897
- * const yDir = { x: 0, y: 1, z: 0 }
898
- * const rot = { x: 0, y: 0, z: 0 }
899
- * const offset = { x: 20, y: 0, z: 0 }
900
- *
901
- * // Creates the root assembly first
902
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
903
- *
904
- * // Creates a part template and adds geometry to it
905
- * const partTempl = await api.createPartAsTemplate('Part_Template')
906
- * const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
907
- * api.box(partTempl, [wcs], 30, 30, 10)
908
- *
909
- * // Adds the created part template as an instance to the root assembly
910
- * const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
911
- * const geoms = await api.createBufferGeometry(rootAsm)
912
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
913
- * @return id of the part template
914
- */
915
- createPartAsTemplate: (name?: string) => ID;
916
- /**
917
- * Creates a new work axis for the given part
918
- * @param partId id of the part to add the new work axis to
919
- * @param type type of the work axis
920
- * @param references references for the work axis, needed for all types except 'Custom'
921
- * @param position position of axis, only needed if type = 'Custom'
922
- * @param direction direction of axis, only needed if type = 'Custom'
923
- * @param local if true, work axis is set in local coordinates of part???
924
- * @param name name of the work axis, if not set default name = 'WorkAxis'
925
- * @example //tbd
926
- * @return id of the work axis
927
- */
928
- createWorkAxis: (partId: VID, type: WorkAxisType, references: VID[], position: Vec<number | string>, direction: Vec<number | string>, local: boolean, name?: string) => ID;
929
- /**
930
- * Creates a new work coordinate system for the given part.
931
- * @param partId id of the part to add the new work coord system to
932
- * @param type type of the work coordinate system
933
- * @param references references for the work coordinate system (point and 2 axis). If empty array, the work coordinate system will set to origin (0, 0, 0)
934
- * @param offset offset from work coordinate system in x-, y- and z-direction
935
- * @param rotation rotation around x-, y- and z-axis from work coordinate system
936
- * @param inverted inverts the direction of the primary axis
937
- * @param name name of the work coordinate system, if not set default name = 'WorkCoordSystem'
938
- * @example
939
- * // Defines some consts
940
- * const orig = { x: 0, y: 0, z: 0 }
941
- * const xDir = { x: 1, y: 0, z: 0 }
942
- * const yDir = { x: 0, y: 1, z: 0 }
943
- * const rot = { x: 0, y: 0, z: 0 }
944
- * const offset1 = { x: 0, y: 0, z: 0 }
945
- * const offset2 = { x: 0, y: 0, z: 0 }
946
- * const offset3 = { x: 15, y: 15, z: 30 }
947
- *
948
- * // Creates the root assembly first
949
- * const rootAsm = await api.createRootAssembly('Root_Assembly')
950
- *
951
- * // Creates a part template and adds geometry to it
952
- * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
953
- * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
954
- * const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
955
- * api.box(partTempl1, [wcs1], 30, 30, 30)
956
- *
957
- * // Creates another part template and adds geometry to it
958
- * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
959
- * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
960
- * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
961
- *
962
- * // Adds the created part templates as instances to the root assembly
963
- * const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
964
- * const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
965
- *
966
- * // Creates a fastened constraint between the instances
967
- * await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 0, 0, 'FC')
968
- * const geoms = await api.createBufferGeometry(rootAsm)
969
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
970
- * @return id of the work coordinate system
971
- */
972
- createWorkCoordSystem: (partId: VID, type: WorkCoordSystemType, references: VID[], offset: Vec<number | string>, rotation: Vec<number | string>, inverted: boolean, name?: string) => ID;
973
- /**
974
- * Creates a new work plane for the given part
975
- * @param partId id of the part to add the new work plane to
976
- * @param type type of the work plane
977
- * @param references references for the work plane, needed for all types except 'Custom'
978
- * @param offset offset in normal direction, can be used for all types except 'LinePlaneAndAngle'
979
- * @param angle angle in degrees, needed for type 'LinePlaneAndAngle'
980
- * @param position position of plane, only needed if type = 'Custom'
981
- * @param normal normal vector of work plane, only needed if type = 'Custom'
982
- * @param local if true, work plane is set in local coordinates of part???
983
- * @param name name of the work plane, if not set default name = 'WorkAxis'
984
- * @example // tbd
985
- * @return id of the work plane
986
- */
987
- createWorkPlane: (partId: VID, type: WorkPlaneType, references: VID[], offset: number, angle: number, position: Vec<number | string>, normal: Vec<number | string>, local: boolean, name?: string) => ID;
988
- /**
989
- * Creates a new work point for the given part
990
- * @param partId id of the part to add the new work point to
991
- * @param type type of the work point
992
- * @param references references for the work point, needed for all types except 'Custom'
993
- * @param position position of point, only needed if type = 'Custom'
994
- * @param direction direction of point, only needed if type = 'Custom'
995
- * @param local if true, work point is set in local coordinates of part???
996
- * @param name name of the work point, if not set default name = 'WorkPoint'
997
- * @example // tbd
998
- * @return id of the work point
999
- */
1000
- createWorkPoint: (partId: VID, type: WorkPointType, references: VID[], position: Vec<number | string>, local: boolean, name?: string) => ID;
1001
- /**
1002
- * Deletes existing expressions.
1003
- * @param partId id or identifier of part to delete expressions from
1004
- * @param members name of members to delete
1005
- * @example
1006
- * // Deletes an expression from part's expression set
1007
- * const part = api.createPart('Part')
1008
- * api.createExpressions(part, { name: 'width', value: 20 }, { name: 'height', value: 40 })
1009
- * api.deleteExpressions(part, ['height'])
1010
- * await api.box(part, [], 'ExpressionSet.width', 20, 20)
1011
- * const geoms = await api.createBufferGeometry(part)
1012
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1013
- * @return true or false, depending on whether deleting the expressions was successful or not
1014
- */
1015
- deleteExpressions: (partId: VID | ObjectIdent, members: string[]) => Promise<boolean>;
1016
- /**
1017
- * Loads a sketch from a ofb filestream and adds its elements to a new sketch.
1018
- * The id of this new created sketch will be returned.
1019
- *
1020
- * @param partId id of the part we want to create the new sketch and copy the sketch elements into it
1021
- * @param strm stream of ofb file which contains the sketch
1022
- * @param planeId id of the face or workplane to set the new sketch on
1023
- * @param name optional name of the sketch to load from filestream
1024
- * @return id of the new sketch, containing the sketch elements from loaded sketch
1025
- */
1026
- loadSketch: (partId: VID, strm: ArrayBuffer, planeId: VID, name?: string) => ID;
1027
- /**
1028
- * Copy an existing sketch and adds its elements to a new sketch.
1029
- * The id of this new created sketch will be returned.
1030
- *
1031
- * @param partId id of the part we want to create the new sketch and copy the sketch elements into it
1032
- * @param sketchId id of the sketch to copy
1033
- * @param planeId id of the face or workplane to set the new sketch on
1034
- * @return id of the new sketch, containing the sketch elements form copied sketch
1035
- */
1036
- copySketch: (partId: VID, sketchId: VID, planeId: VID) => ID;
1037
- /**
1038
- * Place/position the sketch with plane, axis and origin references.
1039
- *
1040
- * @param sketchId id of the sketch to place
1041
- * @param planeId - id of a face or a workplane. This will be the plane where the sketch lies on.
1042
- * If a plane reference already exists, planeId is optional
1043
- * @param invertPlane - if true, the normal of the plane will be inverted
1044
- * @param axisId - optional id of an edge or workaxis. This will be the x-Axis
1045
- * @param isXAxis - if 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
1046
- * @param invertAxis - if true, the direction of the axis will be inverted
1047
- * @param originId - optional point or vertex of the sketch's origin reference
1048
- */
1049
- placeSketch: (sketchId: VID, planeId: VID, invertPlane: boolean, axisId: VID, isXAxis: boolean, invertAxis: boolean, originId: VID) => Promise<void>;
1050
- /**
1051
- * Creates a sphere operation
1052
- * @param partId id of the part where the sphere will be created
1053
- * @param references reference of work coordinate system to place the cone at
1054
- * @param radius bottom diameter of the cone
1055
- * @example
1056
- * // Creates a sphere with radius = 20
1057
- * const part = api.createPart('Part')
1058
- * api.sphere(part, [], 20)
1059
- * const geoms = await api.createBufferGeometry(part)
1060
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1061
- * @return id of the sphere operation
1062
- */
1063
- sphere: (partId: VID, references: VID[], radius: number | string) => ID;
1064
- /**
1065
- * Creates a fillet operation
1066
- * @param partId id of the part where the fillet will be created
1067
- * @param references edge references where the fillet will be created on
1068
- * @param radius radius of the fillet
1069
- * @example
1070
- * // Creates a cylinder and puts a fillet at the top edge
1071
- * const part = api.createPart('Part')
1072
- * api.cylinder(part, [], 10, 100)
1073
- * const topEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
1074
- * api.fillet(part, topEdges, 2)
1075
- * const geoms = await api.createBufferGeometry(part)
1076
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1077
- * @return id of the fillet operation
1078
- */
1079
- fillet: (partId: VID, references: VIDs, radius: number | string) => ID;
1080
- /**
1081
- * Important note: To use this method, you need to add the BuerliGeometry component to your application.
1082
- * Otherwise the selection of geometry won't work.
1083
- * [See this link to buerli geometry](https://buerli.io/docs/training-for-programmers/More/graphics#3-using-the-buerligeometry-react-component)
1084
- *
1085
- * Lets the user select geometry in graphical interface. As soon as the geometry of given type has been selected, the method
1086
- * will return necessary information about it.
1087
- * [See this link to selections](https://buerli.io/docs/training-for-programmers/history/HowTos/useSelectionInHeadless)
1088
- *
1089
- * The _userData_ of the returned object contains additional information about the selected geometry. All geometric
1090
- * information in the _userData_ is already transformed to the correct position. This is especially important for
1091
- * assemblies.
1092
- *
1093
- * @param types array of types to filter user selection.
1094
- * @param count optional number of selections to make (count must be >= 1). Default = 1.
1095
- * @return array of objects containing information about selected geometries
1096
- */
1097
- selectGeometry: <T = GeometryElement>(types: GrT[], count?: number) => Promise<InteractionInfo<T>[]>;
1098
- /**
1099
- * Find geometries of given type on solids in the given part at the given global positions.
1100
- * @param partId Id of the part where geometries tried to be found.
1101
- * @param type Type of the geometry to look for
1102
- * @param positions Array of elements containing one or more positions to look for the geometry
1103
- * @example
1104
- * // Find planes at two different positions
1105
- * const planes = await api.findGeometry(productId, GraphicType.PLANE, [[{x: 50, y: 50, z: 100}], [{x: 100, y: 50, z: 50}]])
1106
- * @return array containing ids of found geometries
1107
- */
1108
- findGeometry: (partId: VID, type: GrT, positions: Vec[][]) => IDs;
1109
- /**
1110
- * Returns the assembly template with given name from assembly container.
1111
- * If asmName is empty, all assemblies from assembly container will be returned.
1112
- * @param asmName Name of assembly to look for
1113
- * @example // tbd
1114
- * @return array containing ids of assembly templates
1115
- */
1116
- getAssemblyTemplate: (asmName?: string) => IDs;
1117
- /**
1118
- * Returns an instance or all instances of a node, depending on whether a name is given or not.
1119
- * The node is the parent of the instance/instances we're looking for and can be a root assembly,
1120
- * another instance or an assembly template.
1121
- * @param id id of the node from which we are searching the children for instances that have the name we are looking for.
1122
- * @param instanceName name of the instance we are looking for
1123
- * @example // tbd
1124
- * @return array containing the ids of the found instances
1125
- */
1126
- getInstance: (id: VID, instanceName?: string) => IDs;
1127
- /**
1128
- * Find first instance which can be identified by given identifier or name.
1129
- * If both optional parameters has been set, the identifier is treated with priority.
1130
- * If no instance with given identifier will be found, the name is used to find an instance.
1131
- *
1132
- * @param drawingId The drawing id.
1133
- * @param options Optional parameters to identify to find instance.
1134
- * @param options.instanceIdent Identifier to find the instance by an identifier
1135
- * @param options.instanceName Name to find the instance by its name
1136
- * @returns first found instance which meets the searching conditions or null if nothing could be found
1137
- */
1138
- findInstance: (options: {
1139
- instanceIdent?: ObjectIdent;
1140
- instanceName?: string;
1141
- }) => ID;
1142
- /**
1143
- * Returns the product ids of the given instance ids.
1144
- * @param instanceIds ids of the instances to get the product ids from
1145
- * @example // tbd
1146
- * @return array containing the product ids of the given instance ids
1147
- */
1148
- getProductsOfInstances: (instanceIds: VID[]) => IDs;
1149
- /**
1150
- * Returns the id of the current product
1151
- * @example // tbd
1152
- */
1153
- getCurrentProduct: () => ID;
1154
- /**
1155
- * Sets the instance with id to the new current instance
1156
- *
1157
- * @param id id of the instance to set as the current
1158
- * @example // tbd
1159
- */
1160
- setCurrentInstance: (id: VID) => Promise<void>;
1161
- /**
1162
- * Sets the product with productId to the new current product
1163
- *
1164
- * @param productId Id of the product to set as the current
1165
- * @example // tbd
1166
- */
1167
- setCurrentProduct: (productId: VID) => Promise<void>;
1168
- /**
1169
- * Returns the id of the current instance
1170
- * @example // tbd
1171
- * @return id of the current instance
1172
- */
1173
- getCurrentInstance: () => ID;
1174
- /**
1175
- * Returns the global transformation of the given id.
1176
- * Currently only ids of instances supported.
1177
- *
1178
- * @param id id of the object to get the global transformation from
1179
- * @example // tbd
1180
- * @return transformation of instance as two-dimensional array containing origin position and direction for x, y and z
1181
- * [
1182
- * [origin.x, origin.y, origin.z],
1183
- * [xVec.x, xVec.y, xVec.z],
1184
- * [yVec.x, yVec.y, yVec.z],
1185
- * [zVec.x, zVec.y, zVec.z]
1186
- * ]
1187
- */
1188
- getTransformation: (id: VID) => Promise<number[][]>;
1189
- /**
1190
- * Returns the part template with given name from part container.
1191
- * If partName is empty, all parts from part container will be returned.
1192
- * @param partName Name of part to look for
1193
- * @example // tbd
1194
- * @return array containing ids of part templates
1195
- */
1196
- getPartTemplate: (partName?: string) => IDs;
1197
- /**
1198
- * Returns the work coord system with the given wcsName from the given reference.
1199
- * If wcsName is not set, all work coord systems of the reference will be returned.
1200
- * @deprecated use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.
1201
- * @param refId id of the reference to look for the work coord system
1202
- * @param wcsName name of the work coord system to look for
1203
- * @example
1204
- * // Adds a loaded part to an assembly. To set the part to the origin of the
1205
- * // assembly with a constraint, the work coord system can be get from part by name.
1206
- * const pt0 = { x: 0, y: 0, z: 0 }
1207
- * const xDir = { x: 1, y: 0, z: 0 }
1208
- * const yDir = { x: 0, y: 1, z: 0 }
1209
- * const nutBoltAsm = await api.createRootAssembly('NutBolt_Asm')
1210
- * const bolt = await api.loadProduct(arraybuffer, 'ofb')
1211
- * const boltRefId = await api.addInstances(bolt, nutBoltAsm, [pt0, xDir, yDir])
1212
- * const wcsIdOrigin = await api.getWorkCoordSystem(boltRefId, 'WCS_Origin')
1213
- * await api.createFastenedOriginConstraint(nutBoltAsm, { refId: boltRefId, wcsId: wcsIdOrigin[0] }, 0, 0, 0, 0, 0, 'FOC')
1214
- * const geoms = await api.createBufferGeometry(nutBoltAsm)
1215
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1216
- * @return array containing ids of work coordinate systems
1217
- */
1218
- getWorkCoordSystem: (id: VID, wcsName?: string) => IDs;
1219
- /**
1220
- * Returns the sketch region with the given sketchRegionName from the given instance or part id.
1221
- * If sketchRegionName is not set, all sketch regions of the reference will be returned.
1222
- * @param id id of the instance or part to look for the sketch region
1223
- * @param sketchRegionName name of the sketch region to look for
1224
- * @example // tbd
1225
- * @return array containing ids of the sketch regions
1226
- */
1227
- getSketchRegion: (id: VID, sketchRegionName?: string) => IDs;
1228
- /**
1229
- * Returns the sketch with the given sketchName from the given instance or part id.
1230
- * If sketchName is not set, all sketches of the reference will be returned.
1231
- * @param id id of the instance or part to look for the sketch
1232
- * @param sketchName name of the sketch to look for
1233
- * @example // tbd
1234
- * @return array containing ids of the sketches
1235
- */
1236
- getSketch: (id: VID, sketchName?: string) => IDs;
1237
- /**
1238
- * Returns the work geometry of given type with given name from the given instance or part id.
1239
- * If the name of the work geometry is empty, all found work geometry of given type is returned
1240
- * @param id id of the instance or part to look for the work geometry
1241
- * @param type type of the work geometry to look for
1242
- * @param wgName optional name of the work geometry to look for
1243
- * @return array containing ids of the work geometry
1244
- */
1245
- getWorkGeometry: (id: VID, type: WorkGeomType, wgName?: string) => IDs;
1246
- /**
1247
- * Returns information about a constraint in the given reference
1248
- * @deprecated use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.
1249
- * @param refId id of the reference to look for the constraint
1250
- * @param constrName name of the constraint to look for
1251
- * @example // tbd
1252
- * @return array containing information about the constraint
1253
- * [
1254
- * constraintId,
1255
- * [ reference id of first mate, workcoordsystem id of first mate, flip type of first mate, reoriented type of first mate ],
1256
- * [ reference id of second mate, workcoordsystem id of second mate, flip type of second mate, reoriented type of second mate ],
1257
- * xOffset,
1258
- * yOffset,
1259
- * zOffset
1260
- * ]
1261
- */
1262
- getConstraint: (refId: VID, constrName?: string) => Promise<ConstraintType>;
1263
- /**
1264
- * Returns the fastened constraint of given instance or assembly id with specified name.
1265
- * @param id id of the instance or assembly to look for the constraint
1266
- * @param constrName name of the constraint to look for
1267
- * @example // tbd
1268
- * @return found fastened constraint as object.
1269
- */
1270
- getFastenedConstraint: (id: VID, constrName: string) => Promise<FastenedConstraintType>;
1271
- /**
1272
- * Returns the fastened origin constraint of given instance or assembly with specified name.
1273
- * @param id id of the instance or assembly to look for the constraint
1274
- * @param constrName name of the constraint to look for
1275
- * @example // tbd
1276
- * @return found fastened origin constraint as object.
1277
- */
1278
- getFastenedOriginConstraint: (id: VID, constrName: string) => Promise<FastenedOriginConstraintType>;
1279
- /**
1280
- * Returns the revolute constraint of given instance or assembly with specified name.
1281
- * @param id id of the instance or assembly to look for the constraint
1282
- * @param constrName name of the constraint to look for
1283
- * @example // tbd
1284
- * @return found revolute constraint as object.
1285
- */
1286
- getRevoluteConstraint: (id: VID, constrName: string) => Promise<RevoluteConstraintType>;
1287
- /**
1288
- * Returns the slider constraint of given instance or assembly with specified name.
1289
- * @param id id of the instance or assembly to look for the constraint
1290
- * @param constrName name of the constraint to look for
1291
- * @example // tbd
1292
- * @return found slider constraint as object.
1293
- */
1294
- getSliderConstraint: (id: VID, constrName: string) => Promise<SliderConstraintType>;
1295
- /**
1296
- * Returns the planar constraint of given instance or assembly with specified name.
1297
- * @param id id of the instance or assembly to look for the constraint
1298
- * @param constrName name of the constraint to look for
1299
- * @example // tbd
1300
- * @return found planar constraint as object.
1301
- */
1302
- getPlanarConstraint: (id: VID, constrName: string) => Promise<PlanarConstraintType>;
1303
- /**
1304
- * Returns the parallel constraint of given instance or assembly with specified name.
1305
- * @param id id of the instance or assembly to look for the constraint
1306
- * @param constrName name of the constraint to look for
1307
- * @example // tbd
1308
- * @return found parallel constraint as object.
1309
- */
1310
- getParallelConstraint: (id: VID, constrName: string) => Promise<ParallelConstraintType>;
1311
- /**
1312
- * Returns the cylindrical constraint of given instance or assembly with specified name.
1313
- * @param id id of the instance or assembly to look for the constraint
1314
- * @param constrName name of the constraint to look for
1315
- * @example // tbd
1316
- * @return found cylindrical constraint as object.
1317
- */
1318
- getCylindricalConstraint: (id: VID, constrName: string) => Promise<CylindricalConstraintType>;
1319
- /**
1320
- * Returns the group constraint of given instance or assembly with specified name.
1321
- * @param id id of the instance or assembly to look for the constraint
1322
- * @param constrName name of the constraint to look for
1323
- * @example // tbd
1324
- * @return found group constraint as object.
1325
- */
1326
- getGroupConstraint: (id: VID, constrName: string) => Promise<GroupConstraintType>;
1327
- /**
1328
- * Returns the linear pattern constraint of given instance or assembly with specified name.
1329
- * @param id id of the instance or assembly to look for the constraint
1330
- * @param constrName name of the constraint to look for
1331
- * @example // tbd
1332
- * @return found linear pattern constraint as object.
1333
- */
1334
- getLinearPatternConstraint: (id: VID, constrName: string) => Promise<LinearPatternConstraintType>;
1335
- /**
1336
- * Returns the circular pattern constraint of given instance or assembly with specified name.
1337
- * @param id id of the instance or assembly to look for the constraint
1338
- * @param constrName name of the constraint to look for
1339
- * @example // tbd
1340
- * @return found circular pattern constraint as object.
1341
- */
1342
- getCircularPatternConstraint: (id: VID, constrName: string) => Promise<CircularPatternConstraintType>;
1343
- /**
1344
- * Returns the id of the feature / operation with name = featureName. The feature can then
1345
- * be used for further operations, like boolean, transformations and so on.
1346
- * @param partId id of the part where to look for the feature / operation
1347
- * @param featureName name of the feature to look for
1348
- * @example // tbd
1349
- * @return id of the feature / operation
1350
- */
1351
- getFeatureByName: (partId: VID, featureName: string) => ID;
1352
- /**
1353
- * Returns an object containing the center of gravity and the volume of the given
1354
- * product, instance or solid. Depending on the input parameter the calculations were made
1355
- * on a single solid, a part, a subassembly, the whole model, ... E.g. the center of gravity of
1356
- * a root assembly, will be the sum of all solid's center of gravity over the whole assembly structure
1357
- *
1358
- * @param id id of the part, assembly, instance or solid we want the information from
1359
- * @example // tbd
1360
- * @return object containing the geometry information
1361
- */
1362
- getGeometryInformation: (id: VID) => Promise<ModelInfo | null>;
1363
- /**
1364
- * Writes the current drawing to a stream and returns the data.
1365
- *
1366
- * Important notes about the ofb format:
1367
- * - It contains binary geometry blocks.
1368
- * - Do not try to convert it to text, the geometry blocks will get damaged!
1369
- *
1370
- * @param type type to write
1371
- * @example // tbd
1372
- * @return stream data
1373
- */
1374
- save: (type: 'ofb' | 'stp') => Promise<Uint8Array | null>;
1375
- /**
1376
- * Writes the current drawing to a stream and POSTs the result to the given url.
1377
- * @param url The url to POST the model to.
1378
- * @param filetype The file type be saved (ofb, stp).
1379
- * @example // tbd
1380
- * @return true if saving was successful
1381
- */
1382
- saveToUrl: (url: string, filetype: 'ofb' | 'stp') => Promise<boolean>;
1383
- /**
1384
- * Loads the given buffer.
1385
- * @param content data as arraybuffer
1386
- * @param type type of the data to load
1387
- * @param options optional object containing ident property to define an identifier for the loaded root product
1388
- * @example // tbd
1389
- * @return array containing the id of the loaded product in the file
1390
- */
1391
- load: (content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
1392
- ident?: ObjectIdent;
1393
- }) => Promise<number[] | null>;
1394
- /**
1395
- * Loads from the given url.
1396
- * @param url The url to load data from.
1397
- * @param filetype The type of data delivered by the url (ofb, stp).
1398
- * @param options optional object containing ident property to define an identifier for the loaded root product
1399
- * @example // tbd
1400
- * @return array containing the id of the loaded product from url
1401
- */
1402
- loadFromUrl: (url: string, filetype: 'ofb' | 'stp', options?: {
1403
- ident?: ObjectIdent;
1404
- }) => Promise<number[] | null>;
1405
- /**
1406
- * Loads a product into the current drawing and adds it to the part- or assembly container.
1407
- * @param content data as arraybuffer
1408
- * @param type type of the data to load
1409
- * @param options optional object containing ident property to define an identifier for the loaded product
1410
- * @example
1411
- * // Loads an existing product
1412
- * const part = api.loadProduct(arraybuffer, 'ofb')
1413
- * const geoms = await api.createBufferGeometry(part)
1414
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1415
- * @return array containing the id of the loaded products
1416
- */
1417
- loadProduct: (content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
1418
- ident?: ObjectIdent;
1419
- }) => Promise<number[] | null>;
1420
- /**
1421
- * Loads a product from the given URL into the current drawing and adds it to the part- or assembly container.
1422
- * @param url The url to load data from.
1423
- * @param filetype The type of data delivered by the url ('ofb', 'stp').
1424
- * @param options optional object containing ident property, to define a identifier for the loaded product
1425
- * @example // tbd
1426
- * @return array containing the id of the loaded products
1427
- */
1428
- loadProductFromUrl: (url: string, filetype: 'ofb' | 'stp', options?: {
1429
- ident?: ObjectIdent;
1430
- }) => Promise<number[] | null>;
1431
- /**
1432
- * Creates a import feature operation and appends geometry to it. This method can be used to import specific geometry
1433
- * which can be used for further operations like boolean, translations and so on.
1434
- * @param partId id of the part where to add the new feature
1435
- * @param content data buffer to add to the import feature
1436
- * @param format the content format
1437
- * @param name optional name for the feature, default = 'Import'
1438
- * @example // tbd
1439
- * @return id of the import feature operation
1440
- */
1441
- importFeature: (partId: VID, content: ArrayBuffer, format: 'stp' | 'step', name?: string) => ID;
1442
- /**
1443
- * Removes instances from root assembly, other instances or assembly templates.
1444
- * @param instances array of instance objects. See following parameter descriptions.
1445
- * @param id id, identifier or name of the instance to remove
1446
- * @example // tbd
1447
- */
1448
- removeInstances: (...instances: {
1449
- id: VID | ObjectIdent;
1450
- }[]) => Promise<void>;
1451
- /**
1452
- * Transforms instances by the given transformation.
1453
- * The transformations are local to the instances parent, which is an assembly.
1454
- * @param instances array of instance objects. See following descriptions.
1455
- * @param id id, identifier or name of the instance to transform
1456
- * @param transformation transformation (origin, xDir, yDir) of the instance local to the owner.
1457
- * @example // tbd
1458
- */
1459
- transformInstances: (...instances: {
1460
- id: VID | ObjectIdent;
1461
- transformation: Transform;
1462
- }[]) => Promise<void>;
1463
- /**
1464
- * Creates a translate operation
1465
- * @param partId id ot the part where features will be translated
1466
- * @param operations ids of the operations which are used for this translate operation,
1467
- * e.g. box, extrusion, chamfer operation
1468
- * @param references references which define the direction of translation. E.g workaxis, 2 workpoints,..
1469
- * @param inverted flag if direction is inverted or not
1470
- * @param distance distance of translation
1471
- * @example // tbd
1472
- * @return id of the translate operation
1473
- */
1474
- translate: (partId: VID, operations: VID[], references: VID[], inverted: 0 | 1, distance: number | string) => ID;
1475
- /**
1476
- * Updates a already created translation. To update value will be distance of translation
1477
- * @deprecated use translate() instead, updateTranslate() will be removed in a future release.
1478
- * @param translationId id of the translation (feature id) which will be updated
1479
- * @param distance new value for distance
1480
- * @example // tbd
1481
- */
1482
- updateTranslate: (translationId: VID, distance: number) => Promise<void>;
1483
- /**
1484
- * Returns found vertices, edges or faces depending on
1485
- * given type and points. Given points define where to look for elements.
1486
- * @deprecated use findGeometry() instead, pick() will be removed in a future release.
1487
- * @param partId id of the part to pick elements
1488
- * @param type type of element to pick
1489
- * @param points points containing 3D coordinates to look for possible element
1490
- * @example
1491
- * // Creates a cylinder an puts a fillet on the top edge
1492
- * const part = api.createPart('Part')
1493
- * api.cylinder(part, [], 10, 100)
1494
- * const edges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
1495
- * api.fillet(part, edges, 2)
1496
- * const geoms = await api.createBufferGeometry(part)
1497
- * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1498
- * @return array containing ids of found geometries
1499
- */
1500
- pick: (partId: VID, type: 'vertex' | 'edge' | 'face', points: Vec[]) => IDs;
1501
- /**
1502
- * Updates multiple expressions in different parts at once
1503
- * @param expressions array of expression objects containing the part id and the expression to set
1504
- * @param partId id, identifier or name of part to update expression
1505
- * @param members array of members to update which contain a name and a value. Value can be an expression, e.g. '2 * laenge'
1506
- * @example // tbd
1507
- * @returns true, if updating expressions in all parts was successfull
1508
- */
1509
- setExpressions: (...expressions: {
1510
- partId: VID | ObjectIdent;
1511
- members: {
1512
- name: string;
1513
- value: number | string;
1514
- }[];
1515
- }[]) => Promise<boolean>;
1516
- /**
1517
- * Creates a mirror operation.
1518
- * Mirrors the entities of an operation at the position of the plane reference
1519
- * @param partId id of the part where the mirror will be created
1520
- * @param operations ids of the operations which are used for this mirror operation,
1521
- * e.g. box, extrusion, chamfer operation
1522
- * @param references id of the references which will be used to mirror (e.g. Workplane)
1523
- */
1524
- mirror: (partId: VID, operations: VID[], references: VID[]) => Promise<ObjectID | null>;
1525
- /**
1526
- * Removes the given operations or the operations which are added after 'toOperation' in history, depending
1527
- * on whether operations or toOperation parameter is given.
1528
- * @param operations ids of all to remove operations. First element in the array will be removed first.
1529
- * This means operations which depend on each other, need to be removed from newest to oldest.
1530
- * @param toOperation all operations, from rollback bar until the id of this operation, will be deleted
1531
- */
1532
- removeOperations: (operations: VID[], toOperation: VID) => Promise<void>;
1533
- /**
1534
- * Creates and returns the mate path as array from the given instance id up to the current instance.
1535
- * This helps to get the right path to set constraints between instances which are located in
1536
- * nested assemblies.
1537
- * @param instanceId id of the instance to get the mate path from
1538
- * @return array containing the ids as a path from given instance to current instance
1539
- */
1540
- getMatePath: (instanceId: VID | ObjectIdent) => Promise<ObjectID[]>;
1541
- /**
1542
- * Creates a slice operation.
1543
- * Slices the entities of the given operations by the given reference.
1544
- * @param partId id of the part where the slice will be created
1545
- * @param operations ids of the operations which are used for this slice operation,
1546
- * e.g. box, extrusion, chamfer operation
1547
- * @param reference id of the workplane reference to use for the slice
1548
- * @param sideFlag flag to toggle which side of the slice will be kept
1549
- * @return id of the slice operation
1550
- */
1551
- slice: (partId: VID, operations: VID[], reference: VID, sideFlag: boolean) => ID;
1552
- /**
1553
- * Creates a slice by sheet operation.
1554
- * Slices the entity of an operation with a sheet entity of another operation
1555
- * @param partId id of the part where the slice will be created
1556
- * @param operationToSlice id of the operation which will be sliced in this slice by sheet operation
1557
- * @param operationOfSheet id of the operation which is used as the slice
1558
- * @param sideFlag flag to toggle which side of the slice will be kept
1559
- * @return id of the slice by sheet operation
1560
- */
1561
- sliceBySheet: (partId: VID, operationToSlice: VID, operationOfSheet: VID, sideFlag: boolean) => ID;
1562
- /**
1563
- * Creates a twist operation
1564
- * @param partId Id of the part to create the twist in.
1565
- * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
1566
- * @param type Type of twist (up, down, symmetric, custom)
1567
- * @param limit1 Start of twist (0 = start at sketch, only for type custom necessary)
1568
- * @param limit2 End of twist, which is actually the height
1569
- * @param direction Direction of twist (only for type custom necessary)
1570
- * @param twistAngle Twist angle of the sketch along height of twist
1571
- * @param twistCenter Point which together with direction defines the twist axis (only for type custom necessary).
1572
- * The actual center/start of the twist is where the defined twist axis intersects the sketch plane. For other types than
1573
- * custom, the center will be the bary center of the selected region.
1574
- * @param capEnds If true, ends will be capped, else a sheet will be created
1575
- * @return id of the twist operation
1576
- */
1577
- twist: (param: {
1578
- partId: VID;
1579
- sketchOrRegionIds: VID | VIDs;
1580
- type: ExtrusionType;
1581
- limit1: number | string;
1582
- limit2: number | string;
1583
- direction?: Vec<number | string>;
1584
- twistAngle: number | string;
1585
- twistCenter?: Vec<number | string>;
1586
- capEnds: 0 | 1;
1587
- }) => ID;
1588
- };
1589
- export declare class History {
1590
- drawingId: DrawingID | null;
1591
- queue: Promise<number>;
1592
- constructor();
1593
- resolve(callback: (...results: any) => Promise<any>, ...args: any[]): Promise<any>;
1594
- init(callback: (api: ApiHistory) => void): () => Promise<void>;
1595
- destroy(): void;
1596
- }
1597
- export declare class history extends History {
1598
- constructor();
1599
- }
1600
- declare type VID = ObjectID | null | Promise<ObjectID | null>;
1601
- declare type VIDs = ObjectID[] | Promise<ObjectID[]>;
1602
- declare type ID = Promise<ObjectID | null>;
1603
- declare type IDs = Promise<ObjectID[]>;
1604
- declare type Point = {
1605
- x: number;
1606
- y: number;
1607
- z: number;
1608
- };
1609
- declare type ModelInfo = {
1610
- centerOfGravity: Vec;
1611
- volume: number;
1612
- };
1613
- declare type MateParam = {
1614
- matePath: VID[];
1615
- wcsId: VID;
1616
- flip: FlipType;
1617
- reoriented: ReorientedType;
1618
- };
1619
- declare type GrT = GraphicType.POINT | GraphicType.LINE | GraphicType.ARC | GraphicType.CIRCLE | GraphicType.PLANE | GraphicType.CYLINDER | GraphicType.CONE | GraphicType.SPHERE | GraphicType.NURBSCURVE | GraphicType.NURBSSURFACE;
1620
- /**
1621
- * Array type containing three points of type Point = {x: number, y: number, z: number}.
1622
- * - [0] = origin position containing x-, y- and z-coordinates
1623
- * - [1] = x-direction vector
1624
- * - [2] = y-direction vector
1625
- */
1626
- export declare type Transform = [Point, Point, Point];
1627
- export declare type DimensionType = DimensionParam<VID, Vec>;
1628
- export declare type ViewOptionsType = {
1629
- /** optional color (autocad color index) to set for the 2d view, if color = 256 then color will be taken from layer definition */
1630
- color?: number;
1631
- /** optional layer to set for the 2d view, layers are defined in the dxf file */
1632
- layer?: string;
1633
- };
1634
- export declare type FastenedOriginConstraintType = {
1635
- /** id of the constraint */
1636
- constrId: VID;
1637
- /** first mate constraint */
1638
- mate1: MateParam;
1639
- /** offset in x-direction */
1640
- xOffset: number | string;
1641
- /** offset in y-direction */
1642
- yOffset: number | string;
1643
- /** offset in z-direction */
1644
- zOffset: number | string;
1645
- /** rotation around x-axis */
1646
- xRotation?: number | string;
1647
- /** rotation around y-axis */
1648
- yRotation?: number | string;
1649
- /** rotation around z-axis */
1650
- zRotation?: number | string;
1651
- };
1652
- export declare type FastenedConstraintType = {
1653
- /** id of the constraint */
1654
- constrId: VID;
1655
- /** first mate constraint */
1656
- mate1: MateParam;
1657
- /** second mate constraint */
1658
- mate2: MateParam;
1659
- /** offset in x-direction */
1660
- xOffset: number | string;
1661
- /** offset in y-direction */
1662
- yOffset: number | string;
1663
- /** offset in z-direction */
1664
- zOffset: number | string;
1665
- /** rotation around x-axis */
1666
- xRotation?: number | string;
1667
- /** rotation around y-axis */
1668
- yRotation?: number | string;
1669
- /** rotation around z-axis */
1670
- zRotation?: number | string;
1671
- };
1672
- export declare type RevoluteConstraintType = {
1673
- /** id of the constraint */
1674
- constrId: VID;
1675
- /** first mate constraint */
1676
- mate1: MateParam;
1677
- /** second mate constraint */
1678
- mate2: MateParam;
1679
- /** offset in z-direction */
1680
- zOffset: number | string;
1681
- /** min and max limit for the rotation around z-Axis */
1682
- zRotationLimits: LimitsParam;
1683
- };
1684
- export declare type SliderConstraintType = {
1685
- /** id of the constraint */
1686
- constrId: VID;
1687
- /** first mate constraint */
1688
- mate1: MateParam;
1689
- /** second mate constraint */
1690
- mate2: MateParam;
1691
- /** offset in x-direction */
1692
- xOffset: number | string;
1693
- /** offset in y-direction */
1694
- yOffset: number | string;
1695
- /** min and max limit for the z-offset */
1696
- zOffsetLimits: LimitsParam;
1697
- };
1698
- export declare type PlanarConstraintType = {
1699
- /** id of the constraint */
1700
- constrId: VID;
1701
- /** first mate constraint */
1702
- mate1: MateParam;
1703
- /** second mate constraint */
1704
- mate2: MateParam;
1705
- /** offset in z-direction */
1706
- zOffset: number | string;
1707
- /** min and max limit for the x-offset */
1708
- xOffsetLimits: LimitsParam;
1709
- /** min and max limit for the y-offset */
1710
- yOffsetLimits: LimitsParam;
1711
- /** min and max limit for the rotation around z-Axis */
1712
- zRotationLimits: LimitsParam;
1713
- };
1714
- export declare type ParallelConstraintType = {
1715
- /** id of the constraint */
1716
- constrId: VID;
1717
- /** first mate constraint */
1718
- mate1: MateParam;
1719
- /** second mate constraint */
1720
- mate2: MateParam;
1721
- /** min and max limit for the x-offset */
1722
- xOffsetLimits: LimitsParam;
1723
- /** min and max limit for the y-offset */
1724
- yOffsetLimits: LimitsParam;
1725
- /** min and max limit for the z-offset */
1726
- zOffsetLimits: LimitsParam;
1727
- /** min and max limit for the rotation around z-Axis */
1728
- zRotationLimits: LimitsParam;
1729
- };
1730
- export declare type CylindricalConstraintType = {
1731
- /** id of the constraint */
1732
- constrId: VID;
1733
- /** first mate constraint */
1734
- mate1: MateParam;
1735
- /** second mate constraint */
1736
- mate2: MateParam;
1737
- /** min and max limit for the z-offset */
1738
- zOffsetLimits: LimitsParam;
1739
- /** min and max limit for the rotation around z-Axis */
1740
- zRotationLimits: LimitsParam;
1741
- };
1742
- export declare type GroupConstraintType = {
1743
- /** id of the constraint */
1744
- constrId: VID;
1745
- /** ids of instances to be grouped */
1746
- instanceIds: VID[];
1747
- };
1748
- export declare type LinearPatternConstraintType = {
1749
- /** id of the constraint */
1750
- constrId: VID;
1751
- /** id of the instance to be copied */
1752
- instanceId: VID;
1753
- /** first mate constraint (z-axis sets the first direction) */
1754
- mate1: MateParam;
1755
- /** number of copies over the first direction (set by z-axis of mate1) */
1756
- firstDirInstanceCount: number | string;
1757
- /** distance between copies over the first direction (set by z-axis of mate1) */
1758
- firstDirDistance: number | string;
1759
- /** second mate constraint (z-axis sets the second direction) */
1760
- mate2: MateParam;
1761
- /** number of copies over the second direction (set by z-axis of mate2) */
1762
- secondDirInstanceCount: number | string;
1763
- /** number of copies over the second direction (set by z-axis of mate2) */
1764
- secondDirDistance: number | string;
1765
- };
1766
- export declare type CircularPatternConstraintType = {
1767
- /** id of the constraint */
1768
- constrId: VID;
1769
- /** id of the instance to be copied */
1770
- instanceId: VID;
1771
- /** first mate constraint (z-axis sets the rotation axis) */
1772
- mate1: MateParam;
1773
- /** total number of copies (clockwise around the axis set by z-axis of mate1) */
1774
- instanceCount: number | string;
1775
- /** angle between copies (clockwise around the axis set by z-axis of mate1) */
1776
- angle: number | string;
1777
- /** offset between copies (set by z-axis of mate2) */
1778
- offset: number | string;
1779
- };
1780
- /**
1781
- * Information about constraint.
1782
- * [
1783
- * constraintId,
1784
- * [ path to product reference,
1785
- * workcoordsystem id of 1st mate,
1786
- * flip type of 1st mate,
1787
- * reoriented type of 1st mate ],
1788
- * [ path to product reference,
1789
- * workcoordsystem id of 2nd mate,
1790
- * flip type of 2nd mate,
1791
- * reoriented type of 2nd mate ],
1792
- * xOffset,
1793
- * yOffset,
1794
- * zOffset
1795
- * ]
1796
- */
1797
- export declare type ConstraintType = [
1798
- number,
1799
- [
1800
- number[],
1801
- number,
1802
- number,
1803
- number
1804
- ],
1805
- [
1806
- number[],
1807
- number,
1808
- number,
1809
- number
1810
- ],
1811
- number,
1812
- number,
1813
- number,
1814
- number,
1815
- number,
1816
- number
1817
- ];
1818
- /**
1819
- * General, generic vector type representing following types:
1820
- * - Value[]
1821
- * - {x: Value, y: Value, z: Value}
1822
- * - THREE.Vector [See threejs documentation](https://threejs.org/docs/?q=Vect#api/en/math/Vector3)
1823
- * - THREE.Euler [See threejs documentation](https://threejs.org/docs/?q=Euler#api/en/math/Euler)
1824
- */
1825
- export declare type Vec<Value = number> = Value[] | {
1826
- x: Value;
1827
- y: Value;
1828
- z: Value;
1829
- } | THREE.Vector3 | THREE.Euler;
1830
- export {};
1
+ import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, ExtrusionType, WorkGeomType, SVGModusType, LimitsParam, DimensionParam, LimitedValue } from '@buerli.io/classcad';
2
+ import { DrawingID, ObjectIdent, ObjectID, GraphicType, InteractionInfo, GeometryElement, DrawingState, BuerliState } from '@buerli.io/core';
3
+ import { BufferGeometry, Material, Object3D, Scene } from 'three';
4
+ /**
5
+ * History based modeling is similar to solid modeling, but it is non-destructive and
6
+ * parametric. You can move back and forth in the modeling history and create feature
7
+ * expressions which you can alter at a later time, prompting your model to re-calculate.
8
+ * Use this for assembly and variant configurators.
9
+ *
10
+ * > The history modeling approach relies heavily on the underlying `assemblyBuilder ClassCAD API`.
11
+ * Since this part of the API is still under construction, the interfaces of the history functions
12
+ * can still change.
13
+ *
14
+ * ```sh
15
+ * npm install @buerli.io/headless
16
+ * ```
17
+ *
18
+ * ```js
19
+ * import { init, History } from '@buerli.io/headless'
20
+ *
21
+ * init('ws://localhost:9091')
22
+ * const cad = new History()
23
+ * cad.init(async api => {
24
+ * // Your code goes here
25
+ * })
26
+ * ```
27
+ */
28
+ export declare type ApiHistory = {
29
+ /**
30
+ * Returns the drawing id of the current headless-session
31
+ * @returns DrawingID
32
+ * @example
33
+ * const drawingId = api.getDrawingId()
34
+ */
35
+ getDrawingId: () => DrawingID;
36
+ /**
37
+ * Returns the drawing of the current headless-session
38
+ * @returns DrawingState
39
+ * @example
40
+ * const drawing = api.getDrawing()
41
+ * // Get all graphic containers
42
+ * const containers = Object.values(drawing.graphic.containers)
43
+ * containers.forEach(container => {
44
+ * // Get all surfaces
45
+ * const surfaces = container.meshes.map(mesh => mesh.properties.surface)
46
+ * // Filter non cylindric
47
+ * const cylinders = surfaces.filter(surface => surface.type === 'cylinder')
48
+ * // Check if all cylinders have a radius greater than 4
49
+ * cylinders.forEach(meta => expect(meta.radius).toBeGreaterThanOrEqual(4))
50
+ * })
51
+ */
52
+ getDrawing: () => DrawingState;
53
+ /**
54
+ * Returns the state tree of the current headless-session
55
+ * @returns BuerliState
56
+ * @example
57
+ * const state = api.getState()
58
+ */
59
+ getState: () => BuerliState;
60
+ /**
61
+ * Sets the global faceting parameters that will stick for this drawing.
62
+ * This defines how detailed solids will be displayed and can yield smaller payloads.
63
+ * @param distanceTol distance tolerance
64
+ * @param angleTol angle tolerance
65
+ * @returns void
66
+ * @example
67
+ * api.setFacetingParameters(0.1, 0)
68
+ */
69
+ setFacetingParameters: (distanceTol: number, angleTol: number) => Promise<void>;
70
+ /**
71
+ * Adds products as instances to root assembly, assembly instance or assembly template.
72
+ * - If the owner is an instance in the expanded tree, its template in the assembly container will also be updated.
73
+ * - If the onwer is an assembly template, all instances of the template will also be updated
74
+ * @param instances array of objects containing the information of "to add" instances. See following parameter descriptions.
75
+ * @param productId id, identifier or name of the product to instantiate
76
+ * @param ownerId id, identifier or name of the owner of to adding instance, owner can be root assembly, assembly instance or assembly template.
77
+ * @param transformation transformation (origin, x-Dir, y-Dir) of the instance
78
+ * @param name optional name for the instance
79
+ * @param options optional object containing ident property, to define a identifier for the adding instance
80
+ * @return array containing the ids of added instances direct to owner
81
+ * @example // tbd
82
+ */
83
+ addInstances: (...instances: {
84
+ productId: VID | ObjectIdent;
85
+ ownerId: VID | ObjectIdent;
86
+ transformation: Transform;
87
+ name?: string;
88
+ options?: {
89
+ ident?: ObjectIdent;
90
+ };
91
+ }[]) => Promise<ObjectID[] | null>;
92
+ /**
93
+ * Adds multiple dimensions to products in the 3D view
94
+ * @param dimensions dimensions to be added to products
95
+ * @example
96
+ * // Get the current product
97
+ * const productId = await api.getCurrentProduct()
98
+ *
99
+ * // Create dimensions
100
+ * const dimension1: DimensionType = {
101
+ * productId: productId,
102
+ * dimParam: {
103
+ * dimType: 'LinearDimension',
104
+ * dimLabel: 'Breite = ',
105
+ * dimStartPos: { x: 0, y: 0, z: 0 },
106
+ * dimEndPos: { x: 100, y: 0, z: 0 },
107
+ * dimTextPos: { x: 50, y: -10, z: 0 },
108
+ * dimTextAngle: 0,
109
+ * dimOrientation: 'Horizontal',
110
+ * },
111
+ * dxfView: 'Top',
112
+ * }
113
+ *
114
+ * const dimension2: DimensionType = {
115
+ * productId: productId,
116
+ * dimParam: {
117
+ * dimType: 'LinearDimension',
118
+ * dimLabel: 'Laenge = ',
119
+ * dimStartPos: { x: 0, y: 0, z: 0 },
120
+ * dimEndPos: { x: 0, y: 100, z: 0 },
121
+ * dimTextPos: { x: 10, y: 50, z: 0 },
122
+ * dimTextAngle: 0,
123
+ * dimOrientation: 'Horizontal',
124
+ * },
125
+ * dxfView: 'Top',
126
+ * }
127
+ *
128
+ * // Add the dimensions
129
+ * const dimensionIds = await api.addDimensions(dimension1, dimension2)
130
+ * @return array containing the ids of added dimensions
131
+ */
132
+ addDimensions: (...dimensions: DimensionType[]) => Promise<ObjectID[] | null>;
133
+ /**
134
+ * Creates different 2D views, depending on the given view types, in the given product.
135
+ * @param productId id of the product where the view will be created in
136
+ * @param viewTypes array of view types. E.g. [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO, ...
137
+ * @param viewOptions optional object of options (currently color and layer) to set for the views.
138
+ * - color: number value 0 - 256, see AutoCAD Color Index (ACI). 256 = color defined by layer
139
+ * - layer: string value, defines the view's layer
140
+ * - Default = { color: 256, layer: '0'}
141
+ * @example
142
+ * // Optionally add dimensions to the product, see addDimension() or addDimensions()
143
+ * await api.addDimensions(...)
144
+ *
145
+ * // Create the wanted views
146
+ * await api.create2DViews(productId, [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO], { color: 2, layer: '6'})
147
+ * @return array containing the ids of created views
148
+ */
149
+ create2DViews: (productId: VID, viewTypes: ViewType[], viewOptions?: ViewOptionsType) => IDs;
150
+ /**
151
+ * This method returns the boundary box of the given views.
152
+ * @param productId id of the product from where the boundary box will returned
153
+ * @param viewTypes array of view types. E.g. 'Top', 'Front', 'Iso', ...
154
+ * @example
155
+ * // After views have been created, see create2DViews(), you can get boundary boxes
156
+ * const bbs = await api.getBoundaryBoxFromViews(productId, ['Top', 'Right_90°', 'Iso'])
157
+ *
158
+ * // Returns for each view a min and max point
159
+ * console.info(bbs) // [[{x: -105, y: -89, z: 0}, {x: 105, y: 55, z: 0}], [...], [...]]
160
+ * @return 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.
161
+ */
162
+ getBoundaryBoxFromViews: (productId: VID, viewTypes?: ViewType[]) => Promise<[Vec, Vec][]>;
163
+ /**
164
+ * Place the 2D views relatively to the origin.
165
+ * @param productId id of the product where the views will be placed in
166
+ * @param viewPositions array of objects, containing the viewType and a vector which defines the moving vector of the given view
167
+ * @example
168
+ * // After the views have been created, see create2DViews(), you can place them relatively to origin {0,0,0}
169
+ * await api.place2DViews(productId, [
170
+ * { viewType: 'Iso', vector: { x: 500, y: 500, z: 0 } },
171
+ * { viewType: 'Right_90°', vector: { x: 500, y: 0, z: 0 } },
172
+ * ])
173
+ */
174
+ place2DViews: (productId: VID, viewPositions: {
175
+ viewType: ViewType;
176
+ vector: Vec;
177
+ }[]) => Promise<void>;
178
+ /**
179
+ * Export the placed views as dxf file.
180
+ * @param productId id of the product where the views exist for export
181
+ * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
182
+ * @example
183
+ * // After creating and placing the views, see place2DViews(), you can export them
184
+ * // You will get the dxf stream back
185
+ * await api.exportDXF(productId)
186
+ */
187
+ exportDXF: (productId: VID, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
188
+ /**
189
+ * Exports the placed views as dxf and converts it into svg stream.
190
+ * @param productId id of the product where the views exist for export
191
+ * @param modus optional modus to define how drawing will fit into svg file,
192
+ * - SVGModusType.WHOLE_DRAWING or SVGModusType.FIT_WHOLE_DRAWING
193
+ * - Default = SVGModusType.FIT_WHOLE_DRAWING
194
+ * @param renderSize optional rendered size [x, y] of the drawing.
195
+ * - x = horizontal size, y = vertical size
196
+ * - Default = 1024 x 768
197
+ * - Effects only if modus = SVGModusType.WHOLE_DRAWING
198
+ * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
199
+ * @example
200
+ * // After creating and placing the views, see place2DViews(), you can export them
201
+ * // You will get the svg stream back
202
+ * await api.exportSVG(productId)
203
+ */
204
+ exportSVG: (productId: VID, modus?: SVGModusType, renderSize?: {
205
+ x: number;
206
+ y: number;
207
+ }, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
208
+ /**
209
+ * Remove existing dimensions from the view.
210
+ * @param dimensionIds ids of the dimensions to be removed
211
+ * @example
212
+ * // You can remove existing dimensions
213
+ * await api.removeDimensions(dimensionIds)
214
+ */
215
+ removeDimensions: (dimensionIds: VID[]) => Promise<void>;
216
+ /**
217
+ * Creates a linear pattern operation
218
+ * @param partId Id of the part to create the linear pattern in.
219
+ * @param operations ids of the operations which are used for this linear pattern operation,
220
+ * e.g. box, extrusion, chamfer operation
221
+ * @param references1 references for the first axis of the pattern. E.g. edge / work axis or 2 vertices / work points
222
+ * @param params1 parameter object which includes inverted flag, distance, count and merged flag
223
+ * for the first direction of the pattern.
224
+ * @param references2 optional references for the second axis of the pattern.
225
+ * @param params2 optional parameter object for second direction of pattern.
226
+ * @return id of the linear pattern operation
227
+ */
228
+ linearPattern: (partId: VID, operations: VID[], references1: VID[], params1: {
229
+ inverted: 0 | 1;
230
+ distance: number | string;
231
+ count: number | string;
232
+ merged: 0 | 1;
233
+ }, references2?: VID[], params2?: {
234
+ inverted: 0 | 1;
235
+ distance: number | string;
236
+ count: number | string;
237
+ }) => ID;
238
+ /**
239
+ * Creates a circular pattern operation
240
+ * @param partId Id of the part to create the circular pattern in.
241
+ * @param operations ids of the operations which are used for this circular pattern operation,
242
+ * e.g. box, extrusion, chamfer operation
243
+ * @param references references for the rotation axis of the pattern. E.g. edge / work axis or 2 vertices / work points
244
+ * @param params parameter object which includes inverted flag, angle, count and merged flag.
245
+ * @return id of the circular pattern operation
246
+ */
247
+ circularPattern: (partId: VID, operations: VID[], references: VID[], params: {
248
+ inverted: 0 | 1;
249
+ angle: number | string;
250
+ count: number | string;
251
+ merged: 0 | 1;
252
+ }) => ID;
253
+ /**
254
+ * Creates an extrusion operation
255
+ * @param partId Id of the part to create the extrusion in.
256
+ * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
257
+ * @param type Type of extrusion (up, down, symmetric, custom)
258
+ * @param limit1 Start of extrusion (0 = start at sketch, only for type custom necessary)
259
+ * @param limit2 End of extrusion, which is actually the height
260
+ * @param taperAngle Angle of taper for extrusion
261
+ * @param direction Direction of extrusion
262
+ * @param capEnds If true, ends will be capped, else a sheet will be created
263
+ * @return id of the extrusion operation
264
+ */
265
+ extrusion: (partId: VID, sketchOrRegionIds: VID | VIDs, type: ExtrusionType, limit1: number | string, limit2: number | string, taperAngle: number | string, direction: Vec<number | string>, capEnds: 0 | 1) => ID;
266
+ /**
267
+ * Creates a revolve operation
268
+ * @param partId Id of the part to create the revolve in.
269
+ * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
270
+ * @param axisIds Array of ids, either [lineId] or [point1Id, point2Id], ids can be both ccId or graphicId
271
+ * @param angle1 Start of revolve in degrees
272
+ * @param angle2 End of revolve in degrees
273
+ * @param inverted flag, whether to invert the axis or not
274
+ * @return id of the revolve operation
275
+ */
276
+ revolve: (partId: VID, sketchOrRegionIds: VID | VIDs, axisIds: VID[], angle1: number | string, angle2: number | string, inverted: 0 | 1) => ID;
277
+ /**
278
+ * Creates a boolean operation.
279
+ * @param partId id of the part where the operation will be created on
280
+ * @param type type of boolean operation.
281
+ * @param operations ids of the operations for this boolean operation, e.g. Box, Chamfer.
282
+ * At least two operations are needed. First operation in the array is the basic operation,
283
+ * all following are the tool operations, which will be unified, subtract or intersect with/from the first operation.
284
+ * @example
285
+ * // Creates a box and subtracts a cylinder from it
286
+ * const part = api.createPart('Part')
287
+ * const cyl = api.cylinder(part, [], 10, 100)
288
+ * const box = api.box(part, [], 20, 20, 20)
289
+ * api.boolean(part, BooleanOperationType.Subtraction, [box, cyl])
290
+ * const geoms = await api.createBufferGeometry(part)
291
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
292
+ * @return id of the boolean operation
293
+ */
294
+ boolean: (partId: VID, type: BooleanOperationType, operations: VID[]) => ID;
295
+ /**
296
+ * Creates a box operation
297
+ * @param partId id of the part where the box will be created
298
+ * @param references reference of work coordinate system to place the box at
299
+ * @param length length of the box (x-axis)
300
+ * @param width width of the box (y-axis)
301
+ * @param height height of the box (z-axis)
302
+ * @example
303
+ * // Creates a box with a length, width and height of 20
304
+ * const part = api.createPart('Part')
305
+ * const box = api.box(part, [], 20, 20, 20)
306
+ * const geoms = await api.createBufferGeometry(part)
307
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
308
+ * @return id of the box operation
309
+ */
310
+ box: (partId: VID, references: VID[], width: number | string, length: number | string, height: number | string) => ID;
311
+ /**
312
+ * Creates a cylinder operation
313
+ * @param partId id of the part where the cylinder will be created
314
+ * @param references reference of work coordinate system to place the cylinder at
315
+ * @param diameter diameter of the cylinder (x/y-axis)
316
+ * @param height height of the cylinder (z-axis)
317
+ * @example
318
+ * // Creates a cylinder with height = 50 and diameter = 20
319
+ * const part = api.createPart('Part')
320
+ * api.cylinder(part, [], 20, 50)
321
+ * const geoms = await api.createBufferGeometry(part)
322
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
323
+ * @return id of the cylinder operation
324
+ */
325
+ cylinder: (partId: VID, references: VID[], diameter: number | string, height: number | string) => ID;
326
+ /**
327
+ * Creates a chamfer operation
328
+ * @param partId id of the part where the chamfers will be created
329
+ * @param type type of chamfer operation.
330
+ * @param references edge references where the chmamfers will be created on
331
+ * @param dist1 1st distance of the chamfer from the edge
332
+ * @param dist2 2nd distance of the chamfer from the edge. Optional if type = Equal_Distance or Distance_And_Angle
333
+ * @param angle angle of the chamfer. Optional if type = Equal_Distance or Two_Distances
334
+ * @example
335
+ * // Creates a cylinder and puts a chamfer at the bottom edge
336
+ * const part = api.createPart('Part')
337
+ * api.cylinder(part, [], 10, 100)
338
+ * const bottomEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 0 }])
339
+ * api.chamfer(part, ChamferType.Equal_Distance, bottomEdges, 2, 0, 0)
340
+ * const geoms = await api.createBufferGeometry(part)
341
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
342
+ * @return id of the chamfer operation
343
+ */
344
+ chamfer: (partId: VID, type: ChamferType, references: VIDs, dist1: number | string, dist2: number | string, angle: number | string) => ID;
345
+ /**
346
+ * Creates a cone operation.
347
+ * @param partId id of the part where the cone will be created
348
+ * @param references reference of work coordinate system to place the cone at
349
+ * @param bDiameter bottom diameter of the cone
350
+ * @param tDiameter top diameter of the cone
351
+ * @param height height of the cone
352
+ * @example
353
+ * // Creates a cone with bottom diameter = 20, top diameter = 0 and height = 20
354
+ * const part = api.createPart('Part')
355
+ * api.cone(part, [], 20, 0, 20)
356
+ * const geoms = await api.createBufferGeometry(part)
357
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
358
+ * @return id of the cone operation
359
+ */
360
+ cone: (partId: VID, references: VID[], bDiameter: number | string, tDiameter: number | string, height: number | string) => ID;
361
+ /**
362
+ * Creates a fastened constraint between mate1 and mate2 within an assembly.
363
+ * @param id id of the root assembly or an assembly template to create constraints on
364
+ * @param mate1 contains 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
365
+ * @param mate2 contains 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
366
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
367
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
368
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
369
+ * @param name name of the constraint
370
+ * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
371
+ * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
372
+ * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
373
+ * @example
374
+ * // Defines some consts
375
+ * const orig = { x: 0, y: 0, z: 0 }
376
+ * const xDir = { x: 1, y: 0, z: 0 }
377
+ * const yDir = { x: 0, y: 1, z: 0 }
378
+ * const rot = { x: 0, y: 0, z: 0 }
379
+ * const offset1 = { x: 0, y: 0, z: 0 }
380
+ * const offset2 = { x: 0, y: 0, z: 0 }
381
+ * const offset3 = { x: 15, y: 15, z: 30 }
382
+ *
383
+ * // Creates the root assembly first
384
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
385
+ *
386
+ * // Creates a part template and adds geometry to it
387
+ * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
388
+ * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
389
+ * const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
390
+ * api.box(partTempl1, [wcs1], 30, 30, 30)
391
+ *
392
+ * // Creates another part template and adds geometry to it
393
+ * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
394
+ * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
395
+ * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
396
+ *
397
+ * // Adds the created part templates as instances to the root assembly
398
+ * const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
399
+ * const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
400
+ *
401
+ * // Creates a fastened constraint between the instances
402
+ * await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 'FC', 0, 0, 0)
403
+ * const geoms = await api.createBufferGeometry(rootAsm)
404
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
405
+ * @return id of the fastened constraint
406
+ */
407
+ createFastenedConstraint: (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>;
408
+ /**
409
+ * Updates multiple fastened constraints
410
+ * @param constraints array of constraint parameter objects. See following parameter descriptions.
411
+ * @param mate1 contains 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
412
+ * @param mate2 contains 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
413
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
414
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
415
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
416
+ * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
417
+ * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
418
+ * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
419
+ * @example // tbd
420
+ */
421
+ updateFastenedConstraints: (...constraints: {
422
+ constrId: VID;
423
+ mate1: MateParam;
424
+ mate2: MateParam;
425
+ xOffset: number | string;
426
+ yOffset: number | string;
427
+ zOffset: number | string;
428
+ xRotation?: number | string;
429
+ yRotation?: number | string;
430
+ zRotation?: number | string;
431
+ }[]) => Promise<void>;
432
+ /**
433
+ * Creates a fastened origin constraint for mate1 to the origin (0, 0, 0).
434
+ * @param id id of the root assembly or an assembly template to create constraints on
435
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
436
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
437
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
438
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
439
+ * @param name name of the constraint
440
+ * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
441
+ * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
442
+ * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
443
+ * @example
444
+ * // Defines some consts
445
+ * const orig = { x: 0, y: 0, z: 0 }
446
+ * const xDir = { x: 1, y: 0, z: 0 }
447
+ * const yDir = { x: 0, y: 1, z: 0 }
448
+ * const rot = { x: 0, y: 0, z: 0 }
449
+ * const offset1 = { x: 0, y: 0, z: 0 }
450
+ * const offset2 = { x: 15, y: 15, z: 15 }
451
+ *
452
+ * // Creates the root assembly first
453
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
454
+ *
455
+ * // Creates a part template and adds geometry to it
456
+ * const partTempl = await api.createPartAsTemplate('Part_Template')
457
+ * const wcs1 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs')
458
+ * const wcs2 = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs')
459
+ * api.box(partTempl, [wcs1], 30, 30, 30)
460
+ *
461
+ * // Adds the created part template as an instance to the root assembly
462
+ * const prt = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
463
+ *
464
+ * // Creates a fastened origin constraint. The box of the part will be centered in origin
465
+ * await api.createFastenedOriginConstraint(rootAsm, { matePath: [prt], wcsId: wcs2 }, 0, 0, 0, 'FOC', 0, 0, 0)
466
+ *
467
+ * const geoms = await api.createBufferGeometry(rootAsm)
468
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial({ transparent: true, opacity: 0.5 })))
469
+ * @return id of the fastened origin constraint
470
+ */
471
+ createFastenedOriginConstraint: (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>;
472
+ /**
473
+ * Updates multiple fastened origin constraints
474
+ * @param constraints array of constraint parameter objects. See following descriptions.
475
+ * @param mate1 contains 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
476
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
477
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
478
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
479
+ * @param xRotation [optional] defines a rotation of mate2 around x-axis of mate1
480
+ * @param yRotation [optional] defines a rotation of mate2 around y-axis of mate1
481
+ * @param zRotation [optional] defines a rotation of mate2 around z-axis of mate1
482
+ * @example // tbd
483
+ */
484
+ updateFastenedOriginConstraints: (...constraints: {
485
+ constrId: VID;
486
+ mate1: MateParam;
487
+ xOffset: number | string;
488
+ yOffset: number | string;
489
+ zOffset: number | string;
490
+ xRotation?: number | string;
491
+ yRotation?: number | string;
492
+ zRotation?: number | string;
493
+ }[]) => Promise<void>;
494
+ /**
495
+ * Creates a cylindrical constraint between mate1 and mate2 within an assembly.
496
+ * @param id id of the root assembly or an assembly template to create constraints on
497
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
498
+ * @param mate2 contains 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
499
+ * @param zOffsetLimits min and max value of offset along z
500
+ * @param zRotationLimits min and max value of rotation around z
501
+ * @param name name of the constraint
502
+ * @example // tbd
503
+ * @return id of the cylindrical constraint
504
+ */
505
+ createCylindricalConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
506
+ /**
507
+ * Updates multiple cylindrical constraints.
508
+ * @param constraints array of constraint parameter objects. See following descriptions.
509
+ * @param constrId id of the constraint to update
510
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
511
+ * @param mate2 contains 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
512
+ * @param zOffsetLimits min and max value of offset along z
513
+ * @param zRotationLimits min and max value of rotation around z
514
+ * @example // tbd
515
+ */
516
+ updateCylindricalConstraints: (...constraints: {
517
+ constrId: VID;
518
+ mate1: MateParam;
519
+ mate2: MateParam;
520
+ zOffsetLimits: LimitsParam;
521
+ zRotationLimits: LimitsParam;
522
+ }[]) => Promise<void>;
523
+ /**
524
+ * Creates a revolute constraint between mate1 and mate2 within an assembly.
525
+ * @param id id of the root assembly or an assembly template to create constraints on
526
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
527
+ * @param mate2 contains 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
528
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
529
+ * @param zRotationLimits min and max value of rotation around z
530
+ * @param name name of the constraint
531
+ * @example // tbd
532
+ * @return id of the revolute constraint
533
+ */
534
+ createRevoluteConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
535
+ /**
536
+ * Updates multiple revolute constraints.
537
+ * @param constraints array of constraint parameter objects. See following descriptions.
538
+ * @param constrId id of the constraint to update
539
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
540
+ * @param mate2 contains 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
541
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
542
+ * @param zRotationLimits min and max value of rotation around z
543
+ * @example // tbd
544
+ */
545
+ updateRevoluteConstraints: (...constraints: {
546
+ constrId: VID;
547
+ mate1: MateParam;
548
+ mate2: MateParam;
549
+ zOffset: number | string;
550
+ zRotationLimits: LimitsParam;
551
+ }[]) => Promise<void>;
552
+ /**
553
+ * Creates a slider constraint between mate1 and mate2 within an assembly.
554
+ * @param id id of the root assembly or an assembly template to create constraints on
555
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
556
+ * @param mate2 contains 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
557
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
558
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
559
+ * @param zOffsetLimits min and max value of offset along z
560
+ * @param name name of the constraint
561
+ * @example // tbd
562
+ * @return id of the slider constraint
563
+ */
564
+ createSliderConstraint: (id: VID, mate1: MateParam, mate2: MateParam, xOffset: number | string, yOffset: number | string, zOffsetLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
565
+ /**
566
+ * Updates multiple slider constraints.
567
+ * @param constraints array of constraint parameter objects. See following descriptions.
568
+ * @param constrId id of the constraint to update
569
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
570
+ * @param mate2 contains 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
571
+ * @param xOffset defines a offset in x-axis from mate1 to mate2
572
+ * @param yOffset defines a offset in y-axis from mate1 to mate2
573
+ * @param zOffsetLimits min and max value of offset along z
574
+ * @example // tbd
575
+ */
576
+ updateSliderConstraints: (...constraints: {
577
+ constrId: VID;
578
+ mate1: MateParam;
579
+ mate2: MateParam;
580
+ xOffset: number | string;
581
+ yOffset: number | string;
582
+ zOffsetLimits: LimitsParam;
583
+ }[]) => Promise<void>;
584
+ /**
585
+ * Creates a planar constraint between mate1 and mate2 within an assembly.
586
+ * @param id id of the root assembly or an assembly template to create constraints on
587
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
588
+ * @param mate2 contains 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
589
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
590
+ * @param xOffsetLimits min and max value of offset along x
591
+ * @param yOffsetLimits min and max value of offset along y
592
+ * @param zRotationLimits min and max value of rotation around z
593
+ * @param name name of the constraint
594
+ * @example // tbd
595
+ * @return id of the planar constraint
596
+ */
597
+ createPlanarConstraint: (id: VID, mate1: MateParam, mate2: MateParam, zOffset: number | string, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
598
+ /**
599
+ * Updates multiple planar constraints.
600
+ * @param constraints array of constraint parameter objects. See following descriptions.
601
+ * @param constrId id of the constraint to update
602
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
603
+ * @param mate2 contains 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
604
+ * @param zOffset defines a offset in z-axis from mate1 to mate2
605
+ * @param xOffsetLimits min and max value of offset along x
606
+ * @param yOffsetLimits min and max value of offset along y
607
+ * @param zRotationLimits min and max value of rotation around z
608
+ * @example // tbd
609
+ */
610
+ updatePlanarConstraints: (...constraints: {
611
+ constrId: VID;
612
+ mate1: MateParam;
613
+ mate2: MateParam;
614
+ zOffset: number | string;
615
+ xOffsetLimits: LimitsParam;
616
+ yOffsetLimits: LimitsParam;
617
+ zRotationLimits: LimitsParam;
618
+ }[]) => Promise<void>;
619
+ /**
620
+ * Creates a parallel constraint between mate1 and mate2 within an assembly.
621
+ * @param id id of the root assembly or an assembly template to create constraints on
622
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
623
+ * @param mate2 contains 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
624
+ * @param xOffsetLimits min and max value of offset along x
625
+ * @param yOffsetLimits min and max value of offset along y
626
+ * @param zOffsetLimits min and max value of offset along z
627
+ * @param zRotationLimits min and max value of rotation around z
628
+ * @param name name of the constraint
629
+ * @example // tbd
630
+ * @return id of the parallel constraint
631
+ */
632
+ createParallelConstraint: (id: VID, mate1: MateParam, mate2: MateParam, xOffsetLimits: LimitsParam, yOffsetLimits: LimitsParam, zOffsetLimits: LimitsParam, zRotationLimits: LimitsParam, name: string) => Promise<ObjectID | null>;
633
+ /**
634
+ * Updates multiple parallel constraints.
635
+ * @param constraints array of constraint parameter objects. See following descriptions.
636
+ * @param constrId id of the constraint to update
637
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states
638
+ * @param mate2 contains 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
639
+ * @param xOffsetLimits min and max value of offset along x
640
+ * @param yOffsetLimits min and max value of offset along y
641
+ * @param zOffsetLimits min and max value of offset along z
642
+ * @param zRotationLimits min and max value of rotation around z
643
+ * @example // tbd
644
+ */
645
+ updateParallelConstraints: (...constraints: {
646
+ constrId: VID;
647
+ mate1: MateParam;
648
+ mate2: MateParam;
649
+ xOffsetLimits: LimitsParam;
650
+ yOffsetLimits: LimitsParam;
651
+ zOffsetLimits: LimitsParam;
652
+ zRotationLimits: LimitsParam;
653
+ }[]) => Promise<void>;
654
+ /**
655
+ * Creates a group constraint between selected instances within an assembly.
656
+ * @param id id of the root assembly or an assembly template to create constraints on
657
+ * @param instanceIds ids of instances to be grouped
658
+ * @param name name of the constraint
659
+ * @example // tbd
660
+ * @return id of the group constraint
661
+ */
662
+ createGroupConstraint: (id: VID, instanceIds: VID[], name: string) => Promise<ObjectID | null>;
663
+ /**
664
+ * Updates multiple group constraints.
665
+ * @param constraints array of constraint parameter objects. See following descriptions.
666
+ * @param constrId id of the constraint to update
667
+ * @param instanceIds ids of instances to be grouped
668
+ * @example // tbd
669
+ */
670
+ updateGroupConstraints: (...constraints: {
671
+ constrId: VID;
672
+ instanceIds: VID[];
673
+ }[]) => Promise<void>;
674
+ /**
675
+ * Makes copies of a selected instance and creates a linear pattern constraint between them.
676
+ * @param id id of the root assembly or an assembly template to create constraints on
677
+ * @param instanceId id of the instance to be copied
678
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
679
+ * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
680
+ * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
681
+ * @param name name of the constraint
682
+ * @param mate2 [optional] contains 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; should belong to the selected instance
683
+ * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
684
+ * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
685
+ * @example // tbd
686
+ * @return id of the linear pattern constraint
687
+ */
688
+ createLinearPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, firstDirInstanceCount: number | string, firstDirDistance: number | string, name: string, mate2?: MateParam, secondDirInstanceCount?: number | string, secondDirDistance?: number | string) => Promise<ObjectID | null>;
689
+ /**
690
+ * Updates multiple linear pattern constraints.
691
+ * @param constraints array of constraint parameter objects. See following descriptions.
692
+ * @param constrId id of the constraint to update
693
+ * @param instanceId id of the instance to be copied
694
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
695
+ * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
696
+ * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
697
+ * @param mate2 [optional] contains 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; should belong to the selected instance
698
+ * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
699
+ * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
700
+ * @example // tbd
701
+ */
702
+ updateLinearPatternConstraints: (...constraints: {
703
+ constrId: VID;
704
+ instanceId: VID;
705
+ mate1: MateParam;
706
+ firstDirInstanceCount: number | string;
707
+ firstDirDistance: number | string;
708
+ mate2?: MateParam;
709
+ secondDirInstanceCount?: number | string;
710
+ secondDirDistance?: number | string;
711
+ }[]) => Promise<void>;
712
+ /**
713
+ * Makes copies of a selected instance and creates a circular pattern constraint between them.
714
+ * @param id id of the root assembly or an assembly template to create constraints on
715
+ * @param instanceId id of the instance to be copied
716
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
717
+ * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
718
+ * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
719
+ * @param offset offset between copies (set by z-axis of mate2)
720
+ * @param name name of the constraint
721
+ * @example // tbd
722
+ * @return id of the circular pattern constraint
723
+ */
724
+ createCircularPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, instanceCount: number | string, angle: number | string, offset: number | string, name: string) => Promise<ObjectID | null>;
725
+ /**
726
+ * Updates multiple circular pattern constraints.
727
+ * @param constraints array of constraint parameter objects. See following descriptions.
728
+ * @param constrId id of the constraint to update
729
+ * @param instanceId id of the instance to be copied
730
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
731
+ * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
732
+ * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
733
+ * @param offset offset between copies (set by z-axis of mate2)
734
+ * @example // tbd
735
+ */
736
+ updateCircularPatternConstraints: (...constraints: {
737
+ constrId: VID;
738
+ instanceId: VID;
739
+ mate1: MateParam;
740
+ instanceCount: number | string;
741
+ angle: number | string;
742
+ offset: number | string;
743
+ }[]) => Promise<void>;
744
+ /**
745
+ * Updates limited value specified (with 'paramName') of multiple constraints
746
+ * @param constrValues array of constraint value objects. See following parameter description for that.
747
+ * @param constrId id of the constraint to update the limited value
748
+ * @param paramName name of the limited parameter
749
+ * @param value new value to set
750
+ */
751
+ update3dConstraintValues: (...constrValues: {
752
+ constrId: VID;
753
+ paramName: LimitedValue;
754
+ value: number;
755
+ }[]) => Promise<void>;
756
+ /**
757
+ * Creates the buffer geometry of any product (part or assembly).
758
+ * @param productId id of the product to create buffer geometry from
759
+ * @example
760
+ * // Creates a cone with bottom diameter = 20, top diameter = 0 and height = 30
761
+ * const part = api.createPart('Part')
762
+ * api.cone(part, [], 20, 0, 30)
763
+ * const geoms = await api.createBufferGeometry(part)
764
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
765
+ * @return array of buffer geometry
766
+ */
767
+ createBufferGeometry: (productId: VID) => Promise<BufferGeometry[] | undefined>;
768
+ /**
769
+ * Creates the threeJS scene of any product (part or assembly).
770
+ * @param productId id of the product to create scene from
771
+ * @param options optional object to define different settings.
772
+ * @param meshPerGeometry boolean flag to define if a part/solid will have a mesh for each
773
+ * geometry element or if the elements will be merged to one mesh
774
+ * @return object containing all the created THREE objects like scene, nodes and materials
775
+ * @example // tbd
776
+ */
777
+ createScene: (productId?: VID, options?: {
778
+ meshPerGeometry?: boolean;
779
+ structureOnly?: boolean;
780
+ }) => Promise<{
781
+ scene: Scene;
782
+ nodes: {
783
+ [key: string]: Object3D;
784
+ };
785
+ materials: {
786
+ [key: string]: Material;
787
+ };
788
+ }>;
789
+ /**
790
+ * Creates one or more expressions.
791
+ * @param partId id or identifier of the part to create the expressions in
792
+ * @param members array of members which contain a name and a value. Value can be an expression, e.g. '2 * laenge'
793
+ * @example
794
+ * // Creates an expression and links it with the width of the box
795
+ * const part = api.createPart('Part')
796
+ * api.createExpressions(part, { name: 'width', value: 20 })
797
+ * api.box(part, [], 'ExpressionSet.width', 20, 20)
798
+ * const geoms = await api.createBufferGeometry(part)
799
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
800
+ * @return true or false, depending on whether creating the expressions was successful or not
801
+ */
802
+ createExpressions: (partId: VID | ObjectIdent, ...members: {
803
+ name: string;
804
+ value: number | string;
805
+ }[]) => Promise<boolean>;
806
+ /**
807
+ * Creates a new assembly template. This template will be added to the assembly container
808
+ * and can be instantiated multiple times as a sub assembly in the root assembly or in other assembly template.
809
+ * Assembly templates can only be created if the root is already an assembly.
810
+ * @param name [optional] name of the assembly template. Default = 'Assembly'
811
+ * @example
812
+ * // Defines some consts
813
+ * const orig = { x: 0, y: 0, z: 0 }
814
+ * const xDir = { x: 1, y: 0, z: 0 }
815
+ * const yDir = { x: 0, y: 1, z: 0 }
816
+ * const rot = { x: 0, y: 0, z: 0 }
817
+ * const offset1 = { x: 0, y: 0, z: 0 }
818
+ * const offset2 = { x: 0, y: 0, z: 0 }
819
+ * const offset3 = { x: 50, y: 0, z: 0 }
820
+ *
821
+ * // Creates the root assembly first
822
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
823
+ *
824
+ * // Creates a assembly template
825
+ * const asmTempl = await api.createAssemblyAsTemplate('Assembly_Template')
826
+ *
827
+ * // Creates a part template and adds geometry to it
828
+ * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
829
+ * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
830
+ * api.box(partTempl1, [wcs1], 30, 30, 30)
831
+ *
832
+ * // Creates another part template and adds geometry to it
833
+ * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
834
+ * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
835
+ * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
836
+ *
837
+ * // Adds the created part templates as instances to the assembly
838
+ * // and the assembly itself multiple times to the root assembly
839
+ * const prt1 = await api.addInstances(partTempl1, asmTempl, [orig, xDir, yDir])
840
+ * const prt2 = await api.addInstances(partTempl2, asmTempl, [orig, xDir, yDir])
841
+ * const asm1 = await api.addInstances(asmTempl, rootAsm, [orig, xDir, yDir])
842
+ * const asm2 = await api.addInstances(asmTempl, rootAsm, [offset3, xDir, yDir])
843
+ *
844
+ * const geoms = await api.createBufferGeometry(rootAsm)
845
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
846
+ * @return id of the assembly template
847
+ */
848
+ createAssemblyAsTemplate: (name?: string) => ID;
849
+ /**
850
+ * Creates a new root assembly. This is the top level assembly.
851
+ * @param name [optional] name of the root assembly. Default = 'AssemblyRoot'
852
+ * @param options optional object containing ident property to define an identifier for the created root assembly
853
+ * @example
854
+ * // Defines some consts
855
+ * const orig = { x: 0, y: 0, z: 0 }
856
+ * const xDir = { x: 1, y: 0, z: 0 }
857
+ * const yDir = { x: 0, y: 1, z: 0 }
858
+ * const rot = { x: 0, y: 0, z: 0 }
859
+ * const offset = { x: 20, y: 0, z: 0 }
860
+ *
861
+ * // Creates the root assembly first
862
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
863
+ *
864
+ * // Creates a part template and adds geometry to it
865
+ * const partTempl = await api.createPartAsTemplate('Part_Template')
866
+ * const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
867
+ * api.box(partTempl, [wcs], 30, 30, 10)
868
+ *
869
+ * // Adds the created part template as an instance to the root assembly
870
+ * const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
871
+ * const geoms = await api.createBufferGeometry(rootAsm)
872
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
873
+ * @return id of the root assembly
874
+ */
875
+ createRootAssembly: (name?: string, options?: {
876
+ ident?: ObjectIdent;
877
+ }) => ID;
878
+ /**
879
+ * Creates a new root part. This is the top level part.
880
+ * @param name [optional] name of the part. Default = 'Part'
881
+ * @example
882
+ * // Creates a box and subtracts a cylinder from it
883
+ * const part = api.createPart('Part')
884
+ * api.cylinder(part, [], 10, 100)
885
+ * const geoms = await api.createBufferGeometry(part)
886
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
887
+ * @return id of the root part
888
+ */
889
+ createPart: (name?: string) => ID;
890
+ /**
891
+ * Creates a new part template. This template will be added to the part container
892
+ * and can be instantiated multiple times in the root assembly or in assembly templates.
893
+ * Part templates can only be created if the root is already an assembly.
894
+ * @param name [optional] name of the part. Default = 'Part'
895
+ * @example
896
+ * // Defines some consts
897
+ * const orig = { x: 0, y: 0, z: 0 }
898
+ * const xDir = { x: 1, y: 0, z: 0 }
899
+ * const yDir = { x: 0, y: 1, z: 0 }
900
+ * const rot = { x: 0, y: 0, z: 0 }
901
+ * const offset = { x: 20, y: 0, z: 0 }
902
+ *
903
+ * // Creates the root assembly first
904
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
905
+ *
906
+ * // Creates a part template and adds geometry to it
907
+ * const partTempl = await api.createPartAsTemplate('Part_Template')
908
+ * const wcs = await api.createWorkCoordSystem(partTempl, WorkCoordSystemType.WCS_Custom, [], offset, rot, false, 'wcs')
909
+ * api.box(partTempl, [wcs], 30, 30, 10)
910
+ *
911
+ * // Adds the created part template as an instance to the root assembly
912
+ * const partRef = await api.addInstances(partTempl, rootAsm, [orig, xDir, yDir])
913
+ * const geoms = await api.createBufferGeometry(rootAsm)
914
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
915
+ * @return id of the part template
916
+ */
917
+ createPartAsTemplate: (name?: string) => ID;
918
+ /**
919
+ * Creates a new work axis for the given part
920
+ * @param partId id of the part to add the new work axis to
921
+ * @param type type of the work axis
922
+ * @param references references for the work axis, needed for all types except 'Custom'
923
+ * @param position position of axis, only needed if type = 'Custom'
924
+ * @param direction direction of axis, only needed if type = 'Custom'
925
+ * @param local if true, work axis is set in local coordinates of part???
926
+ * @param name name of the work axis, if not set default name = 'WorkAxis'
927
+ * @example //tbd
928
+ * @return id of the work axis
929
+ */
930
+ createWorkAxis: (partId: VID, type: WorkAxisType, references: VID[], position: Vec<number | string>, direction: Vec<number | string>, local: boolean, name?: string) => ID;
931
+ /**
932
+ * Creates a new work coordinate system for the given part.
933
+ * @param partId id of the part to add the new work coord system to
934
+ * @param type type of the work coordinate system
935
+ * @param references references for the work coordinate system (point and 2 axis). If empty array, the work coordinate system will set to origin (0, 0, 0)
936
+ * @param offset offset from work coordinate system in x-, y- and z-direction
937
+ * @param rotation rotation around x-, y- and z-axis from work coordinate system
938
+ * @param inverted inverts the direction of the primary axis
939
+ * @param name name of the work coordinate system, if not set default name = 'WorkCoordSystem'
940
+ * @example
941
+ * // Defines some consts
942
+ * const orig = { x: 0, y: 0, z: 0 }
943
+ * const xDir = { x: 1, y: 0, z: 0 }
944
+ * const yDir = { x: 0, y: 1, z: 0 }
945
+ * const rot = { x: 0, y: 0, z: 0 }
946
+ * const offset1 = { x: 0, y: 0, z: 0 }
947
+ * const offset2 = { x: 0, y: 0, z: 0 }
948
+ * const offset3 = { x: 15, y: 15, z: 30 }
949
+ *
950
+ * // Creates the root assembly first
951
+ * const rootAsm = await api.createRootAssembly('Root_Assembly')
952
+ *
953
+ * // Creates a part template and adds geometry to it
954
+ * const partTempl1 = await api.createPartAsTemplate('Part_Template1')
955
+ * const wcs1 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset1, rot, false, 'wcs1')
956
+ * const wcs3 = await api.createWorkCoordSystem(partTempl1, WorkCoordSystemType.WCS_Custom, [], offset3, rot, false, 'wcs3')
957
+ * api.box(partTempl1, [wcs1], 30, 30, 30)
958
+ *
959
+ * // Creates another part template and adds geometry to it
960
+ * const partTempl2 = await api.createPartAsTemplate('Part_Template2')
961
+ * const wcs2 = await api.createWorkCoordSystem(partTempl2, WorkCoordSystemType.WCS_Custom, [], offset2, rot, false, 'wcs2')
962
+ * api.cone(partTempl2, [wcs2], 30, 0.1, 30)
963
+ *
964
+ * // Adds the created part templates as instances to the root assembly
965
+ * const prt1 = await api.addInstances(partTempl1, rootAsm, [orig, xDir, yDir])
966
+ * const prt2 = await api.addInstances(partTempl2, rootAsm, [orig, xDir, yDir])
967
+ *
968
+ * // Creates a fastened constraint between the instances
969
+ * await api.createFastenedConstraint(rootAsm, { matePath: [prt1], wcsId: wcs3 }, { matePath: [prt2], wcsId: wcs2 }, 0, 0, 0, 0, 0, 'FC')
970
+ * const geoms = await api.createBufferGeometry(rootAsm)
971
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
972
+ * @return id of the work coordinate system
973
+ */
974
+ createWorkCoordSystem: (partId: VID, type: WorkCoordSystemType, references: VID[], offset: Vec<number | string>, rotation: Vec<number | string>, inverted: boolean, name?: string) => ID;
975
+ /**
976
+ * Creates a new work plane for the given part
977
+ * @param partId id of the part to add the new work plane to
978
+ * @param type type of the work plane
979
+ * @param references references for the work plane, needed for all types except 'Custom'
980
+ * @param offset offset in normal direction, can be used for all types except 'LinePlaneAndAngle'
981
+ * @param angle angle in degrees, needed for type 'LinePlaneAndAngle'
982
+ * @param position position of plane, only needed if type = 'Custom'
983
+ * @param normal normal vector of work plane, only needed if type = 'Custom'
984
+ * @param local if true, work plane is set in local coordinates of part???
985
+ * @param name name of the work plane, if not set default name = 'WorkAxis'
986
+ * @example // tbd
987
+ * @return id of the work plane
988
+ */
989
+ createWorkPlane: (partId: VID, type: WorkPlaneType, references: VID[], offset: number, angle: number, position: Vec<number | string>, normal: Vec<number | string>, local: boolean, name?: string) => ID;
990
+ /**
991
+ * Creates a new work point for the given part
992
+ * @param partId id of the part to add the new work point to
993
+ * @param type type of the work point
994
+ * @param references references for the work point, needed for all types except 'Custom'
995
+ * @param position position of point, only needed if type = 'Custom'
996
+ * @param direction direction of point, only needed if type = 'Custom'
997
+ * @param local if true, work point is set in local coordinates of part???
998
+ * @param name name of the work point, if not set default name = 'WorkPoint'
999
+ * @example // tbd
1000
+ * @return id of the work point
1001
+ */
1002
+ createWorkPoint: (partId: VID, type: WorkPointType, references: VID[], position: Vec<number | string>, local: boolean, name?: string) => ID;
1003
+ /**
1004
+ * Deletes existing expressions.
1005
+ * @param partId id or identifier of part to delete expressions from
1006
+ * @param members name of members to delete
1007
+ * @example
1008
+ * // Deletes an expression from part's expression set
1009
+ * const part = api.createPart('Part')
1010
+ * api.createExpressions(part, { name: 'width', value: 20 }, { name: 'height', value: 40 })
1011
+ * api.deleteExpressions(part, ['height'])
1012
+ * await api.box(part, [], 'ExpressionSet.width', 20, 20)
1013
+ * const geoms = await api.createBufferGeometry(part)
1014
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1015
+ * @return true or false, depending on whether deleting the expressions was successful or not
1016
+ */
1017
+ deleteExpressions: (partId: VID | ObjectIdent, members: string[]) => Promise<boolean>;
1018
+ /**
1019
+ * Loads a sketch from a ofb filestream and adds its elements to a new sketch.
1020
+ * The id of this new created sketch will be returned.
1021
+ *
1022
+ * @param partId id of the part we want to create the new sketch and copy the sketch elements into it
1023
+ * @param strm stream of ofb file which contains the sketch
1024
+ * @param planeId id of the face or workplane to set the new sketch on
1025
+ * @param name optional name of the sketch to load from filestream
1026
+ * @return id of the new sketch, containing the sketch elements from loaded sketch
1027
+ */
1028
+ loadSketch: (partId: VID, strm: ArrayBuffer, planeId: VID, name?: string) => ID;
1029
+ /**
1030
+ * Copy an existing sketch and adds its elements to a new sketch.
1031
+ * The id of this new created sketch will be returned.
1032
+ *
1033
+ * @param partId id of the part we want to create the new sketch and copy the sketch elements into it
1034
+ * @param sketchId id of the sketch to copy
1035
+ * @param planeId id of the face or workplane to set the new sketch on
1036
+ * @return id of the new sketch, containing the sketch elements form copied sketch
1037
+ */
1038
+ copySketch: (partId: VID, sketchId: VID, planeId: VID) => ID;
1039
+ /**
1040
+ * Place/position the sketch with plane, axis and origin references.
1041
+ *
1042
+ * @param sketchId id of the sketch to place
1043
+ * @param planeId - id of a face or a workplane. This will be the plane where the sketch lies on.
1044
+ * If a plane reference already exists, planeId is optional
1045
+ * @param invertPlane - if true, the normal of the plane will be inverted
1046
+ * @param axisId - optional id of an edge or workaxis. This will be the x-Axis
1047
+ * @param isXAxis - if 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
1048
+ * @param invertAxis - if true, the direction of the axis will be inverted
1049
+ * @param originId - optional point or vertex of the sketch's origin reference
1050
+ */
1051
+ placeSketch: (sketchId: VID, planeId: VID, invertPlane: boolean, axisId: VID, isXAxis: boolean, invertAxis: boolean, originId: VID) => Promise<void>;
1052
+ /**
1053
+ * Creates a sphere operation
1054
+ * @param partId id of the part where the sphere will be created
1055
+ * @param references reference of work coordinate system to place the cone at
1056
+ * @param radius bottom diameter of the cone
1057
+ * @example
1058
+ * // Creates a sphere with radius = 20
1059
+ * const part = api.createPart('Part')
1060
+ * api.sphere(part, [], 20)
1061
+ * const geoms = await api.createBufferGeometry(part)
1062
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1063
+ * @return id of the sphere operation
1064
+ */
1065
+ sphere: (partId: VID, references: VID[], radius: number | string) => ID;
1066
+ /**
1067
+ * Creates a fillet operation
1068
+ * @param partId id of the part where the fillet will be created
1069
+ * @param references edge references where the fillet will be created on
1070
+ * @param radius radius of the fillet
1071
+ * @example
1072
+ * // Creates a cylinder and puts a fillet at the top edge
1073
+ * const part = api.createPart('Part')
1074
+ * api.cylinder(part, [], 10, 100)
1075
+ * const topEdges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
1076
+ * api.fillet(part, topEdges, 2)
1077
+ * const geoms = await api.createBufferGeometry(part)
1078
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1079
+ * @return id of the fillet operation
1080
+ */
1081
+ fillet: (partId: VID, references: VIDs, radius: number | string) => ID;
1082
+ /**
1083
+ * Important note: To use this method, you need to add the BuerliGeometry component to your application.
1084
+ * Otherwise the selection of geometry won't work.
1085
+ * [See this link to buerli geometry](https://buerli.io/docs/training-for-programmers/More/graphics#3-using-the-buerligeometry-react-component)
1086
+ *
1087
+ * Lets the user select geometry in graphical interface. As soon as the geometry of given type has been selected, the method
1088
+ * will return necessary information about it.
1089
+ * [See this link to selections](https://buerli.io/docs/training-for-programmers/history/HowTos/useSelectionInHeadless)
1090
+ *
1091
+ * The _userData_ of the returned object contains additional information about the selected geometry. All geometric
1092
+ * information in the _userData_ is already transformed to the correct position. This is especially important for
1093
+ * assemblies.
1094
+ *
1095
+ * @param types array of types to filter user selection.
1096
+ * @param count optional number of selections to make (count must be >= 1). Default = 1.
1097
+ * @return array of objects containing information about selected geometries
1098
+ */
1099
+ selectGeometry: <T = GeometryElement>(types: GrT[], count?: number) => Promise<InteractionInfo<T>[]>;
1100
+ /**
1101
+ * Find geometries of given type on solids in the given part at the given global positions.
1102
+ * @param partId Id of the part where geometries tried to be found.
1103
+ * @param type Type of the geometry to look for
1104
+ * @param positions Array of elements containing one or more positions to look for the geometry
1105
+ * @example
1106
+ * // Find planes at two different positions
1107
+ * const planes = await api.findGeometry(productId, GraphicType.PLANE, [[{x: 50, y: 50, z: 100}], [{x: 100, y: 50, z: 50}]])
1108
+ * @return array containing ids of found geometries
1109
+ */
1110
+ findGeometry: (partId: VID, type: GrT, positions: Vec[][]) => IDs;
1111
+ /**
1112
+ * Returns the assembly template with given name from assembly container.
1113
+ * If asmName is empty, all assemblies from assembly container will be returned.
1114
+ * @param asmName Name of assembly to look for
1115
+ * @example // tbd
1116
+ * @return array containing ids of assembly templates
1117
+ */
1118
+ getAssemblyTemplate: (asmName?: string) => IDs;
1119
+ /**
1120
+ * Returns an instance or all instances of a node, depending on whether a name is given or not.
1121
+ * The node is the parent of the instance/instances we're looking for and can be a root assembly,
1122
+ * another instance or an assembly template.
1123
+ * @param id id of the node from which we are searching the children for instances that have the name we are looking for.
1124
+ * @param instanceName name of the instance we are looking for
1125
+ * @example // tbd
1126
+ * @return array containing the ids of the found instances
1127
+ */
1128
+ getInstance: (id: VID, instanceName?: string) => IDs;
1129
+ /**
1130
+ * Find first instance which can be identified by given identifier or name.
1131
+ * If both optional parameters has been set, the identifier is treated with priority.
1132
+ * If no instance with given identifier will be found, the name is used to find an instance.
1133
+ *
1134
+ * @param drawingId The drawing id.
1135
+ * @param options Optional parameters to identify to find instance.
1136
+ * @param options.instanceIdent Identifier to find the instance by an identifier
1137
+ * @param options.instanceName Name to find the instance by its name
1138
+ * @returns first found instance which meets the searching conditions or null if nothing could be found
1139
+ */
1140
+ findInstance: (options: {
1141
+ instanceIdent?: ObjectIdent;
1142
+ instanceName?: string;
1143
+ }) => ID;
1144
+ /**
1145
+ * Returns the product ids of the given instance ids.
1146
+ * @param instanceIds ids of the instances to get the product ids from
1147
+ * @example // tbd
1148
+ * @return array containing the product ids of the given instance ids
1149
+ */
1150
+ getProductsOfInstances: (instanceIds: VID[]) => IDs;
1151
+ /**
1152
+ * Returns the id of the current product
1153
+ * @example // tbd
1154
+ */
1155
+ getCurrentProduct: () => ID;
1156
+ /**
1157
+ * Sets the instance with id to the new current instance
1158
+ *
1159
+ * @param id id of the instance to set as the current
1160
+ * @example // tbd
1161
+ */
1162
+ setCurrentInstance: (id: VID) => Promise<void>;
1163
+ /**
1164
+ * Sets the product with productId to the new current product
1165
+ *
1166
+ * @param productId Id of the product to set as the current
1167
+ * @example // tbd
1168
+ */
1169
+ setCurrentProduct: (productId: VID) => Promise<void>;
1170
+ /**
1171
+ * Returns the id of the current instance
1172
+ * @example // tbd
1173
+ * @return id of the current instance
1174
+ */
1175
+ getCurrentInstance: () => ID;
1176
+ /**
1177
+ * Returns the global transformation of the given id.
1178
+ * Currently only ids of instances supported.
1179
+ *
1180
+ * @param id id of the object to get the global transformation from
1181
+ * @example // tbd
1182
+ * @return transformation of instance as two-dimensional array containing origin position and direction for x, y and z
1183
+ * [
1184
+ * [origin.x, origin.y, origin.z],
1185
+ * [xVec.x, xVec.y, xVec.z],
1186
+ * [yVec.x, yVec.y, yVec.z],
1187
+ * [zVec.x, zVec.y, zVec.z]
1188
+ * ]
1189
+ */
1190
+ getTransformation: (id: VID) => Promise<number[][]>;
1191
+ /**
1192
+ * Returns the part template with given name from part container.
1193
+ * If partName is empty, all parts from part container will be returned.
1194
+ * @param partName Name of part to look for
1195
+ * @example // tbd
1196
+ * @return array containing ids of part templates
1197
+ */
1198
+ getPartTemplate: (partName?: string) => IDs;
1199
+ /**
1200
+ * Returns the work coord system with the given wcsName from the given reference.
1201
+ * If wcsName is not set, all work coord systems of the reference will be returned.
1202
+ * @deprecated use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.
1203
+ * @param refId id of the reference to look for the work coord system
1204
+ * @param wcsName name of the work coord system to look for
1205
+ * @example
1206
+ * // Adds a loaded part to an assembly. To set the part to the origin of the
1207
+ * // assembly with a constraint, the work coord system can be get from part by name.
1208
+ * const pt0 = { x: 0, y: 0, z: 0 }
1209
+ * const xDir = { x: 1, y: 0, z: 0 }
1210
+ * const yDir = { x: 0, y: 1, z: 0 }
1211
+ * const nutBoltAsm = await api.createRootAssembly('NutBolt_Asm')
1212
+ * const bolt = await api.loadProduct(arraybuffer, 'ofb')
1213
+ * const boltRefId = await api.addInstances(bolt, nutBoltAsm, [pt0, xDir, yDir])
1214
+ * const wcsIdOrigin = await api.getWorkCoordSystem(boltRefId, 'WCS_Origin')
1215
+ * await api.createFastenedOriginConstraint(nutBoltAsm, { refId: boltRefId, wcsId: wcsIdOrigin[0] }, 0, 0, 0, 0, 0, 'FOC')
1216
+ * const geoms = await api.createBufferGeometry(nutBoltAsm)
1217
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1218
+ * @return array containing ids of work coordinate systems
1219
+ */
1220
+ getWorkCoordSystem: (id: VID, wcsName?: string) => IDs;
1221
+ /**
1222
+ * Returns the sketch region with the given sketchRegionName from the given instance or part id.
1223
+ * If sketchRegionName is not set, all sketch regions of the reference will be returned.
1224
+ * @param id id of the instance or part to look for the sketch region
1225
+ * @param sketchRegionName name of the sketch region to look for
1226
+ * @example // tbd
1227
+ * @return array containing ids of the sketch regions
1228
+ */
1229
+ getSketchRegion: (id: VID, sketchRegionName?: string) => IDs;
1230
+ /**
1231
+ * Returns the sketch with the given sketchName from the given instance or part id.
1232
+ * If sketchName is not set, all sketches of the reference will be returned.
1233
+ * @param id id of the instance or part to look for the sketch
1234
+ * @param sketchName name of the sketch to look for
1235
+ * @example // tbd
1236
+ * @return array containing ids of the sketches
1237
+ */
1238
+ getSketch: (id: VID, sketchName?: string) => IDs;
1239
+ /**
1240
+ * Returns the work geometry of given type with given name from the given instance or part id.
1241
+ * If the name of the work geometry is empty, all found work geometry of given type is returned
1242
+ * @param id id of the instance or part to look for the work geometry
1243
+ * @param type type of the work geometry to look for
1244
+ * @param wgName optional name of the work geometry to look for
1245
+ * @return array containing ids of the work geometry
1246
+ */
1247
+ getWorkGeometry: (id: VID, type: WorkGeomType, wgName?: string) => IDs;
1248
+ /**
1249
+ * Returns information about a constraint in the given reference
1250
+ * @deprecated use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.
1251
+ * @param refId id of the reference to look for the constraint
1252
+ * @param constrName name of the constraint to look for
1253
+ * @example // tbd
1254
+ * @return array containing information about the constraint
1255
+ * [
1256
+ * constraintId,
1257
+ * [ reference id of first mate, workcoordsystem id of first mate, flip type of first mate, reoriented type of first mate ],
1258
+ * [ reference id of second mate, workcoordsystem id of second mate, flip type of second mate, reoriented type of second mate ],
1259
+ * xOffset,
1260
+ * yOffset,
1261
+ * zOffset
1262
+ * ]
1263
+ */
1264
+ getConstraint: (refId: VID, constrName?: string) => Promise<ConstraintType>;
1265
+ /**
1266
+ * Returns the fastened constraint of given instance or assembly id with specified name.
1267
+ * @param id id of the instance or assembly to look for the constraint
1268
+ * @param constrName name of the constraint to look for
1269
+ * @example // tbd
1270
+ * @return found fastened constraint as object.
1271
+ */
1272
+ getFastenedConstraint: (id: VID, constrName: string) => Promise<FastenedConstraintType>;
1273
+ /**
1274
+ * Returns the fastened origin constraint of given instance or assembly with specified name.
1275
+ * @param id id of the instance or assembly to look for the constraint
1276
+ * @param constrName name of the constraint to look for
1277
+ * @example // tbd
1278
+ * @return found fastened origin constraint as object.
1279
+ */
1280
+ getFastenedOriginConstraint: (id: VID, constrName: string) => Promise<FastenedOriginConstraintType>;
1281
+ /**
1282
+ * Returns the revolute constraint of given instance or assembly with specified name.
1283
+ * @param id id of the instance or assembly to look for the constraint
1284
+ * @param constrName name of the constraint to look for
1285
+ * @example // tbd
1286
+ * @return found revolute constraint as object.
1287
+ */
1288
+ getRevoluteConstraint: (id: VID, constrName: string) => Promise<RevoluteConstraintType>;
1289
+ /**
1290
+ * Returns the slider constraint of given instance or assembly with specified name.
1291
+ * @param id id of the instance or assembly to look for the constraint
1292
+ * @param constrName name of the constraint to look for
1293
+ * @example // tbd
1294
+ * @return found slider constraint as object.
1295
+ */
1296
+ getSliderConstraint: (id: VID, constrName: string) => Promise<SliderConstraintType>;
1297
+ /**
1298
+ * Returns the planar constraint of given instance or assembly with specified name.
1299
+ * @param id id of the instance or assembly to look for the constraint
1300
+ * @param constrName name of the constraint to look for
1301
+ * @example // tbd
1302
+ * @return found planar constraint as object.
1303
+ */
1304
+ getPlanarConstraint: (id: VID, constrName: string) => Promise<PlanarConstraintType>;
1305
+ /**
1306
+ * Returns the parallel constraint of given instance or assembly with specified name.
1307
+ * @param id id of the instance or assembly to look for the constraint
1308
+ * @param constrName name of the constraint to look for
1309
+ * @example // tbd
1310
+ * @return found parallel constraint as object.
1311
+ */
1312
+ getParallelConstraint: (id: VID, constrName: string) => Promise<ParallelConstraintType>;
1313
+ /**
1314
+ * Returns the cylindrical constraint of given instance or assembly with specified name.
1315
+ * @param id id of the instance or assembly to look for the constraint
1316
+ * @param constrName name of the constraint to look for
1317
+ * @example // tbd
1318
+ * @return found cylindrical constraint as object.
1319
+ */
1320
+ getCylindricalConstraint: (id: VID, constrName: string) => Promise<CylindricalConstraintType>;
1321
+ /**
1322
+ * Returns the group constraint of given instance or assembly with specified name.
1323
+ * @param id id of the instance or assembly to look for the constraint
1324
+ * @param constrName name of the constraint to look for
1325
+ * @example // tbd
1326
+ * @return found group constraint as object.
1327
+ */
1328
+ getGroupConstraint: (id: VID, constrName: string) => Promise<GroupConstraintType>;
1329
+ /**
1330
+ * Returns the linear pattern constraint of given instance or assembly with specified name.
1331
+ * @param id id of the instance or assembly to look for the constraint
1332
+ * @param constrName name of the constraint to look for
1333
+ * @example // tbd
1334
+ * @return found linear pattern constraint as object.
1335
+ */
1336
+ getLinearPatternConstraint: (id: VID, constrName: string) => Promise<LinearPatternConstraintType>;
1337
+ /**
1338
+ * Returns the circular pattern constraint of given instance or assembly with specified name.
1339
+ * @param id id of the instance or assembly to look for the constraint
1340
+ * @param constrName name of the constraint to look for
1341
+ * @example // tbd
1342
+ * @return found circular pattern constraint as object.
1343
+ */
1344
+ getCircularPatternConstraint: (id: VID, constrName: string) => Promise<CircularPatternConstraintType>;
1345
+ /**
1346
+ * Returns the id of the feature / operation with name = featureName. The feature can then
1347
+ * be used for further operations, like boolean, transformations and so on.
1348
+ * @param partId id of the part where to look for the feature / operation
1349
+ * @param featureName name of the feature to look for
1350
+ * @example // tbd
1351
+ * @return id of the feature / operation
1352
+ */
1353
+ getFeatureByName: (partId: VID, featureName: string) => ID;
1354
+ /**
1355
+ * Returns an object containing the center of gravity and the volume of the given
1356
+ * product, instance or solid. Depending on the input parameter the calculations were made
1357
+ * on a single solid, a part, a subassembly, the whole model, ... E.g. the center of gravity of
1358
+ * a root assembly, will be the sum of all solid's center of gravity over the whole assembly structure
1359
+ *
1360
+ * @param id id of the part, assembly, instance or solid we want the information from
1361
+ * @example // tbd
1362
+ * @return object containing the geometry information
1363
+ */
1364
+ getGeometryInformation: (id: VID) => Promise<ModelInfo | null>;
1365
+ /**
1366
+ * Writes the current drawing to a stream and returns the data.
1367
+ *
1368
+ * Important notes about the ofb format:
1369
+ * - It contains binary geometry blocks.
1370
+ * - Do not try to convert it to text, the geometry blocks will get damaged!
1371
+ *
1372
+ * @param type type to write
1373
+ * @example // tbd
1374
+ * @return stream data
1375
+ */
1376
+ save: (type: 'ofb' | 'stp') => Promise<Uint8Array | null>;
1377
+ /**
1378
+ * Writes the current drawing to a stream and POSTs the result to the given url.
1379
+ * @param url The url to POST the model to.
1380
+ * @param filetype The file type be saved (ofb, stp).
1381
+ * @example // tbd
1382
+ * @return true if saving was successful
1383
+ */
1384
+ saveToUrl: (url: string, filetype: 'ofb' | 'stp') => Promise<boolean>;
1385
+ /**
1386
+ * Loads the given buffer.
1387
+ * @param content data as arraybuffer
1388
+ * @param type type of the data to load
1389
+ * @param options optional object containing ident property to define an identifier for the loaded root product
1390
+ * @example // tbd
1391
+ * @return array containing the id of the loaded product in the file
1392
+ */
1393
+ load: (content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
1394
+ ident?: ObjectIdent;
1395
+ }) => Promise<number[] | null>;
1396
+ /**
1397
+ * Loads from the given url.
1398
+ * @param url The url to load data from.
1399
+ * @param filetype The type of data delivered by the url (ofb, stp).
1400
+ * @param options optional object containing ident property to define an identifier for the loaded root product
1401
+ * @example // tbd
1402
+ * @return array containing the id of the loaded product from url
1403
+ */
1404
+ loadFromUrl: (url: string, filetype: 'ofb' | 'stp', options?: {
1405
+ ident?: ObjectIdent;
1406
+ }) => Promise<number[] | null>;
1407
+ /**
1408
+ * Loads a product into the current drawing and adds it to the part- or assembly container.
1409
+ * @param content data as arraybuffer
1410
+ * @param type type of the data to load
1411
+ * @param options optional object containing ident property to define an identifier for the loaded product
1412
+ * @example
1413
+ * // Loads an existing product
1414
+ * const part = api.loadProduct(arraybuffer, 'ofb')
1415
+ * const geoms = await api.createBufferGeometry(part)
1416
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1417
+ * @return array containing the id of the loaded products
1418
+ */
1419
+ loadProduct: (content: ArrayBuffer, type: 'ofb' | 'stp', options?: {
1420
+ ident?: ObjectIdent;
1421
+ }) => Promise<number[] | null>;
1422
+ /**
1423
+ * Loads a product from the given URL into the current drawing and adds it to the part- or assembly container.
1424
+ * @param url The url to load data from.
1425
+ * @param filetype The type of data delivered by the url ('ofb', 'stp').
1426
+ * @param options optional object containing ident property, to define a identifier for the loaded product
1427
+ * @example // tbd
1428
+ * @return array containing the id of the loaded products
1429
+ */
1430
+ loadProductFromUrl: (url: string, filetype: 'ofb' | 'stp', options?: {
1431
+ ident?: ObjectIdent;
1432
+ }) => Promise<number[] | null>;
1433
+ /**
1434
+ * Creates a import feature operation and appends geometry to it. This method can be used to import specific geometry
1435
+ * which can be used for further operations like boolean, translations and so on.
1436
+ * @param partId id of the part where to add the new feature
1437
+ * @param content data buffer to add to the import feature
1438
+ * @param format the content format
1439
+ * @param name optional name for the feature, default = 'Import'
1440
+ * @example // tbd
1441
+ * @return id of the import feature operation
1442
+ */
1443
+ importFeature: (partId: VID, content: ArrayBuffer, format: 'stp' | 'step', name?: string) => ID;
1444
+ /**
1445
+ * Removes instances from root assembly, other instances or assembly templates.
1446
+ * @param instances array of instance objects. See following parameter descriptions.
1447
+ * @param id id, identifier or name of the instance to remove
1448
+ * @example // tbd
1449
+ */
1450
+ removeInstances: (...instances: {
1451
+ id: VID | ObjectIdent;
1452
+ }[]) => Promise<void>;
1453
+ /**
1454
+ * Transforms instances by the given transformation.
1455
+ * The transformations are local to the instances parent, which is an assembly.
1456
+ * @param instances array of instance objects. See following descriptions.
1457
+ * @param id id, identifier or name of the instance to transform
1458
+ * @param transformation transformation (origin, xDir, yDir) of the instance local to the owner.
1459
+ * @example // tbd
1460
+ */
1461
+ transformInstances: (...instances: {
1462
+ id: VID | ObjectIdent;
1463
+ transformation: Transform;
1464
+ }[]) => Promise<void>;
1465
+ /**
1466
+ * Creates a translate operation
1467
+ * @param partId id ot the part where features will be translated
1468
+ * @param operations ids of the operations which are used for this translate operation,
1469
+ * e.g. box, extrusion, chamfer operation
1470
+ * @param references references which define the direction of translation. E.g workaxis, 2 workpoints,..
1471
+ * @param inverted flag if direction is inverted or not
1472
+ * @param distance distance of translation
1473
+ * @example // tbd
1474
+ * @return id of the translate operation
1475
+ */
1476
+ translate: (partId: VID, operations: VID[], references: VID[], inverted: 0 | 1, distance: number | string) => ID;
1477
+ /**
1478
+ * Updates a already created translation. To update value will be distance of translation
1479
+ * @deprecated use translate() instead, updateTranslate() will be removed in a future release.
1480
+ * @param translationId id of the translation (feature id) which will be updated
1481
+ * @param distance new value for distance
1482
+ * @example // tbd
1483
+ */
1484
+ updateTranslate: (translationId: VID, distance: number) => Promise<void>;
1485
+ /**
1486
+ * Returns found vertices, edges or faces depending on
1487
+ * given type and points. Given points define where to look for elements.
1488
+ * @deprecated use findGeometry() instead, pick() will be removed in a future release.
1489
+ * @param partId id of the part to pick elements
1490
+ * @param type type of element to pick
1491
+ * @param points points containing 3D coordinates to look for possible element
1492
+ * @example
1493
+ * // Creates a cylinder an puts a fillet on the top edge
1494
+ * const part = api.createPart('Part')
1495
+ * api.cylinder(part, [], 10, 100)
1496
+ * const edges = await api.pick(part, 'edge', [{ x: 0, y: 0, z: 100 }])
1497
+ * api.fillet(part, edges, 2)
1498
+ * const geoms = await api.createBufferGeometry(part)
1499
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1500
+ * @return array containing ids of found geometries
1501
+ */
1502
+ pick: (partId: VID, type: 'vertex' | 'edge' | 'face', points: Vec[]) => IDs;
1503
+ /**
1504
+ * Updates multiple expressions in different parts at once
1505
+ * @param expressions array of expression objects containing the part id and the expression to set
1506
+ * @param partId id, identifier or name of part to update expression
1507
+ * @param members array of members to update which contain a name and a value. Value can be an expression, e.g. '2 * laenge'
1508
+ * @example // tbd
1509
+ * @returns true, if updating expressions in all parts was successfull
1510
+ */
1511
+ setExpressions: (...expressions: {
1512
+ partId: VID | ObjectIdent;
1513
+ members: {
1514
+ name: string;
1515
+ value: number | string;
1516
+ }[];
1517
+ }[]) => Promise<boolean>;
1518
+ /**
1519
+ * Creates a mirror operation.
1520
+ * Mirrors the entities of an operation at the position of the plane reference
1521
+ * @param partId id of the part where the mirror will be created
1522
+ * @param operations ids of the operations which are used for this mirror operation,
1523
+ * e.g. box, extrusion, chamfer operation
1524
+ * @param references id of the references which will be used to mirror (e.g. Workplane)
1525
+ */
1526
+ mirror: (partId: VID, operations: VID[], references: VID[]) => Promise<ObjectID | null>;
1527
+ /**
1528
+ * Removes the given operations or the operations which are added after 'toOperation' in history, depending
1529
+ * on whether operations or toOperation parameter is given.
1530
+ * @param operations ids of all to remove operations. First element in the array will be removed first.
1531
+ * This means operations which depend on each other, need to be removed from newest to oldest.
1532
+ * @param toOperation all operations, from rollback bar until the id of this operation, will be deleted
1533
+ */
1534
+ removeOperations: (operations: VID[], toOperation: VID) => Promise<void>;
1535
+ /**
1536
+ * Creates and returns the mate path as array from the given instance id up to the current instance.
1537
+ * This helps to get the right path to set constraints between instances which are located in
1538
+ * nested assemblies.
1539
+ * @param instanceId id of the instance to get the mate path from
1540
+ * @return array containing the ids as a path from given instance to current instance
1541
+ */
1542
+ getMatePath: (instanceId: VID | ObjectIdent) => Promise<ObjectID[]>;
1543
+ /**
1544
+ * Creates a slice operation.
1545
+ * Slices the entities of the given operations by the given reference.
1546
+ * @param partId id of the part where the slice will be created
1547
+ * @param operations ids of the operations which are used for this slice operation,
1548
+ * e.g. box, extrusion, chamfer operation
1549
+ * @param reference id of the workplane reference to use for the slice
1550
+ * @param sideFlag flag to toggle which side of the slice will be kept
1551
+ * @return id of the slice operation
1552
+ */
1553
+ slice: (partId: VID, operations: VID[], reference: VID, sideFlag: boolean) => ID;
1554
+ /**
1555
+ * Creates a slice by sheet operation.
1556
+ * Slices the entity of an operation with a sheet entity of another operation
1557
+ * @param partId id of the part where the slice will be created
1558
+ * @param operationToSlice id of the operation which will be sliced in this slice by sheet operation
1559
+ * @param operationOfSheet id of the operation which is used as the slice
1560
+ * @param sideFlag flag to toggle which side of the slice will be kept
1561
+ * @return id of the slice by sheet operation
1562
+ */
1563
+ sliceBySheet: (partId: VID, operationToSlice: VID, operationOfSheet: VID, sideFlag: boolean) => ID;
1564
+ /**
1565
+ * Creates a twist operation
1566
+ * @param partId Id of the part to create the twist in.
1567
+ * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
1568
+ * @param type Type of twist (up, down, symmetric, custom)
1569
+ * @param limit1 Start of twist (0 = start at sketch, only for type custom necessary)
1570
+ * @param limit2 End of twist, which is actually the height
1571
+ * @param direction Direction of twist (only for type custom necessary)
1572
+ * @param twistAngle Twist angle of the sketch along height of twist
1573
+ * @param twistCenter Point which together with direction defines the twist axis (only for type custom necessary).
1574
+ * The actual center/start of the twist is where the defined twist axis intersects the sketch plane. For other types than
1575
+ * custom, the center will be the bary center of the selected region.
1576
+ * @param capEnds If true, ends will be capped, else a sheet will be created
1577
+ * @return id of the twist operation
1578
+ */
1579
+ twist: (param: {
1580
+ partId: VID;
1581
+ sketchOrRegionIds: VID | VIDs;
1582
+ type: ExtrusionType;
1583
+ limit1: number | string;
1584
+ limit2: number | string;
1585
+ direction?: Vec<number | string>;
1586
+ twistAngle: number | string;
1587
+ twistCenter?: Vec<number | string>;
1588
+ capEnds: 0 | 1;
1589
+ }) => ID;
1590
+ };
1591
+ export declare class History {
1592
+ drawingId: DrawingID | null;
1593
+ queue: Promise<number>;
1594
+ constructor();
1595
+ resolve(callback: (...results: any) => Promise<any>, ...args: any[]): Promise<any>;
1596
+ init(callback: (api: ApiHistory) => void): () => Promise<void>;
1597
+ destroy(): void;
1598
+ }
1599
+ export declare class history extends History {
1600
+ constructor();
1601
+ }
1602
+ declare type VID = ObjectID | null | Promise<ObjectID | null>;
1603
+ declare type VIDs = ObjectID[] | Promise<ObjectID[]>;
1604
+ declare type ID = Promise<ObjectID | null>;
1605
+ declare type IDs = Promise<ObjectID[]>;
1606
+ declare type Point = {
1607
+ x: number;
1608
+ y: number;
1609
+ z: number;
1610
+ };
1611
+ declare type ModelInfo = {
1612
+ centerOfGravity: Vec;
1613
+ volume: number;
1614
+ };
1615
+ declare type MateParam = {
1616
+ matePath: VID[];
1617
+ wcsId: VID;
1618
+ flip: FlipType;
1619
+ reoriented: ReorientedType;
1620
+ };
1621
+ declare type GrT = GraphicType.POINT | GraphicType.LINE | GraphicType.ARC | GraphicType.CIRCLE | GraphicType.PLANE | GraphicType.CYLINDER | GraphicType.CONE | GraphicType.SPHERE | GraphicType.NURBSCURVE | GraphicType.NURBSSURFACE;
1622
+ /**
1623
+ * Array type containing three points of type Point = {x: number, y: number, z: number}.
1624
+ * - [0] = origin position containing x-, y- and z-coordinates
1625
+ * - [1] = x-direction vector
1626
+ * - [2] = y-direction vector
1627
+ */
1628
+ export declare type Transform = [Point, Point, Point];
1629
+ export declare type DimensionType = DimensionParam<VID, Vec>;
1630
+ export declare type ViewOptionsType = {
1631
+ /** optional color (autocad color index) to set for the 2d view, if color = 256 then color will be taken from layer definition */
1632
+ color?: number;
1633
+ /** optional layer to set for the 2d view, layers are defined in the dxf file */
1634
+ layer?: string;
1635
+ };
1636
+ export declare type FastenedOriginConstraintType = {
1637
+ /** id of the constraint */
1638
+ constrId: VID;
1639
+ /** first mate constraint */
1640
+ mate1: MateParam;
1641
+ /** offset in x-direction */
1642
+ xOffset: number | string;
1643
+ /** offset in y-direction */
1644
+ yOffset: number | string;
1645
+ /** offset in z-direction */
1646
+ zOffset: number | string;
1647
+ /** rotation around x-axis */
1648
+ xRotation?: number | string;
1649
+ /** rotation around y-axis */
1650
+ yRotation?: number | string;
1651
+ /** rotation around z-axis */
1652
+ zRotation?: number | string;
1653
+ };
1654
+ export declare type FastenedConstraintType = {
1655
+ /** id of the constraint */
1656
+ constrId: VID;
1657
+ /** first mate constraint */
1658
+ mate1: MateParam;
1659
+ /** second mate constraint */
1660
+ mate2: MateParam;
1661
+ /** offset in x-direction */
1662
+ xOffset: number | string;
1663
+ /** offset in y-direction */
1664
+ yOffset: number | string;
1665
+ /** offset in z-direction */
1666
+ zOffset: number | string;
1667
+ /** rotation around x-axis */
1668
+ xRotation?: number | string;
1669
+ /** rotation around y-axis */
1670
+ yRotation?: number | string;
1671
+ /** rotation around z-axis */
1672
+ zRotation?: number | string;
1673
+ };
1674
+ export declare type RevoluteConstraintType = {
1675
+ /** id of the constraint */
1676
+ constrId: VID;
1677
+ /** first mate constraint */
1678
+ mate1: MateParam;
1679
+ /** second mate constraint */
1680
+ mate2: MateParam;
1681
+ /** offset in z-direction */
1682
+ zOffset: number | string;
1683
+ /** min and max limit for the rotation around z-Axis */
1684
+ zRotationLimits: LimitsParam;
1685
+ };
1686
+ export declare type SliderConstraintType = {
1687
+ /** id of the constraint */
1688
+ constrId: VID;
1689
+ /** first mate constraint */
1690
+ mate1: MateParam;
1691
+ /** second mate constraint */
1692
+ mate2: MateParam;
1693
+ /** offset in x-direction */
1694
+ xOffset: number | string;
1695
+ /** offset in y-direction */
1696
+ yOffset: number | string;
1697
+ /** min and max limit for the z-offset */
1698
+ zOffsetLimits: LimitsParam;
1699
+ };
1700
+ export declare type PlanarConstraintType = {
1701
+ /** id of the constraint */
1702
+ constrId: VID;
1703
+ /** first mate constraint */
1704
+ mate1: MateParam;
1705
+ /** second mate constraint */
1706
+ mate2: MateParam;
1707
+ /** offset in z-direction */
1708
+ zOffset: number | string;
1709
+ /** min and max limit for the x-offset */
1710
+ xOffsetLimits: LimitsParam;
1711
+ /** min and max limit for the y-offset */
1712
+ yOffsetLimits: LimitsParam;
1713
+ /** min and max limit for the rotation around z-Axis */
1714
+ zRotationLimits: LimitsParam;
1715
+ };
1716
+ export declare type ParallelConstraintType = {
1717
+ /** id of the constraint */
1718
+ constrId: VID;
1719
+ /** first mate constraint */
1720
+ mate1: MateParam;
1721
+ /** second mate constraint */
1722
+ mate2: MateParam;
1723
+ /** min and max limit for the x-offset */
1724
+ xOffsetLimits: LimitsParam;
1725
+ /** min and max limit for the y-offset */
1726
+ yOffsetLimits: LimitsParam;
1727
+ /** min and max limit for the z-offset */
1728
+ zOffsetLimits: LimitsParam;
1729
+ /** min and max limit for the rotation around z-Axis */
1730
+ zRotationLimits: LimitsParam;
1731
+ };
1732
+ export declare type CylindricalConstraintType = {
1733
+ /** id of the constraint */
1734
+ constrId: VID;
1735
+ /** first mate constraint */
1736
+ mate1: MateParam;
1737
+ /** second mate constraint */
1738
+ mate2: MateParam;
1739
+ /** min and max limit for the z-offset */
1740
+ zOffsetLimits: LimitsParam;
1741
+ /** min and max limit for the rotation around z-Axis */
1742
+ zRotationLimits: LimitsParam;
1743
+ };
1744
+ export declare type GroupConstraintType = {
1745
+ /** id of the constraint */
1746
+ constrId: VID;
1747
+ /** ids of instances to be grouped */
1748
+ instanceIds: VID[];
1749
+ };
1750
+ export declare type LinearPatternConstraintType = {
1751
+ /** id of the constraint */
1752
+ constrId: VID;
1753
+ /** id of the instance to be copied */
1754
+ instanceId: VID;
1755
+ /** first mate constraint (z-axis sets the first direction) */
1756
+ mate1: MateParam;
1757
+ /** number of copies over the first direction (set by z-axis of mate1) */
1758
+ firstDirInstanceCount: number | string;
1759
+ /** distance between copies over the first direction (set by z-axis of mate1) */
1760
+ firstDirDistance: number | string;
1761
+ /** second mate constraint (z-axis sets the second direction) */
1762
+ mate2: MateParam;
1763
+ /** number of copies over the second direction (set by z-axis of mate2) */
1764
+ secondDirInstanceCount: number | string;
1765
+ /** number of copies over the second direction (set by z-axis of mate2) */
1766
+ secondDirDistance: number | string;
1767
+ };
1768
+ export declare type CircularPatternConstraintType = {
1769
+ /** id of the constraint */
1770
+ constrId: VID;
1771
+ /** id of the instance to be copied */
1772
+ instanceId: VID;
1773
+ /** first mate constraint (z-axis sets the rotation axis) */
1774
+ mate1: MateParam;
1775
+ /** total number of copies (clockwise around the axis set by z-axis of mate1) */
1776
+ instanceCount: number | string;
1777
+ /** angle between copies (clockwise around the axis set by z-axis of mate1) */
1778
+ angle: number | string;
1779
+ /** offset between copies (set by z-axis of mate2) */
1780
+ offset: number | string;
1781
+ };
1782
+ /**
1783
+ * Information about constraint.
1784
+ * [
1785
+ * constraintId,
1786
+ * [ path to product reference,
1787
+ * workcoordsystem id of 1st mate,
1788
+ * flip type of 1st mate,
1789
+ * reoriented type of 1st mate ],
1790
+ * [ path to product reference,
1791
+ * workcoordsystem id of 2nd mate,
1792
+ * flip type of 2nd mate,
1793
+ * reoriented type of 2nd mate ],
1794
+ * xOffset,
1795
+ * yOffset,
1796
+ * zOffset
1797
+ * ]
1798
+ */
1799
+ export declare type ConstraintType = [
1800
+ number,
1801
+ [
1802
+ number[],
1803
+ number,
1804
+ number,
1805
+ number
1806
+ ],
1807
+ [
1808
+ number[],
1809
+ number,
1810
+ number,
1811
+ number
1812
+ ],
1813
+ number,
1814
+ number,
1815
+ number,
1816
+ number,
1817
+ number,
1818
+ number
1819
+ ];
1820
+ /**
1821
+ * General, generic vector type representing following types:
1822
+ * - Value[]
1823
+ * - {x: Value, y: Value, z: Value}
1824
+ * - THREE.Vector [See threejs documentation](https://threejs.org/docs/?q=Vect#api/en/math/Vector3)
1825
+ * - THREE.Euler [See threejs documentation](https://threejs.org/docs/?q=Euler#api/en/math/Euler)
1826
+ */
1827
+ export declare type Vec<Value = number> = Value[] | {
1828
+ x: Value;
1829
+ y: Value;
1830
+ z: Value;
1831
+ } | THREE.Vector3 | THREE.Euler;
1832
+ export {};