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