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