@buerli.io/headless 0.9.1-beta.1 → 0.11.0

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