@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.
@@ -7,9 +7,9 @@ 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, lineSegmentsFilter, loopFilter, MathUtils, planeFilter, pointFilter, } 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
- import * as BufferGeometryUtils_ from 'three/examples/jsm/utils/BufferGeometryUtils';
12
+ import { mergeBufferGeometries } from 'three-stdlib';
13
13
  import { waitForSelect } from './utils/selection';
14
14
  import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
15
15
  const featureAPI = ccAPI.feature;
@@ -21,16 +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
- let BufferGeometryUtils = BufferGeometryUtils_;
25
- if (BufferGeometryUtils.BufferGeometryUtils) {
26
- BufferGeometryUtils = BufferGeometryUtils.BufferGeometryUtils;
27
- }
28
- const resolveVec = (value) => {
29
- if (Array.isArray(value))
30
- return { x: value[0], y: value[1], z: value[2] };
31
- else
32
- return value;
33
- };
34
24
  /**
35
25
  * Returns the cclass of the given dimension type
36
26
  * @param type type of the dimension as string
@@ -79,7 +69,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
79
69
  }
80
70
  if (geometries.length > 0) {
81
71
  const transformation = cDrawing.api.structure.calculateGlobalTransformation(object.id);
82
- const bufferGeom = BufferGeometryUtils.mergeBufferGeometries(geometries);
72
+ const bufferGeom = mergeBufferGeometries(geometries);
83
73
  bufferGeom.applyMatrix4(transformation);
84
74
  bufferGeomArray.push(bufferGeom);
85
75
  }
@@ -116,8 +106,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
116
106
  const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
117
107
  matrix.decompose(part.position, part.quaternion, part.scale);
118
108
  part.updateMatrix();
119
- part.userData = { id: object.id }; // product reference id
120
- part.name = object.name; // product reference name
109
+ part.userData = { id: object.id }; // instance id
110
+ part.name = object.name; // instance name
121
111
  for (const entity of entities) {
122
112
  let cachedEntity = cDrawing.geometry.cache[entity];
123
113
  if (!cachedEntity) {
@@ -165,7 +155,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
165
155
  mesh.name = solidObject.name + '_' + i;
166
156
  mesh.userData = { id: solidObject.id }; // add solid id to the userData
167
157
  if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
168
- mesh.geometry = (BufferGeometryUtils.mergeBufferGeometries || BufferGeometryUtils.mergeGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
158
+ mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
169
159
  mesh.material = new MeshStandardMaterial({
170
160
  color: colorMeshesMap[key].color,
171
161
  transparent: colorMeshesMap[key].opacity < 1,
@@ -187,7 +177,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
187
177
  mesh.name = solidObject.name;
188
178
  mesh.userData = { id: solidObject.id }; // add solid id to the userData
189
179
  if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
190
- mesh.geometry = (BufferGeometryUtils.mergeBufferGeometries || BufferGeometryUtils.mergeGeometries)(colorMeshesMap[key].meshes.map(m => m.geometry));
180
+ mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
191
181
  mesh.material = new MeshStandardMaterial({
192
182
  color: colorMeshesMap[key].color,
193
183
  transparent: colorMeshesMap[key].opacity < 1,
@@ -213,8 +203,8 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
213
203
  const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
214
204
  matrix.decompose(assembly.position, assembly.quaternion, assembly.scale);
215
205
  assembly.updateMatrix();
216
- assembly.userData = { id: object.id }; // assembly root or product reference id
217
- assembly.name = object.name; // assembly root or product reference name
206
+ assembly.userData = { id: object.id }; // assembly root or instance id
207
+ assembly.name = object.name; // assembly root or instance name
218
208
  result.nodes[assembly.name] = assembly;
219
209
  root.add(assembly);
220
210
  for (const child of object.children) {
@@ -224,28 +214,11 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
224
214
  }
225
215
  }
226
216
  };
227
- /**
228
- * Helper function to log relevant points to find geometry to the console.
229
- * This helps the user to copy the points directly from console to parameter of
230
- * findOrSelect() method.
231
- * @param points Array of points array to log to the console
232
- */
233
- const logPoints = (points) => {
234
- let log = 'Relevant points of selected gometry = [[';
235
- if (points && points.length > 0) {
236
- for (let i = 0; i < points.length; i++) {
237
- for (let j = 0; j < points[i].length; j++) {
238
- const point = resolveVec(points[i][j]);
239
- const x = Math.round(point.x * 1000) / 1000;
240
- const y = Math.round(point.y * 1000) / 1000;
241
- const z = Math.round(point.z * 1000) / 1000;
242
- log += '{ x: ' + x + ', y: ' + y + ', z: ' + z + '}';
243
- log += points[i].length - 1 === j ? '' : ',';
244
- }
245
- log += points.length - 1 === i ? ']]' : '],[';
246
- }
247
- console.info(log);
248
- }
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;
249
222
  };
250
223
  export default class CAD {
251
224
  constructor() {
@@ -267,31 +240,31 @@ export default class CAD {
267
240
  throw new Error('Drawing could not be created');
268
241
  this.drawingId = drawingId;
269
242
  const publicApi = {
270
- addNodes: async (...nodes) => {
243
+ addInstances: async (...instances) => {
271
244
  var e_1, _a;
272
- const nodesToAdd = [];
245
+ const instancesToAdd = [];
273
246
  try {
274
- for (var nodes_1 = __asyncValues(nodes), nodes_1_1; nodes_1_1 = await nodes_1.next(), !nodes_1_1.done;) {
275
- const node = nodes_1_1.value;
276
- const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), node.productId, node.ownerId));
277
- const nodeParam = {
278
- referenceId: rProductId,
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,
279
252
  ownerId: rOwnerId,
280
- transformation: node.transformation,
281
- name: node.name,
282
- options: Object.assign(Object.assign({}, node.options), { isLocal: true }), // in non-interactive mode, the transformation is local to the owner
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
283
256
  };
284
- nodesToAdd.push(nodeParam);
257
+ instancesToAdd.push(instanceParam);
285
258
  }
286
259
  }
287
260
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
288
261
  finally {
289
262
  try {
290
- if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) await _a.call(nodes_1);
263
+ if (instances_1_1 && !instances_1_1.done && (_a = instances_1.return)) await _a.call(instances_1);
291
264
  }
292
265
  finally { if (e_1) throw e_1.error; }
293
266
  }
294
- return assemblyBuilderAPI.addNodes(drawingId, nodesToAdd);
267
+ return assemblyBuilderAPI.addInstances(drawingId, instancesToAdd);
295
268
  },
296
269
  addDimensions: async (...dimensions) => {
297
270
  var e_2, _a;
@@ -371,17 +344,17 @@ export default class CAD {
371
344
  return drawing2DAPI.removeDimensions(drawingId, rDimensionIds);
372
345
  }, ...dimensionIds);
373
346
  },
374
- linearPattern: (partId, entities, references1, params1, references2, params2) => {
375
- return this.resolve(async ([rPartId, rEntities, rReferences1, rReferences2]) => {
347
+ linearPattern: (partId, operations, references1, params1, references2, params2) => {
348
+ return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
376
349
  const patternId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCLinearPattern, 'LinearPattern');
377
350
  if (patternId != null) {
378
351
  // entities
379
352
  const cDrawing = await getDrawing(drawingId);
380
353
  const entArray = [];
381
- for (const rEntity of rEntities) {
382
- const entity = cDrawing.structure.tree[(await rEntity)].children;
383
- if (entity != undefined) {
384
- entArray.push(entity[0]);
354
+ for (const rOperation of rOperations) {
355
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
356
+ if (entities != undefined) {
357
+ entArray.push(entities[0]);
385
358
  }
386
359
  }
387
360
  const distance1Param = {
@@ -429,19 +402,19 @@ export default class CAD {
429
402
  return patternId;
430
403
  }
431
404
  return null;
432
- }, partId, entities, references1, references2);
405
+ }, partId, operations, references1, references2);
433
406
  },
434
- circularPattern: (partId, entities, references, params) => {
435
- return this.resolve(async ([rPartId, rEntities, ...rReferences]) => {
407
+ circularPattern: (partId, operations, references, params) => {
408
+ return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
436
409
  const patternId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCCircularPattern, 'CircularPattern');
437
410
  if (patternId != null) {
438
411
  // entities
439
412
  const cDrawing = await getDrawing(drawingId);
440
413
  const entArray = [];
441
- for (const rEntity of rEntities) {
442
- const entity = cDrawing.structure.tree[(await rEntity)].children;
443
- if (entity != undefined) {
444
- entArray.push(entity[0]);
414
+ for (const rOperation of rOperations) {
415
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
416
+ if (entities != undefined) {
417
+ entArray.push(entities[0]);
445
418
  }
446
419
  }
447
420
  const angleParam = { value: params.angle, isExpr: typeof params.angle === 'string' };
@@ -457,11 +430,11 @@ export default class CAD {
457
430
  return patternId;
458
431
  }
459
432
  return null;
460
- }, partId, entities, ...references);
433
+ }, partId, operations, ...references);
461
434
  },
462
435
  extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
463
436
  return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
464
- const extrusion = await featureAPI.createExtrusion(drawingId, rPartId);
437
+ const extrusion = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCExtrusion, 'Extrusion');
465
438
  if (extrusion) {
466
439
  const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
467
440
  if (sketchLines) {
@@ -483,7 +456,7 @@ export default class CAD {
483
456
  },
484
457
  revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
485
458
  return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
486
- const revolve = await featureAPI.createRevolve(drawingId, rPartId);
459
+ const revolve = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCRevolve, 'Revolve');
487
460
  if (revolve) {
488
461
  const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
489
462
  if (sketchLines) {
@@ -495,26 +468,23 @@ export default class CAD {
495
468
  }
496
469
  }, partId, sketchOrRegionIds, ...axisIds);
497
470
  },
498
- boolean: (partId, type, entities) => {
499
- return this.resolve(async ([rPartId, rEntities]) => {
471
+ boolean: (partId, type, operations) => {
472
+ return this.resolve(async ([rPartId, rOperations]) => {
500
473
  const cDrawing = await getDrawing(drawingId);
501
474
  const entArray = [];
502
- for (const rEntity of rEntities) {
503
- const entity = cDrawing.structure.tree[(await rEntity)].children;
504
- if (entity != undefined) {
505
- entArray.push(entity[0]);
475
+ for (const rOperation of rOperations) {
476
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
477
+ if (entities != undefined) {
478
+ entArray.push(entities[0]);
506
479
  }
507
480
  }
508
- const boolId = await featureAPI.createBooleanOperation(drawingId, rPartId, {
509
- type,
510
- entities: entArray,
511
- });
481
+ const boolId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCUnion, 'Union');
512
482
  if (boolId != null) {
513
483
  await featureAPI.updateBooleanOperation(drawingId, boolId, type, entArray);
514
484
  return boolId;
515
485
  }
516
486
  return null;
517
- }, partId, entities);
487
+ }, partId, operations);
518
488
  },
519
489
  box: (partId, references, width, length, height) => {
520
490
  return this.resolve(async ([rPartId, ...rReferences]) => {
@@ -567,11 +537,11 @@ export default class CAD {
567
537
  return null;
568
538
  }, partId, ...references);
569
539
  },
570
- createFastenedConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffset, name) => {
571
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
572
542
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
573
543
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
574
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedConstraint, name);
544
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCFastenedConstraint, name);
575
545
  if (constraintId != null) {
576
546
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
577
547
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -631,10 +601,10 @@ export default class CAD {
631
601
  }
632
602
  await assemblyBuilderAPI.updateFastenedConstraints(drawingId, constrToAdd);
633
603
  },
634
- createFastenedOriginConstraint: async (asmId, mate1, xOffset, yOffset, zOffset, name) => {
635
- const [rAsmId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId));
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));
636
606
  const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
637
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedOriginConstraint, name);
607
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCFastenedOriginConstraint, name);
638
608
  if (constraintId != null) {
639
609
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
640
610
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -686,11 +656,11 @@ export default class CAD {
686
656
  }
687
657
  await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
688
658
  },
689
- createCylindricalConstraint: async (asmId, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
690
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
691
661
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
692
662
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
693
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCCylindricalConstraint, name);
663
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCCylindricalConstraint, name);
694
664
  if (constraintId != null) {
695
665
  await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, [
696
666
  {
@@ -752,11 +722,11 @@ export default class CAD {
752
722
  }
753
723
  await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, constrToAdd);
754
724
  },
755
- createRevoluteConstraint: async (asmId, mate1, mate2, zOffset, zRotationLimits, name) => {
756
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
757
727
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
758
728
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
759
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCRevoluteConstraint, name);
729
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCRevoluteConstraint, name);
760
730
  if (constraintId != null) {
761
731
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
762
732
  await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, [
@@ -820,11 +790,11 @@ export default class CAD {
820
790
  }
821
791
  await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, constrToAdd);
822
792
  },
823
- createSliderConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
824
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
825
795
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
826
796
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
827
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCSliderConstraint, name);
797
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCSliderConstraint, name);
828
798
  if (constraintId != null) {
829
799
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
830
800
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
@@ -892,11 +862,11 @@ export default class CAD {
892
862
  }
893
863
  await assemblyBuilderAPI.updateSliderConstraints(drawingId, constrToAdd);
894
864
  },
895
- createPlanarConstraint: async (asmId, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
896
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
897
867
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
898
868
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
899
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCPlanarConstraint, name);
869
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCPlanarConstraint, name);
900
870
  if (constraintId != null) {
901
871
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
902
872
  await assemblyBuilderAPI.updatePlanarConstraints(drawingId, [
@@ -964,11 +934,11 @@ export default class CAD {
964
934
  }
965
935
  await assemblyBuilderAPI.updatePlanarConstraints(drawingId, constrToAdd);
966
936
  },
967
- createParallelConstraint: async (asmId, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
968
- const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
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));
969
939
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
970
940
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
971
- const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCParallelConstraint, name);
941
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCParallelConstraint, name);
972
942
  if (constraintId != null) {
973
943
  await assemblyBuilderAPI.updateParallelConstraints(drawingId, [
974
944
  {
@@ -1154,10 +1124,10 @@ export default class CAD {
1154
1124
  return null;
1155
1125
  }, partId, ...references);
1156
1126
  },
1157
- createWorkCoordSystem: (partId, type, references, coordinateSystem, offset, rotation, inverted = false, local = false, name) => {
1127
+ createWorkCoordSystem: (partId, type, references, offset, rotation, inverted = false, name) => {
1158
1128
  return this.resolve(async ([rPartId, ...rReferences]) => {
1159
1129
  const wCSName = name ? name : 'WorkCoordSystem';
1160
- const wCSId = await featureAPI.createWorkGeometry(drawingId, rPartId, CCClasses.CCWorkCoordSystem, wCSName);
1130
+ const wCSId = await featureAPI.createWorkGeometry(drawingId, rPartId, CCClasses.CCWorkCSys, wCSName);
1161
1131
  if (wCSId != null) {
1162
1132
  const offsetParam = {
1163
1133
  value: resolveVec(offset),
@@ -1167,7 +1137,7 @@ export default class CAD {
1167
1137
  value: resolveVec(rotation),
1168
1138
  isExpr: typeof rotation === 'string',
1169
1139
  };
1170
- await featureAPI.updateWorkCoordSystem(drawingId, wCSId, type, rReferences, coordinateSystem.map(resolveVec), offsetParam, rotationParam, inverted ? 1 : 0, local);
1140
+ await featureAPI.updateWorkCSys(drawingId, wCSId, type, rReferences, offsetParam, rotationParam, inverted ? 1 : 0);
1171
1141
  return wCSId;
1172
1142
  }
1173
1143
  return null;
@@ -1220,87 +1190,93 @@ export default class CAD {
1220
1190
  return null;
1221
1191
  }, partId, references);
1222
1192
  },
1223
- findOrSelect: (partId, type, length, positions) => {
1224
- return this.resolve(async ([rPartId]) => {
1225
- let filter = lineSegmentsFilter;
1226
- switch (type) {
1227
- case 0: // Vertex
1228
- filter = pointFilter;
1229
- break;
1230
- case 1: // Edge
1231
- filter = lineSegmentsFilter;
1232
- break;
1233
- case 2: // Loop
1234
- filter = loopFilter;
1235
- break;
1236
- case 3: // Face
1237
- filter = planeFilter;
1238
- break;
1239
- }
1240
- const geometries = positions
1241
- ? await geometryAPI.findGeometriesByPoints(drawingId, rPartId, type, positions.map(p => p.map(resolveVec)))
1242
- : await waitForSelect(length, filter, (resolveSelection, items, diff) => {
1243
- if (items.length > length - 1) {
1244
- resolveSelection(items.map(i => i.data.graphicId));
1245
- geometryAPI
1246
- .getPointsByGeometries(drawingId, items.map(i => i.data.graphicId))
1247
- .then(points => {
1248
- logPoints(points);
1249
- });
1250
- }
1193
+ selectGeometry: (types, count) => {
1194
+ const drId = this.drawingId;
1195
+ return this.resolve(async ([]) => {
1196
+ const filter = (scope, data) => scope === BuerliScope && types.some(type => type === data);
1197
+ // Check count param. If not set use by default 1, else check if not < 1
1198
+ const lCount = count ? (count < 1 ? 1 : count) : 1;
1199
+ const selections = (await waitForSelect(lCount, filter, (resolveSelection, items, diff) => {
1200
+ if (items.length > lCount - 1) {
1201
+ resolveSelection(items);
1202
+ }
1203
+ }));
1204
+ const interactionInfos = [];
1205
+ for (const selection of selections) {
1206
+ // Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
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];
1212
+ const interactionInfo = createInfo({
1213
+ objectId: selection.data.container.ownerId,
1214
+ prodRefId: selection.data.productId,
1215
+ containerId: selection.data.container.id,
1216
+ graphicId: selection.data.graphicId,
1217
+ // objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
1218
+ userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
1251
1219
  });
1252
- return geometries;
1220
+ interactionInfos.push(interactionInfo);
1221
+ }
1222
+ return interactionInfos;
1223
+ });
1224
+ },
1225
+ findGeometry: (partId, type, positions) => {
1226
+ return this.resolve(async ([rPartId]) => {
1227
+ const geoms = await geometryAPI.findGeometriesByPoints(drawingId, rPartId, type, positions.map(p => p.map(resolveVec)));
1228
+ return geoms;
1253
1229
  }, partId);
1254
1230
  },
1255
- getAssemblyFromContainer: (asmName) => {
1231
+ getAssemblyTemplate: (asmName) => {
1256
1232
  return this.resolve(async ([]) => {
1257
- const asmIds = asmUtils.getAssemblyFromContainer(drawingId, asmName);
1233
+ const asmIds = asmUtils.getAssemblyTemplate(drawingId, asmName);
1258
1234
  if (asmIds != undefined) {
1259
1235
  return Array.isArray(asmIds) ? asmIds : [asmIds];
1260
1236
  }
1261
1237
  return null;
1262
1238
  });
1263
1239
  },
1264
- getAssemblyNode: (refId, nodeName) => {
1265
- return this.resolve(async ([rRefId]) => {
1266
- const nodeIds = asmUtils.getAssemblyNode(drawingId, rRefId, nodeName);
1267
- if (nodeIds != undefined) {
1268
- return Array.isArray(nodeIds) ? nodeIds : [nodeIds];
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];
1269
1245
  }
1270
1246
  return null;
1271
- }, refId);
1247
+ }, id);
1272
1248
  },
1273
- getProductOfNode: (refIds) => {
1274
- return this.resolve(async ([rRefIds]) => {
1249
+ getProductsOfInstances: (instanceIds) => {
1250
+ return this.resolve(async ([rInstanceIds]) => {
1275
1251
  const drawing = getDrawing(drawingId);
1276
1252
  const tree = drawing.structure.tree;
1277
1253
  const products = [];
1278
- for (const rRefId of rRefIds) {
1279
- const product = asmUtils.findProduct(rRefId, tree);
1254
+ for (const rInstanceId of rInstanceIds) {
1255
+ const product = asmUtils.findProduct(rInstanceId, tree);
1280
1256
  products.push(product);
1281
1257
  }
1282
1258
  return products;
1283
- }, refIds);
1259
+ }, instanceIds);
1284
1260
  },
1285
- setCurrentNode: (refId) => {
1286
- return this.resolve(async ([rRefId]) => {
1287
- await assemblyBuilderAPI.setCurrentNode(drawingId, rRefId);
1288
- }, refId);
1261
+ setCurrentInstance: (id) => {
1262
+ return this.resolve(async ([rId]) => {
1263
+ await assemblyBuilderAPI.setCurrentInstance(drawingId, rId);
1264
+ }, id);
1289
1265
  },
1290
- getCurrentNode: () => {
1266
+ getCurrentInstance: () => {
1291
1267
  return this.resolve(async () => {
1292
1268
  const drw = getDrawing(drawingId);
1293
- return drw.structure.currentNode;
1269
+ return drw.structure.currentInstance;
1294
1270
  });
1295
1271
  },
1296
- getCoordSysFromNode: (refId) => {
1297
- return this.resolve(async ([rRefId]) => {
1298
- const coordSys = asmUtils.getCoordSysFromNode(drawingId, rRefId);
1272
+ getTransformation: (id) => {
1273
+ return this.resolve(async ([rId]) => {
1274
+ const coordSys = asmUtils.getTransformation(drawingId, rId);
1299
1275
  if (coordSys != undefined) {
1300
1276
  return coordSys;
1301
1277
  }
1302
1278
  return null;
1303
- }, refId);
1279
+ }, id);
1304
1280
  },
1305
1281
  setCurrentProduct: (productId) => {
1306
1282
  return this.resolve(async ([rProductId]) => {
@@ -1313,33 +1289,33 @@ export default class CAD {
1313
1289
  return drw.structure.currentProduct;
1314
1290
  });
1315
1291
  },
1316
- getPartFromContainer: (partName) => {
1292
+ getPartTemplate: (partName) => {
1317
1293
  return this.resolve(async ([]) => {
1318
- const partIds = asmUtils.getPartFromContainer(drawingId, partName);
1294
+ const partIds = asmUtils.getPartTemplate(drawingId, partName);
1319
1295
  if (partIds != undefined) {
1320
1296
  return Array.isArray(partIds) ? partIds : [partIds];
1321
1297
  }
1322
1298
  return null;
1323
1299
  });
1324
1300
  },
1325
- getWorkCoordSystem: (refId, wcsName) => {
1326
- return this.resolve(async ([rRefId]) => {
1301
+ getWorkCoordSystem: (id, wcsName) => {
1302
+ return this.resolve(async ([rId]) => {
1327
1303
  console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
1328
- const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rRefId, wcsName);
1304
+ const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rId, wcsName);
1329
1305
  if (wcsIds != undefined) {
1330
1306
  return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
1331
1307
  }
1332
1308
  return null;
1333
- }, refId);
1309
+ }, id);
1334
1310
  },
1335
- getSketchRegion: (refId, sketchRegionName) => {
1336
- return this.resolve(async ([rRefId]) => {
1337
- const sRIds = partUtils.getSketchRegion(drawingId, rRefId, sketchRegionName);
1311
+ getSketchRegion: (id, sketchRegionName) => {
1312
+ return this.resolve(async ([rId]) => {
1313
+ const sRIds = partUtils.getSketchRegion(drawingId, rId, sketchRegionName);
1338
1314
  if (sRIds != undefined) {
1339
1315
  return Array.isArray(sRIds) ? sRIds : [sRIds];
1340
1316
  }
1341
1317
  return null;
1342
- }, refId);
1318
+ }, id);
1343
1319
  },
1344
1320
  getWorkGeometry: (refId, type, wgName) => {
1345
1321
  return this.resolve(async ([rRefId]) => {
@@ -1360,9 +1336,9 @@ export default class CAD {
1360
1336
  return null;
1361
1337
  }, refId);
1362
1338
  },
1363
- getFastenedConstraint: (refId, constrName) => {
1364
- return this.resolve(async ([rRefId]) => {
1365
- const constraint = asmUtils.getFastenedConstraint(drawingId, rRefId, constrName);
1339
+ getFastenedConstraint: (id, constrName) => {
1340
+ return this.resolve(async ([rId]) => {
1341
+ const constraint = asmUtils.getFastenedConstraint(drawingId, rId, constrName);
1366
1342
  if (constraint != undefined) {
1367
1343
  return {
1368
1344
  constrId: constraint.constrId,
@@ -1374,11 +1350,11 @@ export default class CAD {
1374
1350
  };
1375
1351
  }
1376
1352
  return null;
1377
- }, refId);
1353
+ }, id);
1378
1354
  },
1379
- getFastenedOriginConstraint: (refId, constrName) => {
1380
- return this.resolve(async ([rRefId]) => {
1381
- const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rRefId, constrName);
1355
+ getFastenedOriginConstraint: (id, constrName) => {
1356
+ return this.resolve(async ([rId]) => {
1357
+ const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rId, constrName);
1382
1358
  if (constraint != undefined) {
1383
1359
  return {
1384
1360
  constrId: constraint.constrId,
@@ -1389,11 +1365,11 @@ export default class CAD {
1389
1365
  };
1390
1366
  }
1391
1367
  return null;
1392
- }, refId);
1368
+ }, id);
1393
1369
  },
1394
- getRevoluteConstraint: (refId, constrName) => {
1395
- return this.resolve(async ([rRefId]) => {
1396
- const constraint = asmUtils.getRevoluteConstraint(drawingId, rRefId, constrName);
1370
+ getRevoluteConstraint: (id, constrName) => {
1371
+ return this.resolve(async ([rId]) => {
1372
+ const constraint = asmUtils.getRevoluteConstraint(drawingId, rId, constrName);
1397
1373
  if (constraint != undefined) {
1398
1374
  return {
1399
1375
  constrId: constraint.constrId,
@@ -1404,11 +1380,11 @@ export default class CAD {
1404
1380
  };
1405
1381
  }
1406
1382
  return null;
1407
- }, refId);
1383
+ }, id);
1408
1384
  },
1409
- getSliderConstraint: (refId, constrName) => {
1410
- return this.resolve(async ([rRefId]) => {
1411
- const constraint = asmUtils.getSliderConstraint(drawingId, rRefId, constrName);
1385
+ getSliderConstraint: (id, constrName) => {
1386
+ return this.resolve(async ([rId]) => {
1387
+ const constraint = asmUtils.getSliderConstraint(drawingId, rId, constrName);
1412
1388
  if (constraint != undefined) {
1413
1389
  return {
1414
1390
  constrId: constraint.constrId,
@@ -1420,11 +1396,11 @@ export default class CAD {
1420
1396
  };
1421
1397
  }
1422
1398
  return null;
1423
- }, refId);
1399
+ }, id);
1424
1400
  },
1425
- getPlanarConstraint: (refId, constrName) => {
1426
- return this.resolve(async ([rRefId]) => {
1427
- const constraint = asmUtils.getPlanarConstraint(drawingId, rRefId, constrName);
1401
+ getPlanarConstraint: (id, constrName) => {
1402
+ return this.resolve(async ([rId]) => {
1403
+ const constraint = asmUtils.getPlanarConstraint(drawingId, rId, constrName);
1428
1404
  if (constraint != undefined) {
1429
1405
  return {
1430
1406
  constrId: constraint.constrId,
@@ -1437,11 +1413,11 @@ export default class CAD {
1437
1413
  };
1438
1414
  }
1439
1415
  return null;
1440
- }, refId);
1416
+ }, id);
1441
1417
  },
1442
- getParallelConstraint: (refId, constrName) => {
1443
- return this.resolve(async ([rRefId]) => {
1444
- const constraint = asmUtils.getParallelConstraint(drawingId, rRefId, constrName);
1418
+ getParallelConstraint: (id, constrName) => {
1419
+ return this.resolve(async ([rId]) => {
1420
+ const constraint = asmUtils.getParallelConstraint(drawingId, rId, constrName);
1445
1421
  if (constraint != undefined) {
1446
1422
  return {
1447
1423
  constrId: constraint.constrId,
@@ -1454,11 +1430,11 @@ export default class CAD {
1454
1430
  };
1455
1431
  }
1456
1432
  return null;
1457
- }, refId);
1433
+ }, id);
1458
1434
  },
1459
- getCylindricalConstraint: (refId, constrName) => {
1460
- return this.resolve(async ([rRefId]) => {
1461
- const constraint = asmUtils.getCylindricalConstraint(drawingId, rRefId, constrName);
1435
+ getCylindricalConstraint: (id, constrName) => {
1436
+ return this.resolve(async ([rId]) => {
1437
+ const constraint = asmUtils.getCylindricalConstraint(drawingId, rId, constrName);
1462
1438
  if (constraint != undefined) {
1463
1439
  return {
1464
1440
  constrId: constraint.constrId,
@@ -1469,7 +1445,7 @@ export default class CAD {
1469
1445
  };
1470
1446
  }
1471
1447
  return null;
1472
- }, refId);
1448
+ }, id);
1473
1449
  },
1474
1450
  getFeatureByName: (partId, featureName) => {
1475
1451
  return this.resolve(async ([rProductId]) => {
@@ -1480,19 +1456,19 @@ export default class CAD {
1480
1456
  return null;
1481
1457
  }, partId);
1482
1458
  },
1483
- getGeometryInformation: (objectId) => {
1484
- return this.resolve(async ([rProductOrSolidId]) => {
1485
- const values = await baseModelerAPI.getGeometryInformation(drawingId, rProductOrSolidId);
1459
+ getGeometryInformation: (id) => {
1460
+ return this.resolve(async ([rId]) => {
1461
+ const values = await baseModelerAPI.getGeometryInformation(drawingId, rId);
1486
1462
  if (values !== null) {
1487
1463
  return { centerOfGravity: values[0], volume: values[1] };
1488
1464
  }
1489
1465
  return null;
1490
- }, objectId);
1466
+ }, id);
1491
1467
  },
1492
- removeNodes: (...nodes) => {
1493
- return this.resolve(async ([...rNodes]) => {
1494
- return assemblyBuilderAPI.removeNodes(drawingId, rNodes);
1495
- }, ...nodes);
1468
+ removeInstances: (...instances) => {
1469
+ return this.resolve(async ([...rInstances]) => {
1470
+ return assemblyBuilderAPI.removeInstances(drawingId, rInstances);
1471
+ }, ...instances);
1496
1472
  },
1497
1473
  importFeature: (partId, content, format, name) => {
1498
1474
  return this.resolve(async ([rPartId]) => {
@@ -1548,21 +1524,40 @@ export default class CAD {
1548
1524
  await sketcherAPI.setSketchRefs(drawingId, rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
1549
1525
  }, sketchId, planeId, axisId, originId);
1550
1526
  },
1551
- transformNode: (referenceId, ownerId, transformation) => {
1552
- return this.resolve(async ([rRefId, rOwnerId]) => {
1553
- await assemblyBuilderAPI.setNodeTransformation(drawingId, rRefId, rOwnerId, transformation);
1554
- }, referenceId, ownerId);
1527
+ transformInstances: async (...instances) => {
1528
+ var e_11, _a;
1529
+ const instancesToTransform = [];
1530
+ try {
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,
1537
+ options: { isLocal: true }, // in non-interactive mode, the transformation is local to the owner
1538
+ };
1539
+ instancesToTransform.push(instanceParam);
1540
+ }
1541
+ }
1542
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1543
+ finally {
1544
+ try {
1545
+ if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
1546
+ }
1547
+ finally { if (e_11) throw e_11.error; }
1548
+ }
1549
+ return assemblyBuilderAPI.transformInstances(drawingId, instancesToTransform);
1555
1550
  },
1556
- translate: (partId, featureIds, references, inverted, distance) => {
1557
- return this.resolve(async ([rPartId, rFeatureIds, ...rReferences]) => {
1551
+ translate: (partId, operations, references, inverted, distance) => {
1552
+ return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
1558
1553
  const translationId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCTranslation, 'Translate');
1559
1554
  if (translationId !== null) {
1560
1555
  const cDrawing = await getDrawing(drawingId);
1561
1556
  const entArray = [];
1562
- for (const rFeatureId of rFeatureIds) {
1563
- const entity = cDrawing.structure.tree[(await rFeatureId)].children;
1564
- if (entity != undefined) {
1565
- entArray.push(entity[0]);
1557
+ for (const rOperation of rOperations) {
1558
+ const entities = cDrawing.structure.tree[(await rOperation)].children;
1559
+ if (entities != undefined) {
1560
+ entArray.push(entities[0]);
1566
1561
  }
1567
1562
  }
1568
1563
  const dist = { value: distance, isExpr: typeof distance === 'string' };
@@ -1570,7 +1565,7 @@ export default class CAD {
1570
1565
  return translationId;
1571
1566
  }
1572
1567
  return null;
1573
- }, partId, featureIds, ...references);
1568
+ }, partId, operations, ...references);
1574
1569
  },
1575
1570
  // TODO: Remove this method. Is it necessary?
1576
1571
  updateTranslate: (translationId, distance) => {
@@ -1595,11 +1590,11 @@ export default class CAD {
1595
1590
  saveToUrl: (url, filetype) => {
1596
1591
  return baseModelerAPI.saveToUrl(drawingId, url, filetype);
1597
1592
  },
1598
- load: (content, type) => {
1599
- return baseModelerAPI.load(drawingId, content, type);
1593
+ load: (content, type, options) => {
1594
+ return baseModelerAPI.load(drawingId, content, type, '', options);
1600
1595
  },
1601
- loadFromUrl: (url, filetype) => {
1602
- return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true);
1596
+ loadFromUrl: (url, filetype, options) => {
1597
+ return baseModelerAPI.loadFromUrl(drawingId, url, filetype, true, options);
1603
1598
  },
1604
1599
  loadProduct: (content, type, options) => {
1605
1600
  return assemblyBuilderAPI.loadProduct(drawingId, content, type, '', options);
@@ -1609,6 +1604,7 @@ export default class CAD {
1609
1604
  },
1610
1605
  pick: (partId, type, points) => {
1611
1606
  return this.resolve(async ([rPartId]) => {
1607
+ console.warn('Warning: pick() is deprecated, use findGeometry() instead, pick() will be removed in a future release.');
1612
1608
  const refs = await featureAPI.pick(drawingId, rPartId, type, points.map(resolveVec));
1613
1609
  if (refs != undefined) {
1614
1610
  return Array.isArray(refs) ? refs : [refs];
@@ -1659,16 +1655,16 @@ export default class CAD {
1659
1655
  return null;
1660
1656
  }, partId, ...references);
1661
1657
  },
1662
- mirror: async (partId, entities, references) => {
1658
+ mirror: async (partId, operations, references) => {
1663
1659
  const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1664
- const rEntities = await new Promise(res => this.resolve(ids => res(ids), ...entities));
1660
+ const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
1665
1661
  const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
1666
1662
  const cDrawing = getDrawing(drawingId);
1667
1663
  const entArray = [];
1668
- for (const rEntity of rEntities) {
1669
- const entity = cDrawing.structure.tree[rEntity].children;
1670
- if (entity != undefined) {
1671
- entArray.push(entity[0]);
1664
+ for (const rOperation of rOperations) {
1665
+ const entities = cDrawing.structure.tree[rOperation].children;
1666
+ if (entities != undefined) {
1667
+ entArray.push(entities[0]);
1672
1668
  }
1673
1669
  }
1674
1670
  const mirrorId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCMirror, 'Mirror');
@@ -1712,6 +1708,50 @@ export default class CAD {
1712
1708
  return asmUtils.getMatePath(drawingId, rRefId);
1713
1709
  }, refId);
1714
1710
  },
1711
+ slice: async (partId, operations, reference, sideFlag) => {
1712
+ const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1713
+ const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
1714
+ const [rReference] = await new Promise(res => this.resolve(paths => res(paths), reference));
1715
+ const cDrawing = getDrawing(drawingId);
1716
+ const entArray = [];
1717
+ for (const rOperation of rOperations) {
1718
+ const entities = cDrawing.structure.tree[rOperation].children;
1719
+ if (entities != undefined && entities.length > 0) {
1720
+ entArray.push(entities[0]); // use first entity of operation
1721
+ }
1722
+ }
1723
+ const sliceId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCSlice, 'Slice');
1724
+ if (sliceId != null) {
1725
+ await featureAPI.openFeature(drawingId, sliceId);
1726
+ if (entArray.length > 0) {
1727
+ await featureAPI.updateSlice(drawingId, sliceId, entArray, rReference, sideFlag ? 1 : 0);
1728
+ await featureAPI.closeFeature(drawingId, sliceId);
1729
+ return sliceId;
1730
+ }
1731
+ await featureAPI.closeFeature(drawingId, sliceId);
1732
+ await baseModelerAPI.deleteObjects(drawingId, [sliceId]);
1733
+ }
1734
+ return null;
1735
+ },
1736
+ sliceBySheet: async (partId, operationToSlice, operationOfSheet, sideFlag) => {
1737
+ const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1738
+ const [rOperationToSlice] = await new Promise(res => this.resolve(ids => res(ids), operationToSlice));
1739
+ const [rOperationOfSheet] = await new Promise(res => this.resolve(ids => res(ids), operationOfSheet));
1740
+ const entityToSlice = getDrawing(drawingId).structure.tree[rOperationToSlice].children;
1741
+ const entityOfSheet = getDrawing(drawingId).structure.tree[rOperationOfSheet].children;
1742
+ const sliceBySheetId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCSliceBySheet, 'SliceBySheet');
1743
+ if (sliceBySheetId != null) {
1744
+ await featureAPI.openFeature(drawingId, sliceBySheetId);
1745
+ if (entityToSlice && entityToSlice.length > 0 && entityOfSheet && entityOfSheet.length > 0) {
1746
+ await featureAPI.updateSliceBySheet(drawingId, sliceBySheetId, entityToSlice[0], entityOfSheet[0], sideFlag ? 1 : 0);
1747
+ await featureAPI.closeFeature(drawingId, sliceBySheetId);
1748
+ return sliceBySheetId;
1749
+ }
1750
+ await featureAPI.closeFeature(drawingId, sliceBySheetId);
1751
+ await baseModelerAPI.deleteObjects(drawingId, [sliceBySheetId]);
1752
+ }
1753
+ return null;
1754
+ },
1715
1755
  };
1716
1756
  callback(publicApi);
1717
1757
  resolve(drawingId);