@buerli.io/headless 1.0.0 → 1.0.1-beta.2

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