@buerli.io/headless 0.13.1-beta.4 → 0.13.1-beta.7.apiversion
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.
- package/build/cjs/history.js +145 -142
- package/build/cjs/index.js +8 -8
- package/build/cjs/solid.js +36 -36
- package/build/esm/history.js +146 -143
- package/build/esm/index.js +1 -1
- package/build/esm/solid.js +37 -37
- package/build/types/history.d.ts +2 -2
- package/build/types/index.d.ts +1 -1
- package/build/types/solid.d.ts +2 -1
- package/package.json +2 -2
package/build/esm/history.js
CHANGED
|
@@ -6,21 +6,12 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
6
6
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
7
|
};
|
|
8
8
|
/* eslint-disable max-lines */
|
|
9
|
-
import {
|
|
9
|
+
import { api as ccApi, CCClasses, ccUtils, DataType, SVGModusType, Connection, } from '@buerli.io/classcad';
|
|
10
10
|
import { api, getDrawing, MathUtils, BuerliScope, createInfo, Measure, } from '@buerli.io/core';
|
|
11
11
|
import { Group, Matrix4, Mesh, MeshStandardMaterial, Scene } from 'three';
|
|
12
12
|
import { mergeBufferGeometries } from 'three-stdlib';
|
|
13
13
|
import { waitForSelect } from './utils/selection';
|
|
14
14
|
import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
|
|
15
|
-
const featureAPI = ccAPI.feature;
|
|
16
|
-
const sketcherAPI = ccAPI.sketcher;
|
|
17
|
-
const baseModelerAPI = ccAPI.baseModeler;
|
|
18
|
-
const assemblyBuilderAPI = ccAPI.assemblyBuilder;
|
|
19
|
-
const drawing2DAPI = ccAPI.drawing2D;
|
|
20
|
-
const geometryAPI = ccAPI.geometry;
|
|
21
|
-
const baseUtils = ccUtils.base;
|
|
22
|
-
const asmUtils = ccUtils.assembly;
|
|
23
|
-
const partUtils = ccUtils.part;
|
|
24
15
|
/**
|
|
25
16
|
* Helps to create the buffer geometry of the given object recursively.
|
|
26
17
|
* @param object object to create the buffergeometry from
|
|
@@ -31,6 +22,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
|
|
|
31
22
|
const tree = cDrawing.structure.tree;
|
|
32
23
|
if (object.link || object.solids) {
|
|
33
24
|
// Part
|
|
25
|
+
const baseModeler = ccApi(drawingId).v0.baseModeler;
|
|
34
26
|
const solids = object.link ? tree[object.link].solids : object.solids;
|
|
35
27
|
if (solids != undefined) {
|
|
36
28
|
let geometries = [];
|
|
@@ -42,7 +34,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
|
|
|
42
34
|
}
|
|
43
35
|
else {
|
|
44
36
|
// else get visualisation from classcad
|
|
45
|
-
await
|
|
37
|
+
await baseModeler.requestVisualisationOfEntities([solid]);
|
|
46
38
|
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
47
39
|
cachedSolid = cDrawing.geometry.cache[solid];
|
|
48
40
|
if (cachedSolid) {
|
|
@@ -86,6 +78,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
|
|
|
86
78
|
const tree = cDrawing.structure.tree;
|
|
87
79
|
if (object.link || object.solids) {
|
|
88
80
|
// Part
|
|
81
|
+
const baseModeler = ccApi(drawingId).v0.baseModeler;
|
|
89
82
|
const entities = object.link ? tree[object.link].solids : object.solids;
|
|
90
83
|
if (entities != undefined) {
|
|
91
84
|
const part = new Group();
|
|
@@ -98,7 +91,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
|
|
|
98
91
|
let cachedEntity = cDrawing.geometry.cache[entity];
|
|
99
92
|
if (!cachedEntity) {
|
|
100
93
|
// else get visualisation from classcad
|
|
101
|
-
await
|
|
94
|
+
await baseModeler.requestVisualisationOfEntities([entity]);
|
|
102
95
|
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
103
96
|
cachedEntity = cDrawing.geometry.cache[entity];
|
|
104
97
|
}
|
|
@@ -226,15 +219,25 @@ export class History {
|
|
|
226
219
|
}
|
|
227
220
|
init(callback) {
|
|
228
221
|
const promise = new Promise(async (resolve, reject) => {
|
|
229
|
-
const drawingId = await
|
|
222
|
+
const drawingId = await Connection.create();
|
|
230
223
|
if (!drawingId)
|
|
231
|
-
throw new Error('Drawing could not be created');
|
|
224
|
+
throw new Error('Connection/Drawing could not be created');
|
|
232
225
|
this.drawingId = drawingId;
|
|
226
|
+
const cc = ccApi(drawingId);
|
|
227
|
+
const featureAPI = cc.v0.feature;
|
|
228
|
+
const sketcherAPI = cc.v0.sketcher;
|
|
229
|
+
const baseModelerAPI = cc.v0.baseModeler;
|
|
230
|
+
const assemblyBuilderAPI = cc.v0.assemblyBuilder;
|
|
231
|
+
const drawing2DAPI = cc.v0.drawing2D;
|
|
232
|
+
const geometryAPI = cc.v0.geometry;
|
|
233
|
+
const baseUtils = ccUtils.base;
|
|
234
|
+
const asmUtils = ccUtils.assembly;
|
|
235
|
+
const partUtils = ccUtils.part;
|
|
233
236
|
const publicApi = {
|
|
234
237
|
getDrawingId: () => drawingId,
|
|
235
238
|
getDrawing: () => getDrawing(drawingId),
|
|
236
239
|
getState: () => api.getState(),
|
|
237
|
-
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () =>
|
|
240
|
+
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () => cc.v0.common.setFacetingParameters(distanceTol, angleTol)),
|
|
238
241
|
addInstances: async (...instances) => {
|
|
239
242
|
var e_1, _a;
|
|
240
243
|
const instancesToAdd = [];
|
|
@@ -298,7 +301,7 @@ export class History {
|
|
|
298
301
|
}
|
|
299
302
|
finally { if (e_1) throw e_1.error; }
|
|
300
303
|
}
|
|
301
|
-
return assemblyBuilderAPI.addInstances(
|
|
304
|
+
return assemblyBuilderAPI.addInstances(instancesToAdd);
|
|
302
305
|
},
|
|
303
306
|
addDimensions: async (...dimensions) => {
|
|
304
307
|
var e_2, _a;
|
|
@@ -336,13 +339,13 @@ export class History {
|
|
|
336
339
|
}
|
|
337
340
|
finally { if (e_2) throw e_2.error; }
|
|
338
341
|
}
|
|
339
|
-
return drawing2DAPI.addDimensions(
|
|
342
|
+
return drawing2DAPI.addDimensions(dimParamsToAdd); // TODO v0 typescript error because of DimensionParam
|
|
340
343
|
},
|
|
341
344
|
create2DViews: (productId, viewTypes, viewOptions) => {
|
|
342
345
|
return this.resolve(async ([rProductId]) => {
|
|
343
|
-
const viewIds = await drawing2DAPI.create2DViews(
|
|
346
|
+
const viewIds = await drawing2DAPI.create2DViews(rProductId, viewTypes, viewOptions);
|
|
344
347
|
if (viewIds !== null) {
|
|
345
|
-
await drawing2DAPI.centerAllViews(
|
|
348
|
+
await drawing2DAPI.centerAllViews(rProductId, viewTypes);
|
|
346
349
|
return viewIds;
|
|
347
350
|
}
|
|
348
351
|
return null;
|
|
@@ -350,13 +353,13 @@ export class History {
|
|
|
350
353
|
},
|
|
351
354
|
getBoundaryBoxFromViews: (productId, viewTypes) => {
|
|
352
355
|
return this.resolve(async ([rProductId]) => {
|
|
353
|
-
const bbs = await drawing2DAPI.getBoundaryBoxFromViews(
|
|
356
|
+
const bbs = await drawing2DAPI.getBoundaryBoxFromViews(rProductId, viewTypes);
|
|
354
357
|
return bbs;
|
|
355
358
|
}, productId);
|
|
356
359
|
},
|
|
357
360
|
place2DViews: (productId, viewPositions) => {
|
|
358
361
|
return this.resolve(async ([rProductId]) => {
|
|
359
|
-
return drawing2DAPI.place2DViews(
|
|
362
|
+
return drawing2DAPI.place2DViews(rProductId, viewPositions.map(({ viewType, vector }) => ({
|
|
360
363
|
viewType,
|
|
361
364
|
vector: resolveVec(vector),
|
|
362
365
|
})));
|
|
@@ -364,24 +367,24 @@ export class History {
|
|
|
364
367
|
},
|
|
365
368
|
exportDXF: (productId, dxfTemplateFilename) => {
|
|
366
369
|
return this.resolve(async ([rProductId]) => {
|
|
367
|
-
return drawing2DAPI.exportDXF(
|
|
370
|
+
return drawing2DAPI.exportDXF(rProductId, dxfTemplateFilename);
|
|
368
371
|
}, productId);
|
|
369
372
|
},
|
|
370
373
|
exportSVG: (productId, modus, renderSize, dxfTemplateFilename) => {
|
|
371
374
|
return this.resolve(async ([rProductId]) => {
|
|
372
375
|
modus = modus ? modus : SVGModusType.FIT_WHOLE_DRAWING;
|
|
373
376
|
const renderSizeParam = (renderSize === null || renderSize === void 0 ? void 0 : renderSize.x) && (renderSize === null || renderSize === void 0 ? void 0 : renderSize.y) ? [renderSize.x, renderSize.y] : undefined;
|
|
374
|
-
return drawing2DAPI.exportSVG(
|
|
377
|
+
return drawing2DAPI.exportSVG(rProductId, modus, renderSizeParam, dxfTemplateFilename);
|
|
375
378
|
}, productId);
|
|
376
379
|
},
|
|
377
380
|
removeDimensions: (dimensionIds) => {
|
|
378
381
|
return this.resolve(async ([...rDimensionIds]) => {
|
|
379
|
-
return drawing2DAPI.removeDimensions(
|
|
382
|
+
return drawing2DAPI.removeDimensions(rDimensionIds);
|
|
380
383
|
}, ...dimensionIds);
|
|
381
384
|
},
|
|
382
385
|
linearPattern: (partId, operations, references1, params1, references2, params2) => {
|
|
383
386
|
return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
|
|
384
|
-
const patternId = await featureAPI.createFeature(
|
|
387
|
+
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCLinearPattern, 'LinearPattern');
|
|
385
388
|
if (patternId != null) {
|
|
386
389
|
// entities
|
|
387
390
|
const cDrawing = await getDrawing(drawingId);
|
|
@@ -433,7 +436,7 @@ export class History {
|
|
|
433
436
|
else {
|
|
434
437
|
refs2 = null;
|
|
435
438
|
}
|
|
436
|
-
await featureAPI.updatePattern(
|
|
439
|
+
await featureAPI.updatePattern(patternId, entArray, refs1, params1Param, refs2, params2Param);
|
|
437
440
|
return patternId;
|
|
438
441
|
}
|
|
439
442
|
return null;
|
|
@@ -441,7 +444,7 @@ export class History {
|
|
|
441
444
|
},
|
|
442
445
|
circularPattern: (partId, operations, references, params) => {
|
|
443
446
|
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
444
|
-
const patternId = await featureAPI.createFeature(
|
|
447
|
+
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCCircularPattern, 'CircularPattern');
|
|
445
448
|
if (patternId != null) {
|
|
446
449
|
// entities
|
|
447
450
|
const cDrawing = await getDrawing(drawingId);
|
|
@@ -461,7 +464,7 @@ export class History {
|
|
|
461
464
|
params.merged,
|
|
462
465
|
];
|
|
463
466
|
rReferences = Array.isArray(rReferences) ? rReferences : [rReferences];
|
|
464
|
-
await featureAPI.updatePattern(
|
|
467
|
+
await featureAPI.updatePattern(patternId, entArray, rReferences, paramsParam, null, null);
|
|
465
468
|
return patternId;
|
|
466
469
|
}
|
|
467
470
|
return null;
|
|
@@ -469,7 +472,7 @@ export class History {
|
|
|
469
472
|
},
|
|
470
473
|
extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
|
|
471
474
|
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
472
|
-
const extrusion = await featureAPI.createFeature(
|
|
475
|
+
const extrusion = await featureAPI.createFeature(rPartId, CCClasses.CCExtrusion, 'Extrusion');
|
|
473
476
|
if (extrusion) {
|
|
474
477
|
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
475
478
|
? rSketchOrRegionIds
|
|
@@ -486,7 +489,7 @@ export class History {
|
|
|
486
489
|
value: resDirection,
|
|
487
490
|
isExpr: typeof resDirection === 'string',
|
|
488
491
|
};
|
|
489
|
-
await featureAPI.updateExtrusion(
|
|
492
|
+
await featureAPI.updateExtrusion(extrusion, resSketchOrRegionIds, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
|
|
490
493
|
return extrusion;
|
|
491
494
|
}
|
|
492
495
|
}
|
|
@@ -494,7 +497,7 @@ export class History {
|
|
|
494
497
|
},
|
|
495
498
|
revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
|
|
496
499
|
return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
|
|
497
|
-
const revolve = await featureAPI.createFeature(
|
|
500
|
+
const revolve = await featureAPI.createFeature(rPartId, CCClasses.CCRevolve, 'Revolve');
|
|
498
501
|
if (revolve) {
|
|
499
502
|
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
500
503
|
? rSketchOrRegionIds
|
|
@@ -502,7 +505,7 @@ export class History {
|
|
|
502
505
|
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
503
506
|
const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
|
|
504
507
|
const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
|
|
505
|
-
await featureAPI.updateRevolve(
|
|
508
|
+
await featureAPI.updateRevolve(revolve, resSketchOrRegionIds, rAxisIds, angle1Param, angle2Param, inverted);
|
|
506
509
|
return revolve;
|
|
507
510
|
}
|
|
508
511
|
}
|
|
@@ -518,9 +521,9 @@ export class History {
|
|
|
518
521
|
entArray.push(entities[0]);
|
|
519
522
|
}
|
|
520
523
|
}
|
|
521
|
-
const boolId = await featureAPI.createFeature(
|
|
524
|
+
const boolId = await featureAPI.createFeature(rPartId, CCClasses.CCUnion, 'Union');
|
|
522
525
|
if (boolId != null) {
|
|
523
|
-
await featureAPI.updateBooleanOperation(
|
|
526
|
+
await featureAPI.updateBooleanOperation(boolId, type, entArray);
|
|
524
527
|
return boolId;
|
|
525
528
|
}
|
|
526
529
|
return null;
|
|
@@ -528,12 +531,12 @@ export class History {
|
|
|
528
531
|
},
|
|
529
532
|
box: (partId, references, width, length, height) => {
|
|
530
533
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
531
|
-
const boxId = await featureAPI.createFeature(
|
|
534
|
+
const boxId = await featureAPI.createFeature(rPartId, CCClasses.CCBox, 'Box');
|
|
532
535
|
if (boxId != null) {
|
|
533
536
|
const widthParam = { value: width, isExpr: typeof width === 'string' };
|
|
534
537
|
const lengthParam = { value: length, isExpr: typeof length === 'string' };
|
|
535
538
|
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
536
|
-
await featureAPI.updateBox(
|
|
539
|
+
await featureAPI.updateBox(boxId, rReferences, widthParam, lengthParam, heightParam);
|
|
537
540
|
return boxId;
|
|
538
541
|
}
|
|
539
542
|
return null;
|
|
@@ -541,11 +544,11 @@ export class History {
|
|
|
541
544
|
},
|
|
542
545
|
cylinder: (partId, references, diameter, height) => {
|
|
543
546
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
544
|
-
const cylId = await featureAPI.createFeature(
|
|
547
|
+
const cylId = await featureAPI.createFeature(rPartId, CCClasses.CCCylinder, 'Cylinder');
|
|
545
548
|
if (cylId != null) {
|
|
546
549
|
const diameterParam = { value: diameter, isExpr: typeof diameter === 'string' };
|
|
547
550
|
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
548
|
-
await featureAPI.updateCylinder(
|
|
551
|
+
await featureAPI.updateCylinder(cylId, rReferences, diameterParam, heightParam);
|
|
549
552
|
return cylId;
|
|
550
553
|
}
|
|
551
554
|
return null;
|
|
@@ -556,9 +559,9 @@ export class History {
|
|
|
556
559
|
const dist1Param = { value: dist1, isExpr: typeof dist1 === 'string' };
|
|
557
560
|
const dist2Param = { value: dist2, isExpr: typeof dist2 === 'string' };
|
|
558
561
|
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
559
|
-
const chamferId = await featureAPI.createFeature(
|
|
562
|
+
const chamferId = await featureAPI.createFeature(rPartId, CCClasses.CCChamfer, 'Chamfer');
|
|
560
563
|
if (chamferId != null) {
|
|
561
|
-
await featureAPI.updateChamfer(
|
|
564
|
+
await featureAPI.updateChamfer(chamferId, type, rReferences, dist1Param, dist2Param, angleParam);
|
|
562
565
|
return chamferId;
|
|
563
566
|
}
|
|
564
567
|
return null;
|
|
@@ -566,12 +569,12 @@ export class History {
|
|
|
566
569
|
},
|
|
567
570
|
cone: (partId, references, bDiameter, tDiameter, height) => {
|
|
568
571
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
569
|
-
const coneId = await featureAPI.createFeature(
|
|
572
|
+
const coneId = await featureAPI.createFeature(rPartId, CCClasses.CCCone, 'Cone');
|
|
570
573
|
if (coneId != null) {
|
|
571
574
|
const bDiamParam = { value: bDiameter, isExpr: typeof bDiameter === 'string' };
|
|
572
575
|
const tDiamParam = { value: tDiameter, isExpr: typeof tDiameter === 'string' };
|
|
573
576
|
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
574
|
-
await featureAPI.updateCone(
|
|
577
|
+
await featureAPI.updateCone(coneId, rReferences, bDiamParam, tDiamParam, heightParam);
|
|
575
578
|
return coneId;
|
|
576
579
|
}
|
|
577
580
|
return null;
|
|
@@ -581,7 +584,7 @@ export class History {
|
|
|
581
584
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
582
585
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
583
586
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
584
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
587
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedConstraint, name);
|
|
585
588
|
if (constraintId != null) {
|
|
586
589
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
587
590
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
@@ -589,7 +592,7 @@ export class History {
|
|
|
589
592
|
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
590
593
|
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
591
594
|
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
592
|
-
await assemblyBuilderAPI.updateFastenedConstraints(
|
|
595
|
+
await assemblyBuilderAPI.updateFastenedConstraints([
|
|
593
596
|
{
|
|
594
597
|
constrId: constraintId,
|
|
595
598
|
mate1: { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
@@ -660,12 +663,12 @@ export class History {
|
|
|
660
663
|
}
|
|
661
664
|
finally { if (e_3) throw e_3.error; }
|
|
662
665
|
}
|
|
663
|
-
await assemblyBuilderAPI.updateFastenedConstraints(
|
|
666
|
+
await assemblyBuilderAPI.updateFastenedConstraints(constrToAdd);
|
|
664
667
|
},
|
|
665
668
|
createFastenedOriginConstraint: async (id, mate1, xOffset, yOffset, zOffset, name, xRotation, yRotation, zRotation) => {
|
|
666
669
|
const [rId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId));
|
|
667
670
|
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
668
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
671
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedOriginConstraint, name);
|
|
669
672
|
if (constraintId != null) {
|
|
670
673
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
671
674
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
@@ -673,7 +676,7 @@ export class History {
|
|
|
673
676
|
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
674
677
|
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
675
678
|
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
676
|
-
await assemblyBuilderAPI.updateFastenedOriginConstraints(
|
|
679
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints([
|
|
677
680
|
{
|
|
678
681
|
constrId: constraintId,
|
|
679
682
|
mate1: { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
@@ -736,15 +739,15 @@ export class History {
|
|
|
736
739
|
}
|
|
737
740
|
finally { if (e_4) throw e_4.error; }
|
|
738
741
|
}
|
|
739
|
-
await assemblyBuilderAPI.updateFastenedOriginConstraints(
|
|
742
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints(constraintsToAdd);
|
|
740
743
|
},
|
|
741
744
|
createCylindricalConstraint: async (id, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
|
|
742
745
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
743
746
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
744
747
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
745
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
748
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCylindricalConstraint, name);
|
|
746
749
|
if (constraintId != null) {
|
|
747
|
-
await assemblyBuilderAPI.updateCylindricalConstraints(
|
|
750
|
+
await assemblyBuilderAPI.updateCylindricalConstraints([
|
|
748
751
|
{
|
|
749
752
|
constrId: constraintId,
|
|
750
753
|
mate1: {
|
|
@@ -802,16 +805,16 @@ export class History {
|
|
|
802
805
|
}
|
|
803
806
|
finally { if (e_5) throw e_5.error; }
|
|
804
807
|
}
|
|
805
|
-
await assemblyBuilderAPI.updateCylindricalConstraints(
|
|
808
|
+
await assemblyBuilderAPI.updateCylindricalConstraints(constrToAdd);
|
|
806
809
|
},
|
|
807
810
|
createRevoluteConstraint: async (id, mate1, mate2, zOffset, zRotationLimits, name) => {
|
|
808
811
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
809
812
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
810
813
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
811
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
814
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCRevoluteConstraint, name);
|
|
812
815
|
if (constraintId != null) {
|
|
813
816
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
814
|
-
await assemblyBuilderAPI.updateRevoluteConstraints(
|
|
817
|
+
await assemblyBuilderAPI.updateRevoluteConstraints([
|
|
815
818
|
{
|
|
816
819
|
constrId: constraintId,
|
|
817
820
|
mate1: {
|
|
@@ -870,17 +873,17 @@ export class History {
|
|
|
870
873
|
}
|
|
871
874
|
finally { if (e_6) throw e_6.error; }
|
|
872
875
|
}
|
|
873
|
-
await assemblyBuilderAPI.updateRevoluteConstraints(
|
|
876
|
+
await assemblyBuilderAPI.updateRevoluteConstraints(constrToAdd);
|
|
874
877
|
},
|
|
875
878
|
createSliderConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
|
|
876
879
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
877
880
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
878
881
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
879
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
882
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCSliderConstraint, name);
|
|
880
883
|
if (constraintId != null) {
|
|
881
884
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
882
885
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
883
|
-
await assemblyBuilderAPI.updateSliderConstraints(
|
|
886
|
+
await assemblyBuilderAPI.updateSliderConstraints([
|
|
884
887
|
{
|
|
885
888
|
constrId: constraintId,
|
|
886
889
|
mate1: {
|
|
@@ -942,16 +945,16 @@ export class History {
|
|
|
942
945
|
}
|
|
943
946
|
finally { if (e_7) throw e_7.error; }
|
|
944
947
|
}
|
|
945
|
-
await assemblyBuilderAPI.updateSliderConstraints(
|
|
948
|
+
await assemblyBuilderAPI.updateSliderConstraints(constrToAdd);
|
|
946
949
|
},
|
|
947
950
|
createPlanarConstraint: async (id, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
|
|
948
951
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
949
952
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
950
953
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
951
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
954
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCPlanarConstraint, name);
|
|
952
955
|
if (constraintId != null) {
|
|
953
956
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
954
|
-
await assemblyBuilderAPI.updatePlanarConstraints(
|
|
957
|
+
await assemblyBuilderAPI.updatePlanarConstraints([
|
|
955
958
|
{
|
|
956
959
|
constrId: constraintId,
|
|
957
960
|
mate1: {
|
|
@@ -1014,15 +1017,15 @@ export class History {
|
|
|
1014
1017
|
}
|
|
1015
1018
|
finally { if (e_8) throw e_8.error; }
|
|
1016
1019
|
}
|
|
1017
|
-
await assemblyBuilderAPI.updatePlanarConstraints(
|
|
1020
|
+
await assemblyBuilderAPI.updatePlanarConstraints(constrToAdd);
|
|
1018
1021
|
},
|
|
1019
1022
|
createParallelConstraint: async (id, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
|
|
1020
1023
|
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
1021
1024
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1022
1025
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1023
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
1026
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCParallelConstraint, name);
|
|
1024
1027
|
if (constraintId != null) {
|
|
1025
|
-
await assemblyBuilderAPI.updateParallelConstraints(
|
|
1028
|
+
await assemblyBuilderAPI.updateParallelConstraints([
|
|
1026
1029
|
{
|
|
1027
1030
|
constrId: constraintId,
|
|
1028
1031
|
mate1: {
|
|
@@ -1084,14 +1087,14 @@ export class History {
|
|
|
1084
1087
|
}
|
|
1085
1088
|
finally { if (e_9) throw e_9.error; }
|
|
1086
1089
|
}
|
|
1087
|
-
await assemblyBuilderAPI.updateParallelConstraints(
|
|
1090
|
+
await assemblyBuilderAPI.updateParallelConstraints(constrToAdd);
|
|
1088
1091
|
},
|
|
1089
1092
|
createGroupConstraint: async (id, instanceIds, name) => {
|
|
1090
1093
|
const [rId] = await new Promise(res => this.resolve(ids => res(ids), id));
|
|
1091
1094
|
const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...instanceIds));
|
|
1092
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
1095
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCGroupConstraint, name);
|
|
1093
1096
|
if (constraintId != null) {
|
|
1094
|
-
await assemblyBuilderAPI.updateGroupConstraints(
|
|
1097
|
+
await assemblyBuilderAPI.updateGroupConstraints([
|
|
1095
1098
|
{
|
|
1096
1099
|
constrId: constraintId,
|
|
1097
1100
|
instanceIds: rInstanceIds,
|
|
@@ -1122,7 +1125,7 @@ export class History {
|
|
|
1122
1125
|
}
|
|
1123
1126
|
finally { if (e_10) throw e_10.error; }
|
|
1124
1127
|
}
|
|
1125
|
-
await assemblyBuilderAPI.updateGroupConstraints(
|
|
1128
|
+
await assemblyBuilderAPI.updateGroupConstraints(constrToAdd);
|
|
1126
1129
|
},
|
|
1127
1130
|
createLinearPatternConstraint: async (id, instanceId, mate1, firstDirInstanceCount, firstDirDistance, name, mate2, secondDirInstanceCount, secondDirDistance) => {
|
|
1128
1131
|
const [rId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId, mate2 === null || mate2 === void 0 ? void 0 : mate2.wcsId));
|
|
@@ -1131,7 +1134,7 @@ export class History {
|
|
|
1131
1134
|
if (mate2) {
|
|
1132
1135
|
rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1133
1136
|
}
|
|
1134
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
1137
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCLinearPatternConstraint, name);
|
|
1135
1138
|
if (constraintId != null) {
|
|
1136
1139
|
const firstDirInstanceCountParam = {
|
|
1137
1140
|
value: firstDirInstanceCount,
|
|
@@ -1153,7 +1156,7 @@ export class History {
|
|
|
1153
1156
|
isExpr: typeof secondDirDistance === 'string',
|
|
1154
1157
|
}
|
|
1155
1158
|
: undefined;
|
|
1156
|
-
await assemblyBuilderAPI.updateLinearPatternConstraints(
|
|
1159
|
+
await assemblyBuilderAPI.updateLinearPatternConstraints([
|
|
1157
1160
|
{
|
|
1158
1161
|
constrId: constraintId,
|
|
1159
1162
|
instanceId: rInstanceId,
|
|
@@ -1247,12 +1250,12 @@ export class History {
|
|
|
1247
1250
|
}
|
|
1248
1251
|
finally { if (e_11) throw e_11.error; }
|
|
1249
1252
|
}
|
|
1250
|
-
await assemblyBuilderAPI.updateLinearPatternConstraints(
|
|
1253
|
+
await assemblyBuilderAPI.updateLinearPatternConstraints(constrToAdd);
|
|
1251
1254
|
},
|
|
1252
1255
|
createCircularPatternConstraint: async (id, instanceId, mate1, instanceCount, angle, offset, name) => {
|
|
1253
1256
|
const [rId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId));
|
|
1254
1257
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1255
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(
|
|
1258
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCircularPatternConstraint, name);
|
|
1256
1259
|
if (constraintId != null) {
|
|
1257
1260
|
const instanceCountParam = {
|
|
1258
1261
|
value: instanceCount,
|
|
@@ -1260,7 +1263,7 @@ export class History {
|
|
|
1260
1263
|
};
|
|
1261
1264
|
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
1262
1265
|
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1263
|
-
await assemblyBuilderAPI.updateCircularPatternConstraints(
|
|
1266
|
+
await assemblyBuilderAPI.updateCircularPatternConstraints([
|
|
1264
1267
|
{
|
|
1265
1268
|
constrId: constraintId,
|
|
1266
1269
|
instanceId: rInstanceId,
|
|
@@ -1315,7 +1318,7 @@ export class History {
|
|
|
1315
1318
|
}
|
|
1316
1319
|
finally { if (e_12) throw e_12.error; }
|
|
1317
1320
|
}
|
|
1318
|
-
await assemblyBuilderAPI.updateCircularPatternConstraints(
|
|
1321
|
+
await assemblyBuilderAPI.updateCircularPatternConstraints(constrToAdd);
|
|
1319
1322
|
},
|
|
1320
1323
|
update3dConstraintValues: async (...constrValues) => {
|
|
1321
1324
|
var e_13, _a;
|
|
@@ -1338,7 +1341,7 @@ export class History {
|
|
|
1338
1341
|
}
|
|
1339
1342
|
finally { if (e_13) throw e_13.error; }
|
|
1340
1343
|
}
|
|
1341
|
-
await assemblyBuilderAPI.update3DConstraintValues(
|
|
1344
|
+
await assemblyBuilderAPI.update3DConstraintValues(constrValueParams);
|
|
1342
1345
|
},
|
|
1343
1346
|
createBufferGeometry: async (objectId) => {
|
|
1344
1347
|
await this.queue;
|
|
@@ -1390,7 +1393,7 @@ export class History {
|
|
|
1390
1393
|
};
|
|
1391
1394
|
membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
|
|
1392
1395
|
});
|
|
1393
|
-
const success = featureAPI.updateExpressions(
|
|
1396
|
+
const success = featureAPI.updateExpressions([
|
|
1394
1397
|
{ productId: rPartId, toAddMembers: membersToAdd, toModifyMembers: [], toDeleteList: [] },
|
|
1395
1398
|
]);
|
|
1396
1399
|
return success;
|
|
@@ -1398,30 +1401,30 @@ export class History {
|
|
|
1398
1401
|
},
|
|
1399
1402
|
createAssemblyAsTemplate: (name) => {
|
|
1400
1403
|
return this.resolve(async ([]) => {
|
|
1401
|
-
return await assemblyBuilderAPI.createAssemblyAsTemplate(
|
|
1404
|
+
return await assemblyBuilderAPI.createAssemblyAsTemplate(name);
|
|
1402
1405
|
});
|
|
1403
1406
|
},
|
|
1404
1407
|
createRootAssembly: (name, options) => {
|
|
1405
1408
|
return this.resolve(async ([]) => {
|
|
1406
|
-
return await assemblyBuilderAPI.createRootAssembly(
|
|
1409
|
+
return await assemblyBuilderAPI.createRootAssembly(name, options);
|
|
1407
1410
|
});
|
|
1408
1411
|
},
|
|
1409
1412
|
createPart: (name) => {
|
|
1410
1413
|
return this.resolve(async ([]) => {
|
|
1411
1414
|
const partName = name ? name : 'Part';
|
|
1412
|
-
return await featureAPI.newPart(
|
|
1415
|
+
return await featureAPI.newPart(partName);
|
|
1413
1416
|
});
|
|
1414
1417
|
},
|
|
1415
1418
|
createPartAsTemplate: (name) => {
|
|
1416
1419
|
return this.resolve(async ([]) => {
|
|
1417
1420
|
const partName = name ? name : 'Part';
|
|
1418
|
-
return await assemblyBuilderAPI.createPartAsTemplate(
|
|
1421
|
+
return await assemblyBuilderAPI.createPartAsTemplate(partName);
|
|
1419
1422
|
});
|
|
1420
1423
|
},
|
|
1421
1424
|
createWorkAxis: (partId, type, references, position, direction, local, name) => {
|
|
1422
1425
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1423
1426
|
const wAName = name ? name : 'WorkAxis';
|
|
1424
|
-
const wAId = await featureAPI.createWorkGeometry(
|
|
1427
|
+
const wAId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkAxis, wAName);
|
|
1425
1428
|
if (wAId != null) {
|
|
1426
1429
|
const resPosition = resolveVec(position);
|
|
1427
1430
|
const positionParam = {
|
|
@@ -1433,7 +1436,7 @@ export class History {
|
|
|
1433
1436
|
value: resDirection,
|
|
1434
1437
|
isExpr: typeof resDirection === 'string',
|
|
1435
1438
|
};
|
|
1436
|
-
await featureAPI.updateWorkAxis(
|
|
1439
|
+
await featureAPI.updateWorkAxis(wAId, type, rReferences, positionParam, directionParam, local);
|
|
1437
1440
|
return wAId;
|
|
1438
1441
|
}
|
|
1439
1442
|
return null;
|
|
@@ -1442,7 +1445,7 @@ export class History {
|
|
|
1442
1445
|
createWorkCoordSystem: (partId, type, references, offset, rotation, inverted = false, name) => {
|
|
1443
1446
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1444
1447
|
const wCSName = name ? name : 'WorkCoordSystem';
|
|
1445
|
-
const wCSId = await featureAPI.createWorkGeometry(
|
|
1448
|
+
const wCSId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkCSys, wCSName);
|
|
1446
1449
|
if (wCSId != null) {
|
|
1447
1450
|
const resOffset = resolveVec(offset);
|
|
1448
1451
|
const offsetParam = {
|
|
@@ -1454,7 +1457,7 @@ export class History {
|
|
|
1454
1457
|
value: resRotation,
|
|
1455
1458
|
isExpr: typeof resRotation === 'string',
|
|
1456
1459
|
};
|
|
1457
|
-
await featureAPI.updateWorkCSys(
|
|
1460
|
+
await featureAPI.updateWorkCSys(wCSId, type, rReferences, offsetParam, rotationParam, inverted ? 1 : 0);
|
|
1458
1461
|
return wCSId;
|
|
1459
1462
|
}
|
|
1460
1463
|
return null;
|
|
@@ -1463,7 +1466,7 @@ export class History {
|
|
|
1463
1466
|
createWorkPlane: (partId, type, references, offset, angle, position, normal, local, name) => {
|
|
1464
1467
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1465
1468
|
const wPName = name ? name : 'WorkPlane';
|
|
1466
|
-
const wPId = await featureAPI.createWorkGeometry(
|
|
1469
|
+
const wPId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPlane, wPName);
|
|
1467
1470
|
if (wPId != undefined) {
|
|
1468
1471
|
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1469
1472
|
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
@@ -1477,7 +1480,7 @@ export class History {
|
|
|
1477
1480
|
value: resNormal,
|
|
1478
1481
|
isExpr: typeof resNormal === 'string',
|
|
1479
1482
|
};
|
|
1480
|
-
await featureAPI.updateWorkPlane(
|
|
1483
|
+
await featureAPI.updateWorkPlane(wPId, type, rReferences, offsetParam, angleParam, positionParam, normalParam, local);
|
|
1481
1484
|
return wPId;
|
|
1482
1485
|
}
|
|
1483
1486
|
return null;
|
|
@@ -1486,14 +1489,14 @@ export class History {
|
|
|
1486
1489
|
createWorkPoint: (partId, type, references, position, local, name) => {
|
|
1487
1490
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1488
1491
|
const wPTName = name ? name : 'WorkPoint';
|
|
1489
|
-
const wPTId = await featureAPI.createWorkGeometry(
|
|
1492
|
+
const wPTId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPoint, wPTName);
|
|
1490
1493
|
if (wPTId != undefined) {
|
|
1491
1494
|
const resPosition = resolveVec(position);
|
|
1492
1495
|
const positionParam = {
|
|
1493
1496
|
value: resPosition,
|
|
1494
1497
|
isExpr: typeof resPosition === 'string',
|
|
1495
1498
|
};
|
|
1496
|
-
await featureAPI.updateWorkPoint(
|
|
1499
|
+
await featureAPI.updateWorkPoint(wPTId, type, rReferences, positionParam, local);
|
|
1497
1500
|
return wPTId;
|
|
1498
1501
|
}
|
|
1499
1502
|
return null;
|
|
@@ -1502,9 +1505,9 @@ export class History {
|
|
|
1502
1505
|
fillet: (partId, references, radius) => {
|
|
1503
1506
|
return this.resolve(async ([rPartId, rReferences]) => {
|
|
1504
1507
|
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
1505
|
-
const filletId = await featureAPI.createFeature(
|
|
1508
|
+
const filletId = await featureAPI.createFeature(rPartId, CCClasses.CCConstantRadiusFillet, 'Fillet');
|
|
1506
1509
|
if (filletId != null) {
|
|
1507
|
-
await featureAPI.updateFillet(
|
|
1510
|
+
await featureAPI.updateFillet(filletId, rReferences, radiusParam);
|
|
1508
1511
|
return filletId;
|
|
1509
1512
|
}
|
|
1510
1513
|
return null;
|
|
@@ -1524,7 +1527,7 @@ export class History {
|
|
|
1524
1527
|
const interactionInfos = [];
|
|
1525
1528
|
for (const selection of selections) {
|
|
1526
1529
|
// Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
|
|
1527
|
-
const points = await geometryAPI.getPointsByGeometries(
|
|
1530
|
+
const points = await geometryAPI.getPointsByGeometries([selection.data.graphicId]);
|
|
1528
1531
|
const matrix = getDrawing(drId).api.structure.calculateGlobalTransformation(selection.data.productId);
|
|
1529
1532
|
const clone = selection.data.geometry.clone().applyMatrix4(matrix);
|
|
1530
1533
|
// TODO: Should the transform code be moved to something else than Measure? It's helpful for more cases than just measuring.
|
|
@@ -1544,7 +1547,7 @@ export class History {
|
|
|
1544
1547
|
},
|
|
1545
1548
|
findGeometry: (partId, type, positions) => {
|
|
1546
1549
|
return this.resolve(async ([rPartId]) => {
|
|
1547
|
-
const geoms = await geometryAPI.findGeometriesByPoints(
|
|
1550
|
+
const geoms = await geometryAPI.findGeometriesByPoints(rPartId, type, positions.map(pos => pos.map(p => resolveVec(p))));
|
|
1548
1551
|
return geoms;
|
|
1549
1552
|
}, partId);
|
|
1550
1553
|
},
|
|
@@ -1598,7 +1601,7 @@ export class History {
|
|
|
1598
1601
|
},
|
|
1599
1602
|
setCurrentInstance: (id) => {
|
|
1600
1603
|
return this.resolve(async ([rId]) => {
|
|
1601
|
-
await assemblyBuilderAPI.setCurrentInstance(
|
|
1604
|
+
await assemblyBuilderAPI.setCurrentInstance(rId);
|
|
1602
1605
|
}, id);
|
|
1603
1606
|
},
|
|
1604
1607
|
getCurrentInstance: () => {
|
|
@@ -1618,7 +1621,7 @@ export class History {
|
|
|
1618
1621
|
},
|
|
1619
1622
|
setCurrentProduct: (productId) => {
|
|
1620
1623
|
return this.resolve(async ([rProductId]) => {
|
|
1621
|
-
await baseModelerAPI.setCurrentProduct(
|
|
1624
|
+
await baseModelerAPI.setCurrentProduct(rProductId);
|
|
1622
1625
|
}, productId);
|
|
1623
1626
|
},
|
|
1624
1627
|
getCurrentProduct: () => {
|
|
@@ -1849,7 +1852,7 @@ export class History {
|
|
|
1849
1852
|
},
|
|
1850
1853
|
getFeatureByName: (partId, featureName) => {
|
|
1851
1854
|
return this.resolve(async ([rProductId]) => {
|
|
1852
|
-
const feature = await featureAPI.getFeatureByName(
|
|
1855
|
+
const feature = await featureAPI.getFeatureByName(rProductId, featureName);
|
|
1853
1856
|
if (feature !== null) {
|
|
1854
1857
|
return feature;
|
|
1855
1858
|
}
|
|
@@ -1858,7 +1861,7 @@ export class History {
|
|
|
1858
1861
|
},
|
|
1859
1862
|
getGeometryInformation: (id) => {
|
|
1860
1863
|
return this.resolve(async ([rId]) => {
|
|
1861
|
-
const values = await baseModelerAPI.getGeometryInformation(
|
|
1864
|
+
const values = await baseModelerAPI.getGeometryInformation(rId);
|
|
1862
1865
|
if (values !== null) {
|
|
1863
1866
|
return { centerOfGravity: values[0], volume: values[1] };
|
|
1864
1867
|
}
|
|
@@ -1901,14 +1904,14 @@ export class History {
|
|
|
1901
1904
|
}
|
|
1902
1905
|
finally { if (e_14) throw e_14.error; }
|
|
1903
1906
|
}
|
|
1904
|
-
return assemblyBuilderAPI.removeInstances(
|
|
1907
|
+
return assemblyBuilderAPI.removeInstances(instancesToRemove);
|
|
1905
1908
|
},
|
|
1906
1909
|
importFeature: (partId, content, format, name) => {
|
|
1907
1910
|
return this.resolve(async ([rPartId]) => {
|
|
1908
1911
|
const featureName = name ? name : 'Import';
|
|
1909
|
-
const importFeatureId = await featureAPI.createFeature(
|
|
1912
|
+
const importFeatureId = await featureAPI.createFeature(rPartId, CCClasses.CCImport, featureName);
|
|
1910
1913
|
if (importFeatureId !== null) {
|
|
1911
|
-
const solids = await featureAPI.updateImport(
|
|
1914
|
+
const solids = await featureAPI.updateImport(importFeatureId, content, format, featureName);
|
|
1912
1915
|
if (solids !== null) {
|
|
1913
1916
|
return importFeatureId;
|
|
1914
1917
|
}
|
|
@@ -1918,43 +1921,43 @@ export class History {
|
|
|
1918
1921
|
},
|
|
1919
1922
|
loadSketch: (partId, stream, planeId, name) => {
|
|
1920
1923
|
return this.resolve(async ([rPartId, rPlaneId]) => {
|
|
1921
|
-
const sketch = await sketcherAPI.createSketch(
|
|
1924
|
+
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1922
1925
|
if (sketch) {
|
|
1923
|
-
await featureAPI.closeFeature(
|
|
1926
|
+
await featureAPI.closeFeature(sketch);
|
|
1924
1927
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1925
1928
|
const plane = tree[rPlaneId];
|
|
1926
1929
|
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1927
|
-
await sketcherAPI.setWorkPlane(
|
|
1930
|
+
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1928
1931
|
}
|
|
1929
1932
|
else {
|
|
1930
|
-
await sketcherAPI.createAndSetWorkPlane(
|
|
1933
|
+
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1931
1934
|
}
|
|
1932
|
-
await sketcherAPI.loadSketch(
|
|
1935
|
+
await sketcherAPI.loadSketch(rPartId, sketch, stream, name);
|
|
1933
1936
|
return sketch;
|
|
1934
1937
|
}
|
|
1935
1938
|
}, partId, planeId);
|
|
1936
1939
|
},
|
|
1937
1940
|
copySketch: (partId, sketchId, planeId) => {
|
|
1938
1941
|
return this.resolve(async ([rPartId, rPlaneId, rSketchId]) => {
|
|
1939
|
-
const sketch = await sketcherAPI.createSketch(
|
|
1942
|
+
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1940
1943
|
if (sketch) {
|
|
1941
|
-
await featureAPI.closeFeature(
|
|
1944
|
+
await featureAPI.closeFeature(sketch);
|
|
1942
1945
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1943
1946
|
const plane = tree[rPlaneId];
|
|
1944
1947
|
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1945
|
-
await sketcherAPI.setWorkPlane(
|
|
1948
|
+
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1946
1949
|
}
|
|
1947
1950
|
else {
|
|
1948
|
-
await sketcherAPI.createAndSetWorkPlane(
|
|
1951
|
+
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1949
1952
|
}
|
|
1950
|
-
await sketcherAPI.copySketch(
|
|
1953
|
+
await sketcherAPI.copySketch(sketch, rSketchId);
|
|
1951
1954
|
return sketch;
|
|
1952
1955
|
}
|
|
1953
1956
|
}, partId, planeId, sketchId);
|
|
1954
1957
|
},
|
|
1955
1958
|
placeSketch: (sketchId, planeId, invertPlane, axisId, isXAxis, invertAxis, originId) => {
|
|
1956
1959
|
return this.resolve(async ([rSketchId, rPlaneId, rAxisId, rOriginId]) => {
|
|
1957
|
-
await sketcherAPI.setSketchRefs(
|
|
1960
|
+
await sketcherAPI.setSketchRefs(rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
|
|
1958
1961
|
}, sketchId, planeId, axisId, originId);
|
|
1959
1962
|
},
|
|
1960
1963
|
transformInstances: async (...instances) => {
|
|
@@ -1997,11 +2000,11 @@ export class History {
|
|
|
1997
2000
|
}
|
|
1998
2001
|
finally { if (e_15) throw e_15.error; }
|
|
1999
2002
|
}
|
|
2000
|
-
return assemblyBuilderAPI.transformInstances(
|
|
2003
|
+
return assemblyBuilderAPI.transformInstances(instancesToTransform);
|
|
2001
2004
|
},
|
|
2002
2005
|
translate: (partId, operations, references, inverted, distance) => {
|
|
2003
2006
|
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
2004
|
-
const translationId = await featureAPI.createFeature(
|
|
2007
|
+
const translationId = await featureAPI.createFeature(rPartId, CCClasses.CCTranslation, 'Translate');
|
|
2005
2008
|
if (translationId !== null) {
|
|
2006
2009
|
const cDrawing = await getDrawing(drawingId);
|
|
2007
2010
|
const entArray = [];
|
|
@@ -2012,7 +2015,7 @@ export class History {
|
|
|
2012
2015
|
}
|
|
2013
2016
|
}
|
|
2014
2017
|
const dist = { value: distance, isExpr: typeof distance === 'string' };
|
|
2015
|
-
await featureAPI.updateTransformation(
|
|
2018
|
+
await featureAPI.updateTransformation(translationId, entArray, rReferences, inverted, dist);
|
|
2016
2019
|
return translationId;
|
|
2017
2020
|
}
|
|
2018
2021
|
return null;
|
|
@@ -2029,34 +2032,34 @@ export class History {
|
|
|
2029
2032
|
const inverted = members['inverted'].value;
|
|
2030
2033
|
const dist = distance !== null ? distance : members['translationDistance'].value;
|
|
2031
2034
|
const distParam = { value: dist, isExpr: typeof distance === 'string' };
|
|
2032
|
-
await featureAPI.openFeature(
|
|
2033
|
-
await featureAPI.updateTransformation(
|
|
2034
|
-
await featureAPI.closeFeature(
|
|
2035
|
+
await featureAPI.openFeature(rTranslationId);
|
|
2036
|
+
await featureAPI.updateTransformation(rTranslationId, entArray, references, inverted, distParam);
|
|
2037
|
+
await featureAPI.closeFeature(rTranslationId);
|
|
2035
2038
|
}
|
|
2036
2039
|
}, translationId);
|
|
2037
2040
|
},
|
|
2038
2041
|
save: (type) => {
|
|
2039
|
-
return baseModelerAPI.save(
|
|
2042
|
+
return baseModelerAPI.save(type);
|
|
2040
2043
|
},
|
|
2041
2044
|
saveToUrl: (url, filetype) => {
|
|
2042
|
-
return baseModelerAPI.saveToUrl(
|
|
2045
|
+
return baseModelerAPI.saveToUrl(url, filetype);
|
|
2043
2046
|
},
|
|
2044
2047
|
load: (content, type, options) => {
|
|
2045
|
-
return baseModelerAPI.load(
|
|
2048
|
+
return baseModelerAPI.load(content, type, '', options);
|
|
2046
2049
|
},
|
|
2047
2050
|
loadFromUrl: (url, filetype, options) => {
|
|
2048
|
-
return baseModelerAPI.loadFromUrl(
|
|
2051
|
+
return baseModelerAPI.loadFromUrl(url, filetype, true, options);
|
|
2049
2052
|
},
|
|
2050
2053
|
loadProduct: (content, type, options) => {
|
|
2051
|
-
return assemblyBuilderAPI.loadProduct(
|
|
2054
|
+
return assemblyBuilderAPI.loadProduct(content, type, options);
|
|
2052
2055
|
},
|
|
2053
2056
|
loadProductFromUrl: (url, filetype, options) => {
|
|
2054
|
-
return assemblyBuilderAPI.loadProductFromUrl(
|
|
2057
|
+
return assemblyBuilderAPI.loadProductFromUrl(url, filetype, options);
|
|
2055
2058
|
},
|
|
2056
2059
|
pick: (partId, type, points) => {
|
|
2057
2060
|
return this.resolve(async ([rPartId]) => {
|
|
2058
2061
|
console.warn('Warning: pick() is deprecated, use findGeometry() instead, pick() will be removed in a future release.');
|
|
2059
|
-
const refs = await featureAPI.pick(
|
|
2062
|
+
const refs = await featureAPI.pick(rPartId, type, points.map(p => resolveVec(p)));
|
|
2060
2063
|
if (refs != undefined) {
|
|
2061
2064
|
return Array.isArray(refs) ? refs : [refs];
|
|
2062
2065
|
}
|
|
@@ -2113,12 +2116,12 @@ export class History {
|
|
|
2113
2116
|
}
|
|
2114
2117
|
finally { if (e_16) throw e_16.error; }
|
|
2115
2118
|
}
|
|
2116
|
-
const success = await featureAPI.updateExpressions(
|
|
2119
|
+
const success = await featureAPI.updateExpressions(expressionsToSet);
|
|
2117
2120
|
return success;
|
|
2118
2121
|
},
|
|
2119
2122
|
deleteExpressions: (partId, members) => {
|
|
2120
2123
|
return this.resolve(async ([rPartId]) => {
|
|
2121
|
-
const success = featureAPI.updateExpressions(
|
|
2124
|
+
const success = featureAPI.updateExpressions([
|
|
2122
2125
|
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toDeleteList: members },
|
|
2123
2126
|
]);
|
|
2124
2127
|
return success;
|
|
@@ -2126,10 +2129,10 @@ export class History {
|
|
|
2126
2129
|
},
|
|
2127
2130
|
sphere: (partId, references, radius) => {
|
|
2128
2131
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
2129
|
-
const sphereId = await featureAPI.createFeature(
|
|
2132
|
+
const sphereId = await featureAPI.createFeature(rPartId, CCClasses.CCSphere, 'Sphere');
|
|
2130
2133
|
if (sphereId != null) {
|
|
2131
2134
|
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
2132
|
-
await featureAPI.updateSphere(
|
|
2135
|
+
await featureAPI.updateSphere(sphereId, rReferences, radiusParam);
|
|
2133
2136
|
return sphereId;
|
|
2134
2137
|
}
|
|
2135
2138
|
return null;
|
|
@@ -2147,9 +2150,9 @@ export class History {
|
|
|
2147
2150
|
entArray.push(entities[0]);
|
|
2148
2151
|
}
|
|
2149
2152
|
}
|
|
2150
|
-
const mirrorId = await featureAPI.createFeature(
|
|
2153
|
+
const mirrorId = await featureAPI.createFeature(rPartId, CCClasses.CCMirror, 'Mirror');
|
|
2151
2154
|
if (mirrorId != null) {
|
|
2152
|
-
await featureAPI.updateMirror(
|
|
2155
|
+
await featureAPI.updateMirror(mirrorId, entArray, rReferences);
|
|
2153
2156
|
return mirrorId;
|
|
2154
2157
|
}
|
|
2155
2158
|
return null;
|
|
@@ -2158,7 +2161,7 @@ export class History {
|
|
|
2158
2161
|
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2159
2162
|
const [rToOperation] = await new Promise(res => this.resolve(paths => res(paths), toOperation));
|
|
2160
2163
|
if (operations && operations.length > 0) {
|
|
2161
|
-
await baseModelerAPI.deleteObjects(
|
|
2164
|
+
await baseModelerAPI.deleteObjects(rOperations);
|
|
2162
2165
|
}
|
|
2163
2166
|
else if (rToOperation) {
|
|
2164
2167
|
const toRemoveOps = [];
|
|
@@ -2180,7 +2183,7 @@ export class History {
|
|
|
2180
2183
|
index--;
|
|
2181
2184
|
}
|
|
2182
2185
|
}
|
|
2183
|
-
await baseModelerAPI.deleteObjects(
|
|
2186
|
+
await baseModelerAPI.deleteObjects(toRemoveOps);
|
|
2184
2187
|
}
|
|
2185
2188
|
},
|
|
2186
2189
|
getMatePath: async (refId) => {
|
|
@@ -2200,16 +2203,16 @@ export class History {
|
|
|
2200
2203
|
entArray.push(entities[0]); // use first entity of operation
|
|
2201
2204
|
}
|
|
2202
2205
|
}
|
|
2203
|
-
const sliceId = await featureAPI.createFeature(
|
|
2206
|
+
const sliceId = await featureAPI.createFeature(rPartId, CCClasses.CCSlice, 'Slice');
|
|
2204
2207
|
if (sliceId != null) {
|
|
2205
|
-
await featureAPI.openFeature(
|
|
2208
|
+
await featureAPI.openFeature(sliceId);
|
|
2206
2209
|
if (entArray.length > 0) {
|
|
2207
|
-
await featureAPI.updateSlice(
|
|
2208
|
-
await featureAPI.closeFeature(
|
|
2210
|
+
await featureAPI.updateSlice(sliceId, entArray, rReference, sideFlag ? 1 : 0);
|
|
2211
|
+
await featureAPI.closeFeature(sliceId);
|
|
2209
2212
|
return sliceId;
|
|
2210
2213
|
}
|
|
2211
|
-
await featureAPI.closeFeature(
|
|
2212
|
-
await baseModelerAPI.deleteObjects(
|
|
2214
|
+
await featureAPI.closeFeature(sliceId);
|
|
2215
|
+
await baseModelerAPI.deleteObjects([sliceId]);
|
|
2213
2216
|
}
|
|
2214
2217
|
return null;
|
|
2215
2218
|
},
|
|
@@ -2219,22 +2222,22 @@ export class History {
|
|
|
2219
2222
|
const [rOperationOfSheet] = await new Promise(res => this.resolve(ids => res(ids), operationOfSheet));
|
|
2220
2223
|
const entityToSlice = getDrawing(drawingId).structure.tree[rOperationToSlice].children;
|
|
2221
2224
|
const entityOfSheet = getDrawing(drawingId).structure.tree[rOperationOfSheet].children;
|
|
2222
|
-
const sliceBySheetId = await featureAPI.createFeature(
|
|
2225
|
+
const sliceBySheetId = await featureAPI.createFeature(rPartId, CCClasses.CCSliceBySheet, 'SliceBySheet');
|
|
2223
2226
|
if (sliceBySheetId != null) {
|
|
2224
|
-
await featureAPI.openFeature(
|
|
2227
|
+
await featureAPI.openFeature(sliceBySheetId);
|
|
2225
2228
|
if (entityToSlice && entityToSlice.length > 0 && entityOfSheet && entityOfSheet.length > 0) {
|
|
2226
|
-
await featureAPI.updateSliceBySheet(
|
|
2227
|
-
await featureAPI.closeFeature(
|
|
2229
|
+
await featureAPI.updateSliceBySheet(sliceBySheetId, entityToSlice[0], entityOfSheet[0], sideFlag ? 1 : 0);
|
|
2230
|
+
await featureAPI.closeFeature(sliceBySheetId);
|
|
2228
2231
|
return sliceBySheetId;
|
|
2229
2232
|
}
|
|
2230
|
-
await featureAPI.closeFeature(
|
|
2231
|
-
await baseModelerAPI.deleteObjects(
|
|
2233
|
+
await featureAPI.closeFeature(sliceBySheetId);
|
|
2234
|
+
await baseModelerAPI.deleteObjects([sliceBySheetId]);
|
|
2232
2235
|
}
|
|
2233
2236
|
return null;
|
|
2234
2237
|
},
|
|
2235
2238
|
twist: async (param) => {
|
|
2236
2239
|
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
2237
|
-
const twist = await featureAPI.createFeature(
|
|
2240
|
+
const twist = await featureAPI.createFeature(rPartId, CCClasses.CCTwist, 'Twist');
|
|
2238
2241
|
if (twist) {
|
|
2239
2242
|
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
2240
2243
|
? rSketchOrRegionIds
|
|
@@ -2268,7 +2271,7 @@ export class History {
|
|
|
2268
2271
|
value: resTwistCenter,
|
|
2269
2272
|
isExpr: typeof resTwistCenter === 'string',
|
|
2270
2273
|
};
|
|
2271
|
-
await featureAPI.updateTwist(
|
|
2274
|
+
await featureAPI.updateTwist(twist, resSketchOrRegionIds, param.type, limit1Param, limit2Param, directionParam, twistAngleParam, twistCenterParam, param.capEnds);
|
|
2272
2275
|
return twist;
|
|
2273
2276
|
}
|
|
2274
2277
|
}
|