@buerli.io/headless 0.8.0 → 0.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/history.js +173 -171
- package/build/cjs/index.js +19 -1
- package/build/esm/history.js +174 -172
- package/build/esm/index.js +4 -0
- package/build/types/history.d.ts +355 -190
- package/build/types/index.d.ts +4 -0
- package/package.json +2 -2
package/build/esm/history.js
CHANGED
|
@@ -7,7 +7,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
7
7
|
};
|
|
8
8
|
/* eslint-disable max-lines */
|
|
9
9
|
import { ccAPI, CCClasses, ccUtils, DataType, SVGModusType, } from '@buerli.io/classcad';
|
|
10
|
-
import { api, getDrawing, MathUtils, BuerliScope, createInfo, } from '@buerli.io/core';
|
|
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';
|
|
@@ -21,12 +21,6 @@ const geometryAPI = ccAPI.geometry;
|
|
|
21
21
|
const baseUtils = ccUtils.base;
|
|
22
22
|
const asmUtils = ccUtils.assembly;
|
|
23
23
|
const partUtils = ccUtils.part;
|
|
24
|
-
const resolveVec = (value) => {
|
|
25
|
-
if (Array.isArray(value))
|
|
26
|
-
return { x: value[0], y: value[1], z: value[2] };
|
|
27
|
-
else
|
|
28
|
-
return value;
|
|
29
|
-
};
|
|
30
24
|
/**
|
|
31
25
|
* Returns the cclass of the given dimension type
|
|
32
26
|
* @param type type of the dimension as string
|
|
@@ -112,8 +106,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
|
|
|
112
106
|
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
113
107
|
matrix.decompose(part.position, part.quaternion, part.scale);
|
|
114
108
|
part.updateMatrix();
|
|
115
|
-
part.userData = { id: object.id }; //
|
|
116
|
-
part.name = object.name; //
|
|
109
|
+
part.userData = { id: object.id }; // instance id
|
|
110
|
+
part.name = object.name; // instance name
|
|
117
111
|
for (const entity of entities) {
|
|
118
112
|
let cachedEntity = cDrawing.geometry.cache[entity];
|
|
119
113
|
if (!cachedEntity) {
|
|
@@ -209,8 +203,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
|
|
|
209
203
|
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
210
204
|
matrix.decompose(assembly.position, assembly.quaternion, assembly.scale);
|
|
211
205
|
assembly.updateMatrix();
|
|
212
|
-
assembly.userData = { id: object.id }; // assembly root or
|
|
213
|
-
assembly.name = object.name; // assembly root or
|
|
206
|
+
assembly.userData = { id: object.id }; // assembly root or instance id
|
|
207
|
+
assembly.name = object.name; // assembly root or instance name
|
|
214
208
|
result.nodes[assembly.name] = assembly;
|
|
215
209
|
root.add(assembly);
|
|
216
210
|
for (const child of object.children) {
|
|
@@ -220,6 +214,12 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
|
|
|
220
214
|
}
|
|
221
215
|
}
|
|
222
216
|
};
|
|
217
|
+
const resolveVec = (value) => {
|
|
218
|
+
if (Array.isArray(value))
|
|
219
|
+
return { x: value[0], y: value[1], z: value[2] };
|
|
220
|
+
else
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
223
|
export default class CAD {
|
|
224
224
|
constructor() {
|
|
225
225
|
this.drawingId = null;
|
|
@@ -240,31 +240,31 @@ export default class CAD {
|
|
|
240
240
|
throw new Error('Drawing could not be created');
|
|
241
241
|
this.drawingId = drawingId;
|
|
242
242
|
const publicApi = {
|
|
243
|
-
|
|
243
|
+
addInstances: async (...instances) => {
|
|
244
244
|
var e_1, _a;
|
|
245
|
-
const
|
|
245
|
+
const instancesToAdd = [];
|
|
246
246
|
try {
|
|
247
|
-
for (var
|
|
248
|
-
const
|
|
249
|
-
const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id),
|
|
250
|
-
const
|
|
251
|
-
|
|
247
|
+
for (var instances_1 = __asyncValues(instances), instances_1_1; instances_1_1 = await instances_1.next(), !instances_1_1.done;) {
|
|
248
|
+
const instance = instances_1_1.value;
|
|
249
|
+
const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), instance.productId, instance.ownerId));
|
|
250
|
+
const instanceParam = {
|
|
251
|
+
productId: rProductId,
|
|
252
252
|
ownerId: rOwnerId,
|
|
253
|
-
transformation:
|
|
254
|
-
name:
|
|
255
|
-
options: Object.assign(Object.assign({},
|
|
253
|
+
transformation: instance.transformation,
|
|
254
|
+
name: instance.name,
|
|
255
|
+
options: Object.assign(Object.assign({}, instance.options), { isLocal: true }), // in non-interactive mode, the transformation is local to the owner
|
|
256
256
|
};
|
|
257
|
-
|
|
257
|
+
instancesToAdd.push(instanceParam);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
261
261
|
finally {
|
|
262
262
|
try {
|
|
263
|
-
if (
|
|
263
|
+
if (instances_1_1 && !instances_1_1.done && (_a = instances_1.return)) await _a.call(instances_1);
|
|
264
264
|
}
|
|
265
265
|
finally { if (e_1) throw e_1.error; }
|
|
266
266
|
}
|
|
267
|
-
return assemblyBuilderAPI.
|
|
267
|
+
return assemblyBuilderAPI.addInstances(drawingId, instancesToAdd);
|
|
268
268
|
},
|
|
269
269
|
addDimensions: async (...dimensions) => {
|
|
270
270
|
var e_2, _a;
|
|
@@ -344,17 +344,17 @@ export default class CAD {
|
|
|
344
344
|
return drawing2DAPI.removeDimensions(drawingId, rDimensionIds);
|
|
345
345
|
}, ...dimensionIds);
|
|
346
346
|
},
|
|
347
|
-
linearPattern: (partId,
|
|
348
|
-
return this.resolve(async ([rPartId,
|
|
347
|
+
linearPattern: (partId, operations, references1, params1, references2, params2) => {
|
|
348
|
+
return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
|
|
349
349
|
const patternId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCLinearPattern, 'LinearPattern');
|
|
350
350
|
if (patternId != null) {
|
|
351
351
|
// entities
|
|
352
352
|
const cDrawing = await getDrawing(drawingId);
|
|
353
353
|
const entArray = [];
|
|
354
|
-
for (const
|
|
355
|
-
const
|
|
356
|
-
if (
|
|
357
|
-
entArray.push(
|
|
354
|
+
for (const rOperation of rOperations) {
|
|
355
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
356
|
+
if (entities != undefined) {
|
|
357
|
+
entArray.push(entities[0]);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
const distance1Param = {
|
|
@@ -402,19 +402,19 @@ export default class CAD {
|
|
|
402
402
|
return patternId;
|
|
403
403
|
}
|
|
404
404
|
return null;
|
|
405
|
-
}, partId,
|
|
405
|
+
}, partId, operations, references1, references2);
|
|
406
406
|
},
|
|
407
|
-
circularPattern: (partId,
|
|
408
|
-
return this.resolve(async ([rPartId,
|
|
407
|
+
circularPattern: (partId, operations, references, params) => {
|
|
408
|
+
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
409
409
|
const patternId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCCircularPattern, 'CircularPattern');
|
|
410
410
|
if (patternId != null) {
|
|
411
411
|
// entities
|
|
412
412
|
const cDrawing = await getDrawing(drawingId);
|
|
413
413
|
const entArray = [];
|
|
414
|
-
for (const
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
entArray.push(
|
|
414
|
+
for (const rOperation of rOperations) {
|
|
415
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
416
|
+
if (entities != undefined) {
|
|
417
|
+
entArray.push(entities[0]);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
const angleParam = { value: params.angle, isExpr: typeof params.angle === 'string' };
|
|
@@ -430,11 +430,11 @@ export default class CAD {
|
|
|
430
430
|
return patternId;
|
|
431
431
|
}
|
|
432
432
|
return null;
|
|
433
|
-
}, partId,
|
|
433
|
+
}, partId, operations, ...references);
|
|
434
434
|
},
|
|
435
435
|
extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
|
|
436
436
|
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
437
|
-
const extrusion = await featureAPI.
|
|
437
|
+
const extrusion = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCExtrusion, 'Extrusion');
|
|
438
438
|
if (extrusion) {
|
|
439
439
|
const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
|
|
440
440
|
if (sketchLines) {
|
|
@@ -456,7 +456,7 @@ export default class CAD {
|
|
|
456
456
|
},
|
|
457
457
|
revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
|
|
458
458
|
return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
|
|
459
|
-
const revolve = await featureAPI.
|
|
459
|
+
const revolve = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCRevolve, 'Revolve');
|
|
460
460
|
if (revolve) {
|
|
461
461
|
const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
|
|
462
462
|
if (sketchLines) {
|
|
@@ -468,26 +468,23 @@ export default class CAD {
|
|
|
468
468
|
}
|
|
469
469
|
}, partId, sketchOrRegionIds, ...axisIds);
|
|
470
470
|
},
|
|
471
|
-
boolean: (partId, type,
|
|
472
|
-
return this.resolve(async ([rPartId,
|
|
471
|
+
boolean: (partId, type, operations) => {
|
|
472
|
+
return this.resolve(async ([rPartId, rOperations]) => {
|
|
473
473
|
const cDrawing = await getDrawing(drawingId);
|
|
474
474
|
const entArray = [];
|
|
475
|
-
for (const
|
|
476
|
-
const
|
|
477
|
-
if (
|
|
478
|
-
entArray.push(
|
|
475
|
+
for (const rOperation of rOperations) {
|
|
476
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
477
|
+
if (entities != undefined) {
|
|
478
|
+
entArray.push(entities[0]);
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
const boolId = await featureAPI.
|
|
482
|
-
type,
|
|
483
|
-
entities: entArray,
|
|
484
|
-
});
|
|
481
|
+
const boolId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCUnion, 'Union');
|
|
485
482
|
if (boolId != null) {
|
|
486
483
|
await featureAPI.updateBooleanOperation(drawingId, boolId, type, entArray);
|
|
487
484
|
return boolId;
|
|
488
485
|
}
|
|
489
486
|
return null;
|
|
490
|
-
}, partId,
|
|
487
|
+
}, partId, operations);
|
|
491
488
|
},
|
|
492
489
|
box: (partId, references, width, length, height) => {
|
|
493
490
|
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
@@ -540,11 +537,11 @@ export default class CAD {
|
|
|
540
537
|
return null;
|
|
541
538
|
}, partId, ...references);
|
|
542
539
|
},
|
|
543
|
-
createFastenedConstraint: async (
|
|
544
|
-
const [
|
|
540
|
+
createFastenedConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffset, name) => {
|
|
541
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
545
542
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
546
543
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
547
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
544
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCFastenedConstraint, name);
|
|
548
545
|
if (constraintId != null) {
|
|
549
546
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
550
547
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
@@ -604,10 +601,10 @@ export default class CAD {
|
|
|
604
601
|
}
|
|
605
602
|
await assemblyBuilderAPI.updateFastenedConstraints(drawingId, constrToAdd);
|
|
606
603
|
},
|
|
607
|
-
createFastenedOriginConstraint: async (
|
|
608
|
-
const [
|
|
604
|
+
createFastenedOriginConstraint: async (id, mate1, xOffset, yOffset, zOffset, name) => {
|
|
605
|
+
const [rId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId));
|
|
609
606
|
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
610
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
607
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCFastenedOriginConstraint, name);
|
|
611
608
|
if (constraintId != null) {
|
|
612
609
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
613
610
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
@@ -659,11 +656,11 @@ export default class CAD {
|
|
|
659
656
|
}
|
|
660
657
|
await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
|
|
661
658
|
},
|
|
662
|
-
createCylindricalConstraint: async (
|
|
663
|
-
const [
|
|
659
|
+
createCylindricalConstraint: async (id, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
|
|
660
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
664
661
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
665
662
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
666
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
663
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCCylindricalConstraint, name);
|
|
667
664
|
if (constraintId != null) {
|
|
668
665
|
await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, [
|
|
669
666
|
{
|
|
@@ -725,11 +722,11 @@ export default class CAD {
|
|
|
725
722
|
}
|
|
726
723
|
await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, constrToAdd);
|
|
727
724
|
},
|
|
728
|
-
createRevoluteConstraint: async (
|
|
729
|
-
const [
|
|
725
|
+
createRevoluteConstraint: async (id, mate1, mate2, zOffset, zRotationLimits, name) => {
|
|
726
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
730
727
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
731
728
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
732
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
729
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCRevoluteConstraint, name);
|
|
733
730
|
if (constraintId != null) {
|
|
734
731
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
735
732
|
await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, [
|
|
@@ -793,11 +790,11 @@ export default class CAD {
|
|
|
793
790
|
}
|
|
794
791
|
await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, constrToAdd);
|
|
795
792
|
},
|
|
796
|
-
createSliderConstraint: async (
|
|
797
|
-
const [
|
|
793
|
+
createSliderConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
|
|
794
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
798
795
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
799
796
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
800
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
797
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCSliderConstraint, name);
|
|
801
798
|
if (constraintId != null) {
|
|
802
799
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
803
800
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
@@ -865,11 +862,11 @@ export default class CAD {
|
|
|
865
862
|
}
|
|
866
863
|
await assemblyBuilderAPI.updateSliderConstraints(drawingId, constrToAdd);
|
|
867
864
|
},
|
|
868
|
-
createPlanarConstraint: async (
|
|
869
|
-
const [
|
|
865
|
+
createPlanarConstraint: async (id, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
|
|
866
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
870
867
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
871
868
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
872
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
869
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCPlanarConstraint, name);
|
|
873
870
|
if (constraintId != null) {
|
|
874
871
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
875
872
|
await assemblyBuilderAPI.updatePlanarConstraints(drawingId, [
|
|
@@ -937,11 +934,11 @@ export default class CAD {
|
|
|
937
934
|
}
|
|
938
935
|
await assemblyBuilderAPI.updatePlanarConstraints(drawingId, constrToAdd);
|
|
939
936
|
},
|
|
940
|
-
createParallelConstraint: async (
|
|
941
|
-
const [
|
|
937
|
+
createParallelConstraint: async (id, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
|
|
938
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
942
939
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
943
940
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
944
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId,
|
|
941
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCParallelConstraint, name);
|
|
945
942
|
if (constraintId != null) {
|
|
946
943
|
await assemblyBuilderAPI.updateParallelConstraints(drawingId, [
|
|
947
944
|
{
|
|
@@ -1194,26 +1191,31 @@ export default class CAD {
|
|
|
1194
1191
|
}, partId, references);
|
|
1195
1192
|
},
|
|
1196
1193
|
selectGeometry: (types, count) => {
|
|
1194
|
+
const drId = this.drawingId;
|
|
1197
1195
|
return this.resolve(async ([]) => {
|
|
1198
1196
|
const filter = (scope, data) => scope === BuerliScope && types.some(type => type === data);
|
|
1199
1197
|
// Check count param. If not set use by default 1, else check if not < 1
|
|
1200
1198
|
const lCount = count ? (count < 1 ? 1 : count) : 1;
|
|
1201
|
-
const selections = await waitForSelect(lCount, filter, (resolveSelection, items, diff) => {
|
|
1199
|
+
const selections = (await waitForSelect(lCount, filter, (resolveSelection, items, diff) => {
|
|
1202
1200
|
if (items.length > lCount - 1) {
|
|
1203
1201
|
resolveSelection(items);
|
|
1204
1202
|
}
|
|
1205
|
-
});
|
|
1203
|
+
}));
|
|
1206
1204
|
const interactionInfos = [];
|
|
1207
1205
|
for (const selection of selections) {
|
|
1208
1206
|
// Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
|
|
1209
1207
|
const points = await geometryAPI.getPointsByGeometries(drawingId, [selection.data.graphicId]);
|
|
1208
|
+
const matrix = getDrawing(drId).api.structure.calculateGlobalTransformation(selection.data.productId);
|
|
1209
|
+
const clone = selection.data.geometry.clone().applyMatrix4(matrix);
|
|
1210
|
+
// TODO: Should the transform code be moved to something else than Measure? It's helpful for more cases than just measuring.
|
|
1211
|
+
const transformedData = Measure.transform([selection.data], drId)[0];
|
|
1210
1212
|
const interactionInfo = createInfo({
|
|
1211
1213
|
objectId: selection.data.container.ownerId,
|
|
1212
1214
|
prodRefId: selection.data.productId,
|
|
1213
1215
|
containerId: selection.data.container.id,
|
|
1214
1216
|
graphicId: selection.data.graphicId,
|
|
1215
1217
|
// objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
|
|
1216
|
-
userData: Object.assign(Object.assign({},
|
|
1218
|
+
userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
|
|
1217
1219
|
});
|
|
1218
1220
|
interactionInfos.push(interactionInfo);
|
|
1219
1221
|
}
|
|
@@ -1226,55 +1228,55 @@ export default class CAD {
|
|
|
1226
1228
|
return geoms;
|
|
1227
1229
|
}, partId);
|
|
1228
1230
|
},
|
|
1229
|
-
|
|
1231
|
+
getAssemblyTemplate: (asmName) => {
|
|
1230
1232
|
return this.resolve(async ([]) => {
|
|
1231
|
-
const asmIds = asmUtils.
|
|
1233
|
+
const asmIds = asmUtils.getAssemblyTemplate(drawingId, asmName);
|
|
1232
1234
|
if (asmIds != undefined) {
|
|
1233
1235
|
return Array.isArray(asmIds) ? asmIds : [asmIds];
|
|
1234
1236
|
}
|
|
1235
1237
|
return null;
|
|
1236
1238
|
});
|
|
1237
1239
|
},
|
|
1238
|
-
|
|
1239
|
-
return this.resolve(async ([
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1242
|
-
return Array.isArray(
|
|
1240
|
+
getInstance: (id, instanceName) => {
|
|
1241
|
+
return this.resolve(async ([rId]) => {
|
|
1242
|
+
const instances = asmUtils.getInstance(drawingId, rId, instanceName);
|
|
1243
|
+
if (instances != undefined) {
|
|
1244
|
+
return Array.isArray(instances) ? instances : [instances];
|
|
1243
1245
|
}
|
|
1244
1246
|
return null;
|
|
1245
|
-
},
|
|
1247
|
+
}, id);
|
|
1246
1248
|
},
|
|
1247
|
-
|
|
1248
|
-
return this.resolve(async ([
|
|
1249
|
+
getProductsOfInstances: (instanceIds) => {
|
|
1250
|
+
return this.resolve(async ([rInstanceIds]) => {
|
|
1249
1251
|
const drawing = getDrawing(drawingId);
|
|
1250
1252
|
const tree = drawing.structure.tree;
|
|
1251
1253
|
const products = [];
|
|
1252
|
-
for (const
|
|
1253
|
-
const product = asmUtils.findProduct(
|
|
1254
|
+
for (const rInstanceId of rInstanceIds) {
|
|
1255
|
+
const product = asmUtils.findProduct(rInstanceId, tree);
|
|
1254
1256
|
products.push(product);
|
|
1255
1257
|
}
|
|
1256
1258
|
return products;
|
|
1257
|
-
},
|
|
1259
|
+
}, instanceIds);
|
|
1258
1260
|
},
|
|
1259
|
-
|
|
1260
|
-
return this.resolve(async ([
|
|
1261
|
-
await assemblyBuilderAPI.
|
|
1262
|
-
},
|
|
1261
|
+
setCurrentInstance: (id) => {
|
|
1262
|
+
return this.resolve(async ([rId]) => {
|
|
1263
|
+
await assemblyBuilderAPI.setCurrentInstance(drawingId, rId);
|
|
1264
|
+
}, id);
|
|
1263
1265
|
},
|
|
1264
|
-
|
|
1266
|
+
getCurrentInstance: () => {
|
|
1265
1267
|
return this.resolve(async () => {
|
|
1266
1268
|
const drw = getDrawing(drawingId);
|
|
1267
|
-
return drw.structure.
|
|
1269
|
+
return drw.structure.currentInstance;
|
|
1268
1270
|
});
|
|
1269
1271
|
},
|
|
1270
|
-
|
|
1271
|
-
return this.resolve(async ([
|
|
1272
|
-
const coordSys = asmUtils.
|
|
1272
|
+
getTransformation: (id) => {
|
|
1273
|
+
return this.resolve(async ([rId]) => {
|
|
1274
|
+
const coordSys = asmUtils.getTransformation(drawingId, rId);
|
|
1273
1275
|
if (coordSys != undefined) {
|
|
1274
1276
|
return coordSys;
|
|
1275
1277
|
}
|
|
1276
1278
|
return null;
|
|
1277
|
-
},
|
|
1279
|
+
}, id);
|
|
1278
1280
|
},
|
|
1279
1281
|
setCurrentProduct: (productId) => {
|
|
1280
1282
|
return this.resolve(async ([rProductId]) => {
|
|
@@ -1287,33 +1289,33 @@ export default class CAD {
|
|
|
1287
1289
|
return drw.structure.currentProduct;
|
|
1288
1290
|
});
|
|
1289
1291
|
},
|
|
1290
|
-
|
|
1292
|
+
getPartTemplate: (partName) => {
|
|
1291
1293
|
return this.resolve(async ([]) => {
|
|
1292
|
-
const partIds = asmUtils.
|
|
1294
|
+
const partIds = asmUtils.getPartTemplate(drawingId, partName);
|
|
1293
1295
|
if (partIds != undefined) {
|
|
1294
1296
|
return Array.isArray(partIds) ? partIds : [partIds];
|
|
1295
1297
|
}
|
|
1296
1298
|
return null;
|
|
1297
1299
|
});
|
|
1298
1300
|
},
|
|
1299
|
-
getWorkCoordSystem: (
|
|
1300
|
-
return this.resolve(async ([
|
|
1301
|
+
getWorkCoordSystem: (id, wcsName) => {
|
|
1302
|
+
return this.resolve(async ([rId]) => {
|
|
1301
1303
|
console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
|
|
1302
|
-
const wcsIds = asmUtils.getWorkCoordSystem(drawingId,
|
|
1304
|
+
const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rId, wcsName);
|
|
1303
1305
|
if (wcsIds != undefined) {
|
|
1304
1306
|
return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
|
|
1305
1307
|
}
|
|
1306
1308
|
return null;
|
|
1307
|
-
},
|
|
1309
|
+
}, id);
|
|
1308
1310
|
},
|
|
1309
|
-
getSketchRegion: (
|
|
1310
|
-
return this.resolve(async ([
|
|
1311
|
-
const sRIds = partUtils.getSketchRegion(drawingId,
|
|
1311
|
+
getSketchRegion: (id, sketchRegionName) => {
|
|
1312
|
+
return this.resolve(async ([rId]) => {
|
|
1313
|
+
const sRIds = partUtils.getSketchRegion(drawingId, rId, sketchRegionName);
|
|
1312
1314
|
if (sRIds != undefined) {
|
|
1313
1315
|
return Array.isArray(sRIds) ? sRIds : [sRIds];
|
|
1314
1316
|
}
|
|
1315
1317
|
return null;
|
|
1316
|
-
},
|
|
1318
|
+
}, id);
|
|
1317
1319
|
},
|
|
1318
1320
|
getWorkGeometry: (refId, type, wgName) => {
|
|
1319
1321
|
return this.resolve(async ([rRefId]) => {
|
|
@@ -1334,9 +1336,9 @@ export default class CAD {
|
|
|
1334
1336
|
return null;
|
|
1335
1337
|
}, refId);
|
|
1336
1338
|
},
|
|
1337
|
-
getFastenedConstraint: (
|
|
1338
|
-
return this.resolve(async ([
|
|
1339
|
-
const constraint = asmUtils.getFastenedConstraint(drawingId,
|
|
1339
|
+
getFastenedConstraint: (id, constrName) => {
|
|
1340
|
+
return this.resolve(async ([rId]) => {
|
|
1341
|
+
const constraint = asmUtils.getFastenedConstraint(drawingId, rId, constrName);
|
|
1340
1342
|
if (constraint != undefined) {
|
|
1341
1343
|
return {
|
|
1342
1344
|
constrId: constraint.constrId,
|
|
@@ -1348,11 +1350,11 @@ export default class CAD {
|
|
|
1348
1350
|
};
|
|
1349
1351
|
}
|
|
1350
1352
|
return null;
|
|
1351
|
-
},
|
|
1353
|
+
}, id);
|
|
1352
1354
|
},
|
|
1353
|
-
getFastenedOriginConstraint: (
|
|
1354
|
-
return this.resolve(async ([
|
|
1355
|
-
const constraint = asmUtils.getFastenedOriginConstraint(drawingId,
|
|
1355
|
+
getFastenedOriginConstraint: (id, constrName) => {
|
|
1356
|
+
return this.resolve(async ([rId]) => {
|
|
1357
|
+
const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rId, constrName);
|
|
1356
1358
|
if (constraint != undefined) {
|
|
1357
1359
|
return {
|
|
1358
1360
|
constrId: constraint.constrId,
|
|
@@ -1363,11 +1365,11 @@ export default class CAD {
|
|
|
1363
1365
|
};
|
|
1364
1366
|
}
|
|
1365
1367
|
return null;
|
|
1366
|
-
},
|
|
1368
|
+
}, id);
|
|
1367
1369
|
},
|
|
1368
|
-
getRevoluteConstraint: (
|
|
1369
|
-
return this.resolve(async ([
|
|
1370
|
-
const constraint = asmUtils.getRevoluteConstraint(drawingId,
|
|
1370
|
+
getRevoluteConstraint: (id, constrName) => {
|
|
1371
|
+
return this.resolve(async ([rId]) => {
|
|
1372
|
+
const constraint = asmUtils.getRevoluteConstraint(drawingId, rId, constrName);
|
|
1371
1373
|
if (constraint != undefined) {
|
|
1372
1374
|
return {
|
|
1373
1375
|
constrId: constraint.constrId,
|
|
@@ -1378,11 +1380,11 @@ export default class CAD {
|
|
|
1378
1380
|
};
|
|
1379
1381
|
}
|
|
1380
1382
|
return null;
|
|
1381
|
-
},
|
|
1383
|
+
}, id);
|
|
1382
1384
|
},
|
|
1383
|
-
getSliderConstraint: (
|
|
1384
|
-
return this.resolve(async ([
|
|
1385
|
-
const constraint = asmUtils.getSliderConstraint(drawingId,
|
|
1385
|
+
getSliderConstraint: (id, constrName) => {
|
|
1386
|
+
return this.resolve(async ([rId]) => {
|
|
1387
|
+
const constraint = asmUtils.getSliderConstraint(drawingId, rId, constrName);
|
|
1386
1388
|
if (constraint != undefined) {
|
|
1387
1389
|
return {
|
|
1388
1390
|
constrId: constraint.constrId,
|
|
@@ -1394,11 +1396,11 @@ export default class CAD {
|
|
|
1394
1396
|
};
|
|
1395
1397
|
}
|
|
1396
1398
|
return null;
|
|
1397
|
-
},
|
|
1399
|
+
}, id);
|
|
1398
1400
|
},
|
|
1399
|
-
getPlanarConstraint: (
|
|
1400
|
-
return this.resolve(async ([
|
|
1401
|
-
const constraint = asmUtils.getPlanarConstraint(drawingId,
|
|
1401
|
+
getPlanarConstraint: (id, constrName) => {
|
|
1402
|
+
return this.resolve(async ([rId]) => {
|
|
1403
|
+
const constraint = asmUtils.getPlanarConstraint(drawingId, rId, constrName);
|
|
1402
1404
|
if (constraint != undefined) {
|
|
1403
1405
|
return {
|
|
1404
1406
|
constrId: constraint.constrId,
|
|
@@ -1411,11 +1413,11 @@ export default class CAD {
|
|
|
1411
1413
|
};
|
|
1412
1414
|
}
|
|
1413
1415
|
return null;
|
|
1414
|
-
},
|
|
1416
|
+
}, id);
|
|
1415
1417
|
},
|
|
1416
|
-
getParallelConstraint: (
|
|
1417
|
-
return this.resolve(async ([
|
|
1418
|
-
const constraint = asmUtils.getParallelConstraint(drawingId,
|
|
1418
|
+
getParallelConstraint: (id, constrName) => {
|
|
1419
|
+
return this.resolve(async ([rId]) => {
|
|
1420
|
+
const constraint = asmUtils.getParallelConstraint(drawingId, rId, constrName);
|
|
1419
1421
|
if (constraint != undefined) {
|
|
1420
1422
|
return {
|
|
1421
1423
|
constrId: constraint.constrId,
|
|
@@ -1428,11 +1430,11 @@ export default class CAD {
|
|
|
1428
1430
|
};
|
|
1429
1431
|
}
|
|
1430
1432
|
return null;
|
|
1431
|
-
},
|
|
1433
|
+
}, id);
|
|
1432
1434
|
},
|
|
1433
|
-
getCylindricalConstraint: (
|
|
1434
|
-
return this.resolve(async ([
|
|
1435
|
-
const constraint = asmUtils.getCylindricalConstraint(drawingId,
|
|
1435
|
+
getCylindricalConstraint: (id, constrName) => {
|
|
1436
|
+
return this.resolve(async ([rId]) => {
|
|
1437
|
+
const constraint = asmUtils.getCylindricalConstraint(drawingId, rId, constrName);
|
|
1436
1438
|
if (constraint != undefined) {
|
|
1437
1439
|
return {
|
|
1438
1440
|
constrId: constraint.constrId,
|
|
@@ -1443,7 +1445,7 @@ export default class CAD {
|
|
|
1443
1445
|
};
|
|
1444
1446
|
}
|
|
1445
1447
|
return null;
|
|
1446
|
-
},
|
|
1448
|
+
}, id);
|
|
1447
1449
|
},
|
|
1448
1450
|
getFeatureByName: (partId, featureName) => {
|
|
1449
1451
|
return this.resolve(async ([rProductId]) => {
|
|
@@ -1454,19 +1456,19 @@ export default class CAD {
|
|
|
1454
1456
|
return null;
|
|
1455
1457
|
}, partId);
|
|
1456
1458
|
},
|
|
1457
|
-
getGeometryInformation: (
|
|
1458
|
-
return this.resolve(async ([
|
|
1459
|
-
const values = await baseModelerAPI.getGeometryInformation(drawingId,
|
|
1459
|
+
getGeometryInformation: (id) => {
|
|
1460
|
+
return this.resolve(async ([rId]) => {
|
|
1461
|
+
const values = await baseModelerAPI.getGeometryInformation(drawingId, rId);
|
|
1460
1462
|
if (values !== null) {
|
|
1461
1463
|
return { centerOfGravity: values[0], volume: values[1] };
|
|
1462
1464
|
}
|
|
1463
1465
|
return null;
|
|
1464
|
-
},
|
|
1466
|
+
}, id);
|
|
1465
1467
|
},
|
|
1466
|
-
|
|
1467
|
-
return this.resolve(async ([...
|
|
1468
|
-
return assemblyBuilderAPI.
|
|
1469
|
-
}, ...
|
|
1468
|
+
removeInstances: (...instances) => {
|
|
1469
|
+
return this.resolve(async ([...rInstances]) => {
|
|
1470
|
+
return assemblyBuilderAPI.removeInstances(drawingId, rInstances);
|
|
1471
|
+
}, ...instances);
|
|
1470
1472
|
},
|
|
1471
1473
|
importFeature: (partId, content, format, name) => {
|
|
1472
1474
|
return this.resolve(async ([rPartId]) => {
|
|
@@ -1522,40 +1524,40 @@ export default class CAD {
|
|
|
1522
1524
|
await sketcherAPI.setSketchRefs(drawingId, rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
|
|
1523
1525
|
}, sketchId, planeId, axisId, originId);
|
|
1524
1526
|
},
|
|
1525
|
-
|
|
1527
|
+
transformInstances: async (...instances) => {
|
|
1526
1528
|
var e_11, _a;
|
|
1527
|
-
const
|
|
1529
|
+
const instancesToTransform = [];
|
|
1528
1530
|
try {
|
|
1529
|
-
for (var
|
|
1530
|
-
const
|
|
1531
|
-
const [
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1534
|
-
transformation:
|
|
1531
|
+
for (var instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = await instances_2.next(), !instances_2_1.done;) {
|
|
1532
|
+
const instance = instances_2_1.value;
|
|
1533
|
+
const [rInstanceId] = await new Promise(res => this.resolve(id => res(id), instance.id));
|
|
1534
|
+
const instanceParam = {
|
|
1535
|
+
id: rInstanceId,
|
|
1536
|
+
transformation: instance.transformation,
|
|
1535
1537
|
options: { isLocal: true }, // in non-interactive mode, the transformation is local to the owner
|
|
1536
1538
|
};
|
|
1537
|
-
|
|
1539
|
+
instancesToTransform.push(instanceParam);
|
|
1538
1540
|
}
|
|
1539
1541
|
}
|
|
1540
1542
|
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1541
1543
|
finally {
|
|
1542
1544
|
try {
|
|
1543
|
-
if (
|
|
1545
|
+
if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
|
|
1544
1546
|
}
|
|
1545
1547
|
finally { if (e_11) throw e_11.error; }
|
|
1546
1548
|
}
|
|
1547
|
-
return assemblyBuilderAPI.
|
|
1549
|
+
return assemblyBuilderAPI.transformInstances(drawingId, instancesToTransform);
|
|
1548
1550
|
},
|
|
1549
|
-
translate: (partId,
|
|
1550
|
-
return this.resolve(async ([rPartId,
|
|
1551
|
+
translate: (partId, operations, references, inverted, distance) => {
|
|
1552
|
+
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
1551
1553
|
const translationId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCTranslation, 'Translate');
|
|
1552
1554
|
if (translationId !== null) {
|
|
1553
1555
|
const cDrawing = await getDrawing(drawingId);
|
|
1554
1556
|
const entArray = [];
|
|
1555
|
-
for (const
|
|
1556
|
-
const
|
|
1557
|
-
if (
|
|
1558
|
-
entArray.push(
|
|
1557
|
+
for (const rOperation of rOperations) {
|
|
1558
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
1559
|
+
if (entities != undefined) {
|
|
1560
|
+
entArray.push(entities[0]);
|
|
1559
1561
|
}
|
|
1560
1562
|
}
|
|
1561
1563
|
const dist = { value: distance, isExpr: typeof distance === 'string' };
|
|
@@ -1563,7 +1565,7 @@ export default class CAD {
|
|
|
1563
1565
|
return translationId;
|
|
1564
1566
|
}
|
|
1565
1567
|
return null;
|
|
1566
|
-
}, partId,
|
|
1568
|
+
}, partId, operations, ...references);
|
|
1567
1569
|
},
|
|
1568
1570
|
// TODO: Remove this method. Is it necessary?
|
|
1569
1571
|
updateTranslate: (translationId, distance) => {
|
|
@@ -1588,11 +1590,11 @@ export default class CAD {
|
|
|
1588
1590
|
saveToUrl: (url, filetype) => {
|
|
1589
1591
|
return baseModelerAPI.saveToUrl(drawingId, url, filetype);
|
|
1590
1592
|
},
|
|
1591
|
-
load: (content, type) => {
|
|
1592
|
-
return baseModelerAPI.load(drawingId, content, type);
|
|
1593
|
+
load: (content, type, options) => {
|
|
1594
|
+
return baseModelerAPI.load(drawingId, content, type, '', options);
|
|
1593
1595
|
},
|
|
1594
|
-
loadFromUrl: (url, filetype) => {
|
|
1595
|
-
return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true);
|
|
1596
|
+
loadFromUrl: (url, filetype, options) => {
|
|
1597
|
+
return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true, options);
|
|
1596
1598
|
},
|
|
1597
1599
|
loadProduct: (content, type, options) => {
|
|
1598
1600
|
return assemblyBuilderAPI.loadProduct(drawingId, content, type, '', options);
|
|
@@ -1653,16 +1655,16 @@ export default class CAD {
|
|
|
1653
1655
|
return null;
|
|
1654
1656
|
}, partId, ...references);
|
|
1655
1657
|
},
|
|
1656
|
-
mirror: async (partId,
|
|
1658
|
+
mirror: async (partId, operations, references) => {
|
|
1657
1659
|
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
1658
|
-
const
|
|
1660
|
+
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
1659
1661
|
const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
|
|
1660
1662
|
const cDrawing = getDrawing(drawingId);
|
|
1661
1663
|
const entArray = [];
|
|
1662
|
-
for (const
|
|
1663
|
-
const
|
|
1664
|
-
if (
|
|
1665
|
-
entArray.push(
|
|
1664
|
+
for (const rOperation of rOperations) {
|
|
1665
|
+
const entities = cDrawing.structure.tree[rOperation].children;
|
|
1666
|
+
if (entities != undefined) {
|
|
1667
|
+
entArray.push(entities[0]);
|
|
1666
1668
|
}
|
|
1667
1669
|
}
|
|
1668
1670
|
const mirrorId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCMirror, 'Mirror');
|