@buerli.io/headless 0.7.1 → 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.
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __asyncValues = (this && this.__asyncValues) || function (o) {
26
3
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
27
4
  var m = o[Symbol.asyncIterator], i;
@@ -34,7 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
11
  const classcad_1 = require("@buerli.io/classcad");
35
12
  const core_1 = require("@buerli.io/core");
36
13
  const three_1 = require("three");
37
- const BufferGeometryUtils_ = __importStar(require("three/examples/jsm/utils/BufferGeometryUtils"));
14
+ const three_stdlib_1 = require("three-stdlib");
38
15
  const selection_1 = require("./utils/selection");
39
16
  const meshes_1 = require("./utils/meshes");
40
17
  const featureAPI = classcad_1.ccAPI.feature;
@@ -46,16 +23,6 @@ const geometryAPI = classcad_1.ccAPI.geometry;
46
23
  const baseUtils = classcad_1.ccUtils.base;
47
24
  const asmUtils = classcad_1.ccUtils.assembly;
48
25
  const partUtils = classcad_1.ccUtils.part;
49
- let BufferGeometryUtils = BufferGeometryUtils_;
50
- if (BufferGeometryUtils.BufferGeometryUtils) {
51
- BufferGeometryUtils = BufferGeometryUtils.BufferGeometryUtils;
52
- }
53
- const resolveVec = (value) => {
54
- if (Array.isArray(value))
55
- return { x: value[0], y: value[1], z: value[2] };
56
- else
57
- return value;
58
- };
59
26
  /**
60
27
  * Returns the cclass of the given dimension type
61
28
  * @param type type of the dimension as string
@@ -104,7 +71,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
104
71
  }
105
72
  if (geometries.length > 0) {
106
73
  const transformation = cDrawing.api.structure.calculateGlobalTransformation(object.id);
107
- const bufferGeom = BufferGeometryUtils.mergeBufferGeometries(geometries);
74
+ const bufferGeom = (0, three_stdlib_1.mergeBufferGeometries)(geometries);
108
75
  bufferGeom.applyMatrix4(transformation);
109
76
  bufferGeomArray.push(bufferGeom);
110
77
  }
@@ -141,8 +108,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
141
108
  const matrix = object.coordinateSystem ? core_1.MathUtils.convertToMatrix4(object.coordinateSystem) : new three_1.Matrix4();
142
109
  matrix.decompose(part.position, part.quaternion, part.scale);
143
110
  part.updateMatrix();
144
- part.userData = { id: object.id }; // product reference id
145
- part.name = object.name; // product reference name
111
+ part.userData = { id: object.id }; // instance id
112
+ part.name = object.name; // instance name
146
113
  for (const entity of entities) {
147
114
  let cachedEntity = cDrawing.geometry.cache[entity];
148
115
  if (!cachedEntity) {
@@ -190,7 +157,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
190
157
  mesh.name = solidObject.name + '_' + i;
191
158
  mesh.userData = { id: solidObject.id }; // add solid id to the userData
192
159
  if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
193
- mesh.geometry = (BufferGeometryUtils.mergeBufferGeometries || BufferGeometryUtils.mergeGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
160
+ mesh.geometry = (0, three_stdlib_1.mergeBufferGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
194
161
  mesh.material = new three_1.MeshStandardMaterial({
195
162
  color: colorMeshesMap[key].color,
196
163
  transparent: colorMeshesMap[key].opacity < 1,
@@ -212,7 +179,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
212
179
  mesh.name = solidObject.name;
213
180
  mesh.userData = { id: solidObject.id }; // add solid id to the userData
214
181
  if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
215
- mesh.geometry = (BufferGeometryUtils.mergeBufferGeometries || BufferGeometryUtils.mergeGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
182
+ mesh.geometry = (0, three_stdlib_1.mergeBufferGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
216
183
  mesh.material = new three_1.MeshStandardMaterial({
217
184
  color: colorMeshesMap[key].color,
218
185
  transparent: colorMeshesMap[key].opacity < 1,
@@ -238,8 +205,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
238
205
  const matrix = object.coordinateSystem ? core_1.MathUtils.convertToMatrix4(object.coordinateSystem) : new three_1.Matrix4();
239
206
  matrix.decompose(assembly.position, assembly.quaternion, assembly.scale);
240
207
  assembly.updateMatrix();
241
- assembly.userData = { id: object.id }; // assembly root or product reference id
242
- assembly.name = object.name; // assembly root or product reference name
208
+ assembly.userData = { id: object.id }; // assembly root or instance id
209
+ assembly.name = object.name; // assembly root or instance name
243
210
  result.nodes[assembly.name] = assembly;
244
211
  root.add(assembly);
245
212
  for (const child of object.children) {
@@ -249,28 +216,11 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
249
216
  }
250
217
  }
251
218
  };
252
- /**
253
- * Helper function to log relevant points to find geometry to the console.
254
- * This helps the user to copy the points directly from console to parameter of
255
- * findOrSelect() method.
256
- * @param points Array of points array to log to the console
257
- */
258
- const logPoints = (points) => {
259
- let log = 'Relevant points of selected gometry = [[';
260
- if (points && points.length > 0) {
261
- for (let i = 0; i < points.length; i++) {
262
- for (let j = 0; j < points[i].length; j++) {
263
- const point = resolveVec(points[i][j]);
264
- const x = Math.round(point.x * 1000) / 1000;
265
- const y = Math.round(point.y * 1000) / 1000;
266
- const z = Math.round(point.z * 1000) / 1000;
267
- log += '{ x: ' + x + ', y: ' + y + ', z: ' + z + '}';
268
- log += points[i].length - 1 === j ? '' : ',';
269
- }
270
- log += points.length - 1 === i ? ']]' : '],[';
271
- }
272
- console.info(log);
273
- }
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;
274
224
  };
275
225
  class CAD {
276
226
  constructor() {
@@ -292,31 +242,31 @@ class CAD {
292
242
  throw new Error('Drawing could not be created');
293
243
  this.drawingId = drawingId;
294
244
  const publicApi = {
295
- addNodes: async (...nodes) => {
245
+ addInstances: async (...instances) => {
296
246
  var e_1, _a;
297
- const nodesToAdd = [];
247
+ const instancesToAdd = [];
298
248
  try {
299
- for (var nodes_1 = __asyncValues(nodes), nodes_1_1; nodes_1_1 = await nodes_1.next(), !nodes_1_1.done;) {
300
- const node = nodes_1_1.value;
301
- const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), node.productId, node.ownerId));
302
- const nodeParam = {
303
- referenceId: rProductId,
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,
304
254
  ownerId: rOwnerId,
305
- transformation: node.transformation,
306
- name: node.name,
307
- options: Object.assign(Object.assign({}, node.options), { isLocal: true }), // in non-interactive mode, the transformation is local to the owner
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
308
258
  };
309
- nodesToAdd.push(nodeParam);
259
+ instancesToAdd.push(instanceParam);
310
260
  }
311
261
  }
312
262
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
313
263
  finally {
314
264
  try {
315
- if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) await _a.call(nodes_1);
265
+ if (instances_1_1 && !instances_1_1.done && (_a = instances_1.return)) await _a.call(instances_1);
316
266
  }
317
267
  finally { if (e_1) throw e_1.error; }
318
268
  }
319
- return assemblyBuilderAPI.addNodes(drawingId, nodesToAdd);
269
+ return assemblyBuilderAPI.addInstances(drawingId, instancesToAdd);
320
270
  },
321
271
  addDimensions: async (...dimensions) => {
322
272
  var e_2, _a;
@@ -396,17 +346,17 @@ class CAD {
396
346
  return drawing2DAPI.removeDimensions(drawingId, rDimensionIds);
397
347
  }, ...dimensionIds);
398
348
  },
399
- linearPattern: (partId, entities, references1, params1, references2, params2) => {
400
- return this.resolve(async ([rPartId, rEntities, rReferences1, rReferences2]) => {
349
+ linearPattern: (partId, operations, references1, params1, references2, params2) => {
350
+ return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
401
351
  const patternId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCLinearPattern, 'LinearPattern');
402
352
  if (patternId != null) {
403
353
  // entities
404
354
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
405
355
  const entArray = [];
406
- for (const rEntity of rEntities) {
407
- const entity = cDrawing.structure.tree[(await rEntity)].children;
408
- if (entity != undefined) {
409
- entArray.push(entity[0]);
356
+ for (const rOperation of rOperations) {
357
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
358
+ if (entities != undefined) {
359
+ entArray.push(entities[0]);
410
360
  }
411
361
  }
412
362
  const distance1Param = {
@@ -454,19 +404,19 @@ class CAD {
454
404
  return patternId;
455
405
  }
456
406
  return null;
457
- }, partId, entities, references1, references2);
407
+ }, partId, operations, references1, references2);
458
408
  },
459
- circularPattern: (partId, entities, references, params) => {
460
- return this.resolve(async ([rPartId, rEntities, ...rReferences]) => {
409
+ circularPattern: (partId, operations, references, params) => {
410
+ return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
461
411
  const patternId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCCircularPattern, 'CircularPattern');
462
412
  if (patternId != null) {
463
413
  // entities
464
414
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
465
415
  const entArray = [];
466
- for (const rEntity of rEntities) {
467
- const entity = cDrawing.structure.tree[(await rEntity)].children;
468
- if (entity != undefined) {
469
- entArray.push(entity[0]);
416
+ for (const rOperation of rOperations) {
417
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
418
+ if (entities != undefined) {
419
+ entArray.push(entities[0]);
470
420
  }
471
421
  }
472
422
  const angleParam = { value: params.angle, isExpr: typeof params.angle === 'string' };
@@ -482,11 +432,11 @@ class CAD {
482
432
  return patternId;
483
433
  }
484
434
  return null;
485
- }, partId, entities, ...references);
435
+ }, partId, operations, ...references);
486
436
  },
487
437
  extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
488
438
  return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
489
- const extrusion = await featureAPI.createExtrusion(drawingId, rPartId);
439
+ const extrusion = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCExtrusion, 'Extrusion');
490
440
  if (extrusion) {
491
441
  const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
492
442
  if (sketchLines) {
@@ -508,7 +458,7 @@ class CAD {
508
458
  },
509
459
  revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
510
460
  return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
511
- const revolve = await featureAPI.createRevolve(drawingId, rPartId);
461
+ const revolve = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCRevolve, 'Revolve');
512
462
  if (revolve) {
513
463
  const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
514
464
  if (sketchLines) {
@@ -520,26 +470,23 @@ class CAD {
520
470
  }
521
471
  }, partId, sketchOrRegionIds, ...axisIds);
522
472
  },
523
- boolean: (partId, type, entities) => {
524
- return this.resolve(async ([rPartId, rEntities]) => {
473
+ boolean: (partId, type, operations) => {
474
+ return this.resolve(async ([rPartId, rOperations]) => {
525
475
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
526
476
  const entArray = [];
527
- for (const rEntity of rEntities) {
528
- const entity = cDrawing.structure.tree[(await rEntity)].children;
529
- if (entity != undefined) {
530
- entArray.push(entity[0]);
477
+ for (const rOperation of rOperations) {
478
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
479
+ if (entities != undefined) {
480
+ entArray.push(entities[0]);
531
481
  }
532
482
  }
533
- const boolId = await featureAPI.createBooleanOperation(drawingId, rPartId, {
534
- type,
535
- entities: entArray,
536
- });
483
+ const boolId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCUnion, 'Union');
537
484
  if (boolId != null) {
538
485
  await featureAPI.updateBooleanOperation(drawingId, boolId, type, entArray);
539
486
  return boolId;
540
487
  }
541
488
  return null;
542
- }, partId, entities);
489
+ }, partId, operations);
543
490
  },
544
491
  box: (partId, references, width, length, height) => {
545
492
  return this.resolve(async ([rPartId, ...rReferences]) => {
@@ -592,11 +539,11 @@ class CAD {
592
539
  return null;
593
540
  }, partId, ...references);
594
541
  },
595
- createFastenedConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffset, name) => {
596
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
597
544
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
598
545
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
599
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedConstraint, name);
546
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCFastenedConstraint, name);
600
547
  if (constraintId != null) {
601
548
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
602
549
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -656,10 +603,10 @@ class CAD {
656
603
  }
657
604
  await assemblyBuilderAPI.updateFastenedConstraints(drawingId, constrToAdd);
658
605
  },
659
- createFastenedOriginConstraint: async (asmId, mate1, xOffset, yOffset, zOffset, name) => {
660
- const [rAsmId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId));
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));
661
608
  const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
662
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedOriginConstraint, name);
609
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCFastenedOriginConstraint, name);
663
610
  if (constraintId != null) {
664
611
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
665
612
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -711,11 +658,11 @@ class CAD {
711
658
  }
712
659
  await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
713
660
  },
714
- createCylindricalConstraint: async (asmId, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
715
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
716
663
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
717
664
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
718
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCCylindricalConstraint, name);
665
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCCylindricalConstraint, name);
719
666
  if (constraintId != null) {
720
667
  await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, [
721
668
  {
@@ -777,11 +724,11 @@ class CAD {
777
724
  }
778
725
  await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, constrToAdd);
779
726
  },
780
- createRevoluteConstraint: async (asmId, mate1, mate2, zOffset, zRotationLimits, name) => {
781
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
782
729
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
783
730
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
784
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCRevoluteConstraint, name);
731
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCRevoluteConstraint, name);
785
732
  if (constraintId != null) {
786
733
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
787
734
  await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, [
@@ -845,11 +792,11 @@ class CAD {
845
792
  }
846
793
  await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, constrToAdd);
847
794
  },
848
- createSliderConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
849
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
850
797
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
851
798
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
852
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCSliderConstraint, name);
799
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCSliderConstraint, name);
853
800
  if (constraintId != null) {
854
801
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
855
802
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -917,11 +864,11 @@ class CAD {
917
864
  }
918
865
  await assemblyBuilderAPI.updateSliderConstraints(drawingId, constrToAdd);
919
866
  },
920
- createPlanarConstraint: async (asmId, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
921
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
922
869
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
923
870
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
924
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCPlanarConstraint, name);
871
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCPlanarConstraint, name);
925
872
  if (constraintId != null) {
926
873
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
927
874
  await assemblyBuilderAPI.updatePlanarConstraints(drawingId, [
@@ -989,11 +936,11 @@ class CAD {
989
936
  }
990
937
  await assemblyBuilderAPI.updatePlanarConstraints(drawingId, constrToAdd);
991
938
  },
992
- createParallelConstraint: async (asmId, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
993
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
994
941
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
995
942
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
996
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCParallelConstraint, name);
943
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCParallelConstraint, name);
997
944
  if (constraintId != null) {
998
945
  await assemblyBuilderAPI.updateParallelConstraints(drawingId, [
999
946
  {
@@ -1179,10 +1126,10 @@ class CAD {
1179
1126
  return null;
1180
1127
  }, partId, ...references);
1181
1128
  },
1182
- createWorkCoordSystem: (partId, type, references, coordinateSystem, offset, rotation, inverted = false, local = false, name) => {
1129
+ createWorkCoordSystem: (partId, type, references, offset, rotation, inverted = false, name) => {
1183
1130
  return this.resolve(async ([rPartId, ...rReferences]) => {
1184
1131
  const wCSName = name ? name : 'WorkCoordSystem';
1185
- const wCSId = await featureAPI.createWorkGeometry(drawingId, rPartId, classcad_1.CCClasses.CCWorkCoordSystem, wCSName);
1132
+ const wCSId = await featureAPI.createWorkGeometry(drawingId, rPartId, classcad_1.CCClasses.CCWorkCSys, wCSName);
1186
1133
  if (wCSId != null) {
1187
1134
  const offsetParam = {
1188
1135
  value: resolveVec(offset),
@@ -1192,7 +1139,7 @@ class CAD {
1192
1139
  value: resolveVec(rotation),
1193
1140
  isExpr: typeof rotation === 'string',
1194
1141
  };
1195
- await featureAPI.updateWorkCoordSystem(drawingId, wCSId, type, rReferences, coordinateSystem.map(resolveVec), offsetParam, rotationParam, inverted ? 1 : 0, local);
1142
+ await featureAPI.updateWorkCSys(drawingId, wCSId, type, rReferences, offsetParam, rotationParam, inverted ? 1 : 0);
1196
1143
  return wCSId;
1197
1144
  }
1198
1145
  return null;
@@ -1245,87 +1192,93 @@ class CAD {
1245
1192
  return null;
1246
1193
  }, partId, references);
1247
1194
  },
1248
- findOrSelect: (partId, type, length, positions) => {
1249
- return this.resolve(async ([rPartId]) => {
1250
- let filter = core_1.lineSegmentsFilter;
1251
- switch (type) {
1252
- case 0: // Vertex
1253
- filter = core_1.pointFilter;
1254
- break;
1255
- case 1: // Edge
1256
- filter = core_1.lineSegmentsFilter;
1257
- break;
1258
- case 2: // Loop
1259
- filter = core_1.loopFilter;
1260
- break;
1261
- case 3: // Face
1262
- filter = core_1.planeFilter;
1263
- break;
1264
- }
1265
- const geometries = positions
1266
- ? await geometryAPI.findGeometriesByPoints(drawingId, rPartId, type, positions.map(p => p.map(resolveVec)))
1267
- : await (0, selection_1.waitForSelect)(length, filter, (resolveSelection, items, diff) => {
1268
- if (items.length > length - 1) {
1269
- resolveSelection(items.map(i => i.data.graphicId));
1270
- geometryAPI
1271
- .getPointsByGeometries(drawingId, items.map(i => i.data.graphicId))
1272
- .then(points => {
1273
- logPoints(points);
1274
- });
1275
- }
1195
+ selectGeometry: (types, count) => {
1196
+ const drId = this.drawingId;
1197
+ return this.resolve(async ([]) => {
1198
+ const filter = (scope, data) => scope === core_1.BuerliScope && types.some(type => type === data);
1199
+ // Check count param. If not set use by default 1, else check if not < 1
1200
+ const lCount = count ? (count < 1 ? 1 : count) : 1;
1201
+ const selections = (await (0, selection_1.waitForSelect)(lCount, filter, (resolveSelection, items, diff) => {
1202
+ if (items.length > lCount - 1) {
1203
+ resolveSelection(items);
1204
+ }
1205
+ }));
1206
+ const interactionInfos = [];
1207
+ for (const selection of selections) {
1208
+ // Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
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];
1214
+ const interactionInfo = (0, core_1.createInfo)({
1215
+ objectId: selection.data.container.ownerId,
1216
+ prodRefId: selection.data.productId,
1217
+ containerId: selection.data.container.id,
1218
+ graphicId: selection.data.graphicId,
1219
+ // objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
1220
+ userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
1276
1221
  });
1277
- return geometries;
1222
+ interactionInfos.push(interactionInfo);
1223
+ }
1224
+ return interactionInfos;
1225
+ });
1226
+ },
1227
+ findGeometry: (partId, type, positions) => {
1228
+ return this.resolve(async ([rPartId]) => {
1229
+ const geoms = await geometryAPI.findGeometriesByPoints(drawingId, rPartId, type, positions.map(p => p.map(resolveVec)));
1230
+ return geoms;
1278
1231
  }, partId);
1279
1232
  },
1280
- getAssemblyFromContainer: (asmName) => {
1233
+ getAssemblyTemplate: (asmName) => {
1281
1234
  return this.resolve(async ([]) => {
1282
- const asmIds = asmUtils.getAssemblyFromContainer(drawingId, asmName);
1235
+ const asmIds = asmUtils.getAssemblyTemplate(drawingId, asmName);
1283
1236
  if (asmIds != undefined) {
1284
1237
  return Array.isArray(asmIds) ? asmIds : [asmIds];
1285
1238
  }
1286
1239
  return null;
1287
1240
  });
1288
1241
  },
1289
- getAssemblyNode: (refId, nodeName) => {
1290
- return this.resolve(async ([rRefId]) => {
1291
- const nodeIds = asmUtils.getAssemblyNode(drawingId, rRefId, nodeName);
1292
- if (nodeIds != undefined) {
1293
- return Array.isArray(nodeIds) ? nodeIds : [nodeIds];
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];
1294
1247
  }
1295
1248
  return null;
1296
- }, refId);
1249
+ }, id);
1297
1250
  },
1298
- getProductOfNode: (refIds) => {
1299
- return this.resolve(async ([rRefIds]) => {
1251
+ getProductsOfInstances: (instanceIds) => {
1252
+ return this.resolve(async ([rInstanceIds]) => {
1300
1253
  const drawing = (0, core_1.getDrawing)(drawingId);
1301
1254
  const tree = drawing.structure.tree;
1302
1255
  const products = [];
1303
- for (const rRefId of rRefIds) {
1304
- const product = asmUtils.findProduct(rRefId, tree);
1256
+ for (const rInstanceId of rInstanceIds) {
1257
+ const product = asmUtils.findProduct(rInstanceId, tree);
1305
1258
  products.push(product);
1306
1259
  }
1307
1260
  return products;
1308
- }, refIds);
1261
+ }, instanceIds);
1309
1262
  },
1310
- setCurrentNode: (refId) => {
1311
- return this.resolve(async ([rRefId]) => {
1312
- await assemblyBuilderAPI.setCurrentNode(drawingId, rRefId);
1313
- }, refId);
1263
+ setCurrentInstance: (id) => {
1264
+ return this.resolve(async ([rId]) => {
1265
+ await assemblyBuilderAPI.setCurrentInstance(drawingId, rId);
1266
+ }, id);
1314
1267
  },
1315
- getCurrentNode: () => {
1268
+ getCurrentInstance: () => {
1316
1269
  return this.resolve(async () => {
1317
1270
  const drw = (0, core_1.getDrawing)(drawingId);
1318
- return drw.structure.currentNode;
1271
+ return drw.structure.currentInstance;
1319
1272
  });
1320
1273
  },
1321
- getCoordSysFromNode: (refId) => {
1322
- return this.resolve(async ([rRefId]) => {
1323
- const coordSys = asmUtils.getCoordSysFromNode(drawingId, rRefId);
1274
+ getTransformation: (id) => {
1275
+ return this.resolve(async ([rId]) => {
1276
+ const coordSys = asmUtils.getTransformation(drawingId, rId);
1324
1277
  if (coordSys != undefined) {
1325
1278
  return coordSys;
1326
1279
  }
1327
1280
  return null;
1328
- }, refId);
1281
+ }, id);
1329
1282
  },
1330
1283
  setCurrentProduct: (productId) => {
1331
1284
  return this.resolve(async ([rProductId]) => {
@@ -1338,33 +1291,33 @@ class CAD {
1338
1291
  return drw.structure.currentProduct;
1339
1292
  });
1340
1293
  },
1341
- getPartFromContainer: (partName) => {
1294
+ getPartTemplate: (partName) => {
1342
1295
  return this.resolve(async ([]) => {
1343
- const partIds = asmUtils.getPartFromContainer(drawingId, partName);
1296
+ const partIds = asmUtils.getPartTemplate(drawingId, partName);
1344
1297
  if (partIds != undefined) {
1345
1298
  return Array.isArray(partIds) ? partIds : [partIds];
1346
1299
  }
1347
1300
  return null;
1348
1301
  });
1349
1302
  },
1350
- getWorkCoordSystem: (refId, wcsName) => {
1351
- return this.resolve(async ([rRefId]) => {
1303
+ getWorkCoordSystem: (id, wcsName) => {
1304
+ return this.resolve(async ([rId]) => {
1352
1305
  console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
1353
- const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rRefId, wcsName);
1306
+ const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rId, wcsName);
1354
1307
  if (wcsIds != undefined) {
1355
1308
  return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
1356
1309
  }
1357
1310
  return null;
1358
- }, refId);
1311
+ }, id);
1359
1312
  },
1360
- getSketchRegion: (refId, sketchRegionName) => {
1361
- return this.resolve(async ([rRefId]) => {
1362
- const sRIds = partUtils.getSketchRegion(drawingId, rRefId, sketchRegionName);
1313
+ getSketchRegion: (id, sketchRegionName) => {
1314
+ return this.resolve(async ([rId]) => {
1315
+ const sRIds = partUtils.getSketchRegion(drawingId, rId, sketchRegionName);
1363
1316
  if (sRIds != undefined) {
1364
1317
  return Array.isArray(sRIds) ? sRIds : [sRIds];
1365
1318
  }
1366
1319
  return null;
1367
- }, refId);
1320
+ }, id);
1368
1321
  },
1369
1322
  getWorkGeometry: (refId, type, wgName) => {
1370
1323
  return this.resolve(async ([rRefId]) => {
@@ -1385,9 +1338,9 @@ class CAD {
1385
1338
  return null;
1386
1339
  }, refId);
1387
1340
  },
1388
- getFastenedConstraint: (refId, constrName) => {
1389
- return this.resolve(async ([rRefId]) => {
1390
- const constraint = asmUtils.getFastenedConstraint(drawingId, rRefId, constrName);
1341
+ getFastenedConstraint: (id, constrName) => {
1342
+ return this.resolve(async ([rId]) => {
1343
+ const constraint = asmUtils.getFastenedConstraint(drawingId, rId, constrName);
1391
1344
  if (constraint != undefined) {
1392
1345
  return {
1393
1346
  constrId: constraint.constrId,
@@ -1399,11 +1352,11 @@ class CAD {
1399
1352
  };
1400
1353
  }
1401
1354
  return null;
1402
- }, refId);
1355
+ }, id);
1403
1356
  },
1404
- getFastenedOriginConstraint: (refId, constrName) => {
1405
- return this.resolve(async ([rRefId]) => {
1406
- const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rRefId, constrName);
1357
+ getFastenedOriginConstraint: (id, constrName) => {
1358
+ return this.resolve(async ([rId]) => {
1359
+ const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rId, constrName);
1407
1360
  if (constraint != undefined) {
1408
1361
  return {
1409
1362
  constrId: constraint.constrId,
@@ -1414,11 +1367,11 @@ class CAD {
1414
1367
  };
1415
1368
  }
1416
1369
  return null;
1417
- }, refId);
1370
+ }, id);
1418
1371
  },
1419
- getRevoluteConstraint: (refId, constrName) => {
1420
- return this.resolve(async ([rRefId]) => {
1421
- const constraint = asmUtils.getRevoluteConstraint(drawingId, rRefId, constrName);
1372
+ getRevoluteConstraint: (id, constrName) => {
1373
+ return this.resolve(async ([rId]) => {
1374
+ const constraint = asmUtils.getRevoluteConstraint(drawingId, rId, constrName);
1422
1375
  if (constraint != undefined) {
1423
1376
  return {
1424
1377
  constrId: constraint.constrId,
@@ -1429,11 +1382,11 @@ class CAD {
1429
1382
  };
1430
1383
  }
1431
1384
  return null;
1432
- }, refId);
1385
+ }, id);
1433
1386
  },
1434
- getSliderConstraint: (refId, constrName) => {
1435
- return this.resolve(async ([rRefId]) => {
1436
- const constraint = asmUtils.getSliderConstraint(drawingId, rRefId, constrName);
1387
+ getSliderConstraint: (id, constrName) => {
1388
+ return this.resolve(async ([rId]) => {
1389
+ const constraint = asmUtils.getSliderConstraint(drawingId, rId, constrName);
1437
1390
  if (constraint != undefined) {
1438
1391
  return {
1439
1392
  constrId: constraint.constrId,
@@ -1445,11 +1398,11 @@ class CAD {
1445
1398
  };
1446
1399
  }
1447
1400
  return null;
1448
- }, refId);
1401
+ }, id);
1449
1402
  },
1450
- getPlanarConstraint: (refId, constrName) => {
1451
- return this.resolve(async ([rRefId]) => {
1452
- const constraint = asmUtils.getPlanarConstraint(drawingId, rRefId, constrName);
1403
+ getPlanarConstraint: (id, constrName) => {
1404
+ return this.resolve(async ([rId]) => {
1405
+ const constraint = asmUtils.getPlanarConstraint(drawingId, rId, constrName);
1453
1406
  if (constraint != undefined) {
1454
1407
  return {
1455
1408
  constrId: constraint.constrId,
@@ -1462,11 +1415,11 @@ class CAD {
1462
1415
  };
1463
1416
  }
1464
1417
  return null;
1465
- }, refId);
1418
+ }, id);
1466
1419
  },
1467
- getParallelConstraint: (refId, constrName) => {
1468
- return this.resolve(async ([rRefId]) => {
1469
- const constraint = asmUtils.getParallelConstraint(drawingId, rRefId, constrName);
1420
+ getParallelConstraint: (id, constrName) => {
1421
+ return this.resolve(async ([rId]) => {
1422
+ const constraint = asmUtils.getParallelConstraint(drawingId, rId, constrName);
1470
1423
  if (constraint != undefined) {
1471
1424
  return {
1472
1425
  constrId: constraint.constrId,
@@ -1479,11 +1432,11 @@ class CAD {
1479
1432
  };
1480
1433
  }
1481
1434
  return null;
1482
- }, refId);
1435
+ }, id);
1483
1436
  },
1484
- getCylindricalConstraint: (refId, constrName) => {
1485
- return this.resolve(async ([rRefId]) => {
1486
- const constraint = asmUtils.getCylindricalConstraint(drawingId, rRefId, constrName);
1437
+ getCylindricalConstraint: (id, constrName) => {
1438
+ return this.resolve(async ([rId]) => {
1439
+ const constraint = asmUtils.getCylindricalConstraint(drawingId, rId, constrName);
1487
1440
  if (constraint != undefined) {
1488
1441
  return {
1489
1442
  constrId: constraint.constrId,
@@ -1494,7 +1447,7 @@ class CAD {
1494
1447
  };
1495
1448
  }
1496
1449
  return null;
1497
- }, refId);
1450
+ }, id);
1498
1451
  },
1499
1452
  getFeatureByName: (partId, featureName) => {
1500
1453
  return this.resolve(async ([rProductId]) => {
@@ -1505,19 +1458,19 @@ class CAD {
1505
1458
  return null;
1506
1459
  }, partId);
1507
1460
  },
1508
- getGeometryInformation: (objectId) => {
1509
- return this.resolve(async ([rProductOrSolidId]) => {
1510
- const values = await baseModelerAPI.getGeometryInformation(drawingId, rProductOrSolidId);
1461
+ getGeometryInformation: (id) => {
1462
+ return this.resolve(async ([rId]) => {
1463
+ const values = await baseModelerAPI.getGeometryInformation(drawingId, rId);
1511
1464
  if (values !== null) {
1512
1465
  return { centerOfGravity: values[0], volume: values[1] };
1513
1466
  }
1514
1467
  return null;
1515
- }, objectId);
1468
+ }, id);
1516
1469
  },
1517
- removeNodes: (...nodes) => {
1518
- return this.resolve(async ([...rNodes]) => {
1519
- return assemblyBuilderAPI.removeNodes(drawingId, rNodes);
1520
- }, ...nodes);
1470
+ removeInstances: (...instances) => {
1471
+ return this.resolve(async ([...rInstances]) => {
1472
+ return assemblyBuilderAPI.removeInstances(drawingId, rInstances);
1473
+ }, ...instances);
1521
1474
  },
1522
1475
  importFeature: (partId, content, format, name) => {
1523
1476
  return this.resolve(async ([rPartId]) => {
@@ -1573,21 +1526,40 @@ class CAD {
1573
1526
  await sketcherAPI.setSketchRefs(drawingId, rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
1574
1527
  }, sketchId, planeId, axisId, originId);
1575
1528
  },
1576
- transformNode: (referenceId, ownerId, transformation) => {
1577
- return this.resolve(async ([rRefId, rOwnerId]) => {
1578
- await assemblyBuilderAPI.setNodeTransformation(drawingId, rRefId, rOwnerId, transformation);
1579
- }, referenceId, ownerId);
1529
+ transformInstances: async (...instances) => {
1530
+ var e_11, _a;
1531
+ const instancesToTransform = [];
1532
+ try {
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,
1539
+ options: { isLocal: true }, // in non-interactive mode, the transformation is local to the owner
1540
+ };
1541
+ instancesToTransform.push(instanceParam);
1542
+ }
1543
+ }
1544
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1545
+ finally {
1546
+ try {
1547
+ if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
1548
+ }
1549
+ finally { if (e_11) throw e_11.error; }
1550
+ }
1551
+ return assemblyBuilderAPI.transformInstances(drawingId, instancesToTransform);
1580
1552
  },
1581
- translate: (partId, featureIds, references, inverted, distance) => {
1582
- return this.resolve(async ([rPartId, rFeatureIds, ...rReferences]) => {
1553
+ translate: (partId, operations, references, inverted, distance) => {
1554
+ return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
1583
1555
  const translationId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCTranslation, 'Translate');
1584
1556
  if (translationId !== null) {
1585
1557
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
1586
1558
  const entArray = [];
1587
- for (const rFeatureId of rFeatureIds) {
1588
- const entity = cDrawing.structure.tree[(await rFeatureId)].children;
1589
- if (entity != undefined) {
1590
- entArray.push(entity[0]);
1559
+ for (const rOperation of rOperations) {
1560
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
1561
+ if (entities != undefined) {
1562
+ entArray.push(entities[0]);
1591
1563
  }
1592
1564
  }
1593
1565
  const dist = { value: distance, isExpr: typeof distance === 'string' };
@@ -1595,7 +1567,7 @@ class CAD {
1595
1567
  return translationId;
1596
1568
  }
1597
1569
  return null;
1598
- }, partId, featureIds, ...references);
1570
+ }, partId, operations, ...references);
1599
1571
  },
1600
1572
  // TODO: Remove this method. Is it necessary?
1601
1573
  updateTranslate: (translationId, distance) => {
@@ -1620,11 +1592,11 @@ class CAD {
1620
1592
  saveToUrl: (url, filetype) => {
1621
1593
  return baseModelerAPI.saveToUrl(drawingId, url, filetype);
1622
1594
  },
1623
- load: (content, type) => {
1624
- return baseModelerAPI.load(drawingId, content, type);
1595
+ load: (content, type, options) => {
1596
+ return baseModelerAPI.load(drawingId, content, type, '', options);
1625
1597
  },
1626
- loadFromUrl: (url, filetype) => {
1627
- return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true);
1598
+ loadFromUrl: (url, filetype, options) => {
1599
+ return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true, options);
1628
1600
  },
1629
1601
  loadProduct: (content, type, options) => {
1630
1602
  return assemblyBuilderAPI.loadProduct(drawingId, content, type, '', options);
@@ -1634,6 +1606,7 @@ class CAD {
1634
1606
  },
1635
1607
  pick: (partId, type, points) => {
1636
1608
  return this.resolve(async ([rPartId]) => {
1609
+ console.warn('Warning: pick() is deprecated, use findGeometry() instead, pick() will be removed in a future release.');
1637
1610
  const refs = await featureAPI.pick(drawingId, rPartId, type, points.map(resolveVec));
1638
1611
  if (refs != undefined) {
1639
1612
  return Array.isArray(refs) ? refs : [refs];
@@ -1684,16 +1657,16 @@ class CAD {
1684
1657
  return null;
1685
1658
  }, partId, ...references);
1686
1659
  },
1687
- mirror: async (partId, entities, references) => {
1660
+ mirror: async (partId, operations, references) => {
1688
1661
  const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1689
- const rEntities = await new Promise(res => this.resolve(ids => res(ids), ...entities));
1662
+ const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
1690
1663
  const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
1691
1664
  const cDrawing = (0, core_1.getDrawing)(drawingId);
1692
1665
  const entArray = [];
1693
- for (const rEntity of rEntities) {
1694
- const entity = cDrawing.structure.tree[rEntity].children;
1695
- if (entity != undefined) {
1696
- entArray.push(entity[0]);
1666
+ for (const rOperation of rOperations) {
1667
+ const entities = cDrawing.structure.tree[rOperation].children;
1668
+ if (entities != undefined) {
1669
+ entArray.push(entities[0]);
1697
1670
  }
1698
1671
  }
1699
1672
  const mirrorId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCMirror, 'Mirror');
@@ -1737,6 +1710,50 @@ class CAD {
1737
1710
  return asmUtils.getMatePath(drawingId, rRefId);
1738
1711
  }, refId);
1739
1712
  },
1713
+ slice: async (partId, operations, reference, sideFlag) => {
1714
+ const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1715
+ const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
1716
+ const [rReference] = await new Promise(res => this.resolve(paths => res(paths), reference));
1717
+ const cDrawing = (0, core_1.getDrawing)(drawingId);
1718
+ const entArray = [];
1719
+ for (const rOperation of rOperations) {
1720
+ const entities = cDrawing.structure.tree[rOperation].children;
1721
+ if (entities != undefined && entities.length > 0) {
1722
+ entArray.push(entities[0]); // use first entity of operation
1723
+ }
1724
+ }
1725
+ const sliceId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCSlice, 'Slice');
1726
+ if (sliceId != null) {
1727
+ await featureAPI.openFeature(drawingId, sliceId);
1728
+ if (entArray.length > 0) {
1729
+ await featureAPI.updateSlice(drawingId, sliceId, entArray, rReference, sideFlag ? 1 : 0);
1730
+ await featureAPI.closeFeature(drawingId, sliceId);
1731
+ return sliceId;
1732
+ }
1733
+ await featureAPI.closeFeature(drawingId, sliceId);
1734
+ await baseModelerAPI.deleteObjects(drawingId, [sliceId]);
1735
+ }
1736
+ return null;
1737
+ },
1738
+ sliceBySheet: async (partId, operationToSlice, operationOfSheet, sideFlag) => {
1739
+ const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1740
+ const [rOperationToSlice] = await new Promise(res => this.resolve(ids => res(ids), operationToSlice));
1741
+ const [rOperationOfSheet] = await new Promise(res => this.resolve(ids => res(ids), operationOfSheet));
1742
+ const entityToSlice = (0, core_1.getDrawing)(drawingId).structure.tree[rOperationToSlice].children;
1743
+ const entityOfSheet = (0, core_1.getDrawing)(drawingId).structure.tree[rOperationOfSheet].children;
1744
+ const sliceBySheetId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCSliceBySheet, 'SliceBySheet');
1745
+ if (sliceBySheetId != null) {
1746
+ await featureAPI.openFeature(drawingId, sliceBySheetId);
1747
+ if (entityToSlice && entityToSlice.length > 0 && entityOfSheet && entityOfSheet.length > 0) {
1748
+ await featureAPI.updateSliceBySheet(drawingId, sliceBySheetId, entityToSlice[0], entityOfSheet[0], sideFlag ? 1 : 0);
1749
+ await featureAPI.closeFeature(drawingId, sliceBySheetId);
1750
+ return sliceBySheetId;
1751
+ }
1752
+ await featureAPI.closeFeature(drawingId, sliceBySheetId);
1753
+ await baseModelerAPI.deleteObjects(drawingId, [sliceBySheetId]);
1754
+ }
1755
+ return null;
1756
+ },
1740
1757
  };
1741
1758
  callback(publicApi);
1742
1759
  resolve(drawingId);