@buerli.io/headless 0.8.0 → 0.9.0

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