@buerli.io/headless 0.5.0-beta.2 → 0.5.0-beta.3

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.
@@ -38,26 +38,14 @@ const BufferGeometryUtils_ = __importStar(require("three/examples/jsm/utils/Buff
38
38
  const selection_1 = require("./utils/selection");
39
39
  const featureAPI = classcad_1.ccAPI.feature;
40
40
  const sketcherAPI = classcad_1.ccAPI.sketcher;
41
- const base = classcad_1.ccUtils.base;
41
+ const baseModelerAPI = classcad_1.ccAPI.baseModeler;
42
+ const assemblyBuilderAPI = classcad_1.ccAPI.assemblyBuilder;
43
+ const baseUtils = classcad_1.ccUtils.base;
44
+ const asmUtils = classcad_1.ccUtils.assembly;
42
45
  let BufferGeometryUtils = BufferGeometryUtils_;
43
46
  if (BufferGeometryUtils.BufferGeometryUtils) {
44
47
  BufferGeometryUtils = BufferGeometryUtils.BufferGeometryUtils;
45
48
  }
46
- /**
47
- * Returns the data type of the given value
48
- * @param value value to get the data type from
49
- * @returns datatype of value
50
- */
51
- const getDataType = (value) => {
52
- switch (typeof value) {
53
- case 'number':
54
- return classcad_1.DataType.REAL;
55
- case 'object':
56
- return classcad_1.DataType.POINT;
57
- case 'string':
58
- return classcad_1.DataType.STRING;
59
- }
60
- };
61
49
  /**
62
50
  * Returns the cclass of the given dimension type
63
51
  * @param type type of the dimension as string
@@ -81,7 +69,7 @@ const getDimensionType = (type) => {
81
69
  */
82
70
  const getGlobalTransformation = (drawingId, ownerId, localTransformation) => {
83
71
  const lT = localTransformation;
84
- const coordSysOwner = classcad_1.ccUtils.assembly.getCoordSysFromNode(drawingId, ownerId);
72
+ const coordSysOwner = asmUtils.getCoordSysFromNode(drawingId, ownerId);
85
73
  if (coordSysOwner) {
86
74
  const origin = [lT[0].x, lT[0].y, lT[0].z];
87
75
  const xAxis = [lT[1].x, lT[1].y, lT[1].z];
@@ -149,83 +137,80 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
149
137
  }
150
138
  };
151
139
  /**
152
- * We traverse recursively over structure tree, starting with object and create three objects and meshes
153
- * for the scene. Each part or assembly will be turned into groups and subgroups. Solids from parts will be turned
154
- * into merged meshes, which are children of the group. Faces of a solid with different color
140
+ * We traverse recursively over structure tree, starting with object and create THREE objects
141
+ * for the scene. Each part or assembly will be turned into groups and subgroups. Solids which are children of the
142
+ * parts will be turned into groups as well. Children of solids will be merged to meshes. Faces of a solid with different color
155
143
  * or transparency will get its own mesh.
156
144
  * @param object root object where we start building the three scene
157
145
  * @param drawingId id of the drawing
158
146
  * @param root the root of the scene
159
- * @param options e.g. meshPerFace controls if each face gets a own mesh or if they will be combined/merged
147
+ * @param result object containing all the current collected nodes, solids, meshes
148
+ * @param options e.g. meshPerGeometry controls if each geometry element gets a own mesh or if they will be combined/merged
160
149
  */
161
- const createRecursiveScene = async (object, drawingId, root, options) => {
150
+ const createRecursiveScene = async (object, drawingId, root, result, options) => {
162
151
  let cDrawing = (0, core_1.getDrawing)(drawingId);
163
152
  const tree = cDrawing.structure.tree;
164
153
  if (object.link || object.solids) {
165
154
  // Part
166
- const solids = object.link ? tree[object.link].solids : object.solids;
167
- if (solids != undefined) {
168
- let meshes = [];
169
- const cachedSolids = [];
170
- for (const solid of solids) {
171
- let cachedSolid = cDrawing.geometry.cache[solid];
172
- if (!cachedSolid) {
155
+ const entities = object.link ? tree[object.link].solids : object.solids;
156
+ if (entities != undefined) {
157
+ const part = new three_1.Group();
158
+ part.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
159
+ part.matrixAutoUpdate = false;
160
+ part.userData = { id: object.id }; // product reference id
161
+ part.name = object.name; // product reference name
162
+ for (const entity of entities) {
163
+ let cachedEntity = cDrawing.geometry.cache[entity];
164
+ if (!cachedEntity) {
173
165
  // else get visualisation from classcad
174
- await classcad_1.ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [solid]);
166
+ await classcad_1.ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [entity]);
175
167
  cDrawing = (0, core_1.getDrawing)(drawingId); // get current drawing state after request
176
- cachedSolid = cDrawing.geometry.cache[solid];
177
- }
178
- if (cachedSolid) {
179
- if (options === null || options === void 0 ? void 0 : options.meshPerFace) {
180
- meshes = [...meshes, ...cachedSolid.meshes.map(m => m)];
181
- }
182
- else {
183
- cachedSolids.push(cachedSolid);
184
- }
168
+ cachedEntity = cDrawing.geometry.cache[entity];
185
169
  }
186
- }
187
- // If meshPerFace = true, we create for each face a separat mesh
188
- if (options === null || options === void 0 ? void 0 : options.meshPerFace) {
189
- if (meshes.length > 0) {
190
- const part = new three_1.Group();
191
- part.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
192
- part.matrixAutoUpdate = false;
193
- part.userData = { id: object.id }; // product reference id
194
- part.name = object.name; // product reference name
195
- for (const mesh of meshes) {
196
- part.add(new three_1.Mesh(mesh.geometry, new three_1.MeshStandardMaterial({ color: mesh.color, transparent: mesh.opacity < 1, opacity: mesh.opacity })));
197
- }
198
- root.add(part);
199
- }
200
- }
201
- else {
202
- if (cachedSolids.length > 0) {
203
- const part = new three_1.Group();
204
- part.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
205
- part.matrixAutoUpdate = false;
206
- part.userData = { id: object.id }; // product reference id
207
- part.name = object.name; // product reference name
208
- // A cached solid can have different colored faces, e.g. if a brep has been decorated.
209
- // In that case, we group the meshes with the same color/tranparency
210
- for (const cs of cachedSolids) {
211
- const colorMeshesMap = getDifferentColoredMeshesFromSolid(cs);
212
- Object.keys(colorMeshesMap).forEach(key => {
213
- const coloredMeshes = colorMeshesMap[key];
214
- const mesh = new three_1.Mesh();
215
- mesh.userData = { id: cs.container.ownerId }; // solid id
216
- mesh.name = tree[cs.container.ownerId].name; // solid name
217
- mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(coloredMeshes.map(m => m.geometry));
218
- mesh.material = new three_1.MeshStandardMaterial({
219
- color: coloredMeshes[0].color,
220
- transparent: coloredMeshes[0].opacity < 1,
221
- opacity: coloredMeshes[0].opacity,
170
+ if (cachedEntity && cachedEntity.meshes.length > 0) {
171
+ const solidObject = cDrawing.structure.tree[cachedEntity.container.ownerId];
172
+ if (solidObject) {
173
+ const _solid = new three_1.Group();
174
+ _solid.name = solidObject.name;
175
+ _solid.userData = { id: solidObject.id }; // add solid id to the userData
176
+ if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
177
+ // Create a mesh for each geometry element
178
+ cachedEntity.meshes.forEach(m => {
179
+ const mesh = new three_1.Mesh();
180
+ mesh.userData = { id: m.graphicId }; // add graphic id to the userData
181
+ mesh.geometry = m.geometry;
182
+ mesh.material = new three_1.MeshStandardMaterial({
183
+ color: m.color,
184
+ transparent: m.opacity < 1,
185
+ opacity: m.opacity,
186
+ });
187
+ _solid.add(mesh);
188
+ result.meshes.push(mesh);
222
189
  });
223
- part.add(mesh);
224
- });
190
+ }
191
+ else {
192
+ // Merge all geometries into one mesh, sort them by color
193
+ const colorMeshesMap = getDifferentColoredMeshesFromEntity(cachedEntity);
194
+ Object.keys(colorMeshesMap).forEach(key => {
195
+ const coloredMeshes = colorMeshesMap[key];
196
+ const mesh = new three_1.Mesh();
197
+ mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(coloredMeshes.map(m => m.geometry));
198
+ mesh.material = new three_1.MeshStandardMaterial({
199
+ color: coloredMeshes[0].color,
200
+ transparent: coloredMeshes[0].opacity < 1,
201
+ opacity: coloredMeshes[0].opacity,
202
+ });
203
+ _solid.add(mesh); // Add mesh to solid of the scene
204
+ result.meshes.push(mesh); // Collect mesh to return result later
205
+ });
206
+ }
207
+ part.add(_solid);
208
+ result.solids.push(_solid);
225
209
  }
226
- root.add(part);
227
210
  }
228
211
  }
212
+ root.add(part);
213
+ result.nodes.push(part);
229
214
  }
230
215
  }
231
216
  else if (object.children) {
@@ -235,22 +220,23 @@ const createRecursiveScene = async (object, drawingId, root, options) => {
235
220
  assembly.matrixAutoUpdate = false;
236
221
  assembly.userData = { id: object.id }; // assembly root or product reference id
237
222
  assembly.name = object.name; // assembly root or product reference name
223
+ result.nodes.push(assembly);
238
224
  root.add(assembly);
239
225
  for (const child of object.children) {
240
226
  if (tree[child].class === classcad_1.CCClasses.CCProductReference || tree[child].class === classcad_1.CCClasses.CCProductReferenceET) {
241
- await createRecursiveScene(tree[child], drawingId, assembly, options);
227
+ await createRecursiveScene(tree[child], drawingId, assembly, result, options);
242
228
  }
243
229
  }
244
230
  }
245
231
  };
246
232
  /**
247
233
  * Get all meshes in a map, sorted by their color / transparency
248
- * @param solid solid to look for the meshes
234
+ * @param entity entity to look for the meshes
249
235
  * @returns map (key = color/transparency as string, value = meshes array)
250
236
  */
251
- const getDifferentColoredMeshesFromSolid = (solid) => {
237
+ const getDifferentColoredMeshesFromEntity = (entity) => {
252
238
  const colorMeshesMap = {};
253
- solid.meshes.forEach(mesh => {
239
+ entity.meshes.forEach(mesh => {
254
240
  const key = mesh.color.getHexString() + mesh.opacity.toString();
255
241
  if (colorMeshesMap[key]) {
256
242
  colorMeshesMap[key].push(mesh);
@@ -303,12 +289,6 @@ class CAD {
303
289
  throw new Error('Drawing could not be created');
304
290
  this.drawingId = drawingId;
305
291
  const publicApi = {
306
- addNode: (productId, ownerId, transformation, name) => {
307
- return this.resolve(async ([rProductId, rOwnerId]) => {
308
- const globalTransformation = getGlobalTransformation(drawingId, rOwnerId, transformation) || transformation;
309
- return classcad_1.ccAPI.assemblyBuilder.addNode(drawingId, rProductId, rOwnerId, globalTransformation, name);
310
- }, productId, ownerId);
311
- },
312
292
  addNodes: async (...nodes) => {
313
293
  var e_1, _a;
314
294
  const nodesToAdd = [];
@@ -334,29 +314,6 @@ class CAD {
334
314
  }
335
315
  return classcad_1.ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
336
316
  },
337
- addDimension: (dim) => {
338
- return this.resolve(async ([rProductId]) => {
339
- const dimensionType = getDimensionType(dim.dimParam.dimType);
340
- const dimParam = {
341
- productId: rProductId,
342
- param: {
343
- type: dimensionType,
344
- name: dim.dimParam.dimName,
345
- label: dim.dimParam.dimLabel,
346
- value: dim.dimParam.dimValue,
347
- startPos: dim.dimParam.dimStartPos,
348
- endPos: dim.dimParam.dimEndPos,
349
- textPos: dim.dimParam.dimTextPos,
350
- textAngle: dim.dimParam.dimTextAngle,
351
- orientation: dim.dimParam.dimOrientation,
352
- color: dim.dimParam.dimColor,
353
- layer: dim.dimParam.dimLayer,
354
- },
355
- dxfView: dim.dxfView,
356
- };
357
- return classcad_1.ccAPI.drawing2D.addDimension(drawingId, dimParam);
358
- }, dim.productId);
359
- },
360
317
  addDimensions: async (...dimensions) => {
361
318
  var e_2, _a;
362
319
  const dimParamsToAdd = [];
@@ -527,7 +484,7 @@ class CAD {
527
484
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
528
485
  const sketchLines = [];
529
486
  // TODO: Which sketch lines need to be included, is CCClasses.CCCurve and its derivation enough?
530
- sketchLines.push(...classcad_1.ccUtils.base.getChildren(rSketchId, classcad_1.CCClasses.CCCurve, cDrawing.structure.tree));
487
+ sketchLines.push(...baseUtils.getChildren(rSketchId, classcad_1.CCClasses.CCCurve, cDrawing.structure.tree));
531
488
  if (sketchLines) {
532
489
  const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
533
490
  const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
@@ -551,8 +508,8 @@ class CAD {
551
508
  if (revolve) {
552
509
  const cDrawing = await (0, core_1.getDrawing)(drawingId);
553
510
  const sketchLines = [];
554
- sketchLines.push(...classcad_1.ccUtils.base.getChildren(rSketchId, classcad_1.CCClasses.CCCircle, cDrawing.structure.tree));
555
- sketchLines.push(...classcad_1.ccUtils.base.getChildren(rSketchId, classcad_1.CCClasses.CCLine, cDrawing.structure.tree));
511
+ sketchLines.push(...baseUtils.getChildren(rSketchId, classcad_1.CCClasses.CCCircle, cDrawing.structure.tree));
512
+ sketchLines.push(...baseUtils.getChildren(rSketchId, classcad_1.CCClasses.CCLine, cDrawing.structure.tree));
556
513
  if (sketchLines) {
557
514
  const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
558
515
  const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
@@ -638,25 +595,25 @@ class CAD {
638
595
  const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
639
596
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
640
597
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
641
- const constraintId = await classcad_1.ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedConstraint, name);
598
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedConstraint, name);
642
599
  if (constraintId != null) {
643
600
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
644
601
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
645
602
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
646
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, constraintId, { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
603
+ await assemblyBuilderAPI.updateFastenedConstraints(drawingId, [
604
+ {
605
+ constrId: constraintId,
606
+ mate1: { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
607
+ mate2: { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented },
608
+ xOffset: xOffsetParam,
609
+ yOffset: yOffsetParam,
610
+ zOffset: zOffsetParam,
611
+ },
612
+ ]);
647
613
  return constraintId;
648
614
  }
649
615
  return null;
650
616
  },
651
- updateFastenedConstraint: async (constrId, mate1, mate2, xOffset, yOffset, zOffset) => {
652
- const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId, mate2.wcsId));
653
- const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
654
- const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
655
- const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
656
- const yOffsetParam = { value: yOffset, isExpr: typeof xOffset === 'string' };
657
- const zOffsetParam = { value: zOffset, isExpr: typeof xOffset === 'string' };
658
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, rConstrId, { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
659
- },
660
617
  updateFastenedConstraints: async (...constraints) => {
661
618
  var e_3, _a;
662
619
  const constrToAdd = [];
@@ -696,29 +653,29 @@ class CAD {
696
653
  }
697
654
  finally { if (e_3) throw e_3.error; }
698
655
  }
699
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraints(drawingId, constrToAdd);
656
+ await assemblyBuilderAPI.updateFastenedConstraints(drawingId, constrToAdd);
700
657
  },
701
658
  createFastenedOriginConstraint: async (asmId, mate1, xOffset, yOffset, zOffset, name) => {
702
659
  const [rAsmId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId));
703
660
  const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
704
- const constraintId = await classcad_1.ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedOriginConstraint, name);
661
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedOriginConstraint, name);
705
662
  if (constraintId != null) {
706
663
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
707
664
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
708
665
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
709
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
666
+ await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, [
667
+ {
668
+ constrId: constraintId,
669
+ mate1: { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
670
+ xOffset: xOffsetParam,
671
+ yOffset: yOffsetParam,
672
+ zOffset: zOffsetParam,
673
+ },
674
+ ]);
710
675
  return constraintId;
711
676
  }
712
677
  return null;
713
678
  },
714
- updateFastenedOriginConstraint: async (constrId, mate1, xOffset, yOffset, zOffset) => {
715
- const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId));
716
- const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
717
- const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
718
- const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
719
- const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
720
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
721
- },
722
679
  updateFastenedOriginConstraints: async (...constraints) => {
723
680
  var e_4, _a;
724
681
  const constraintsToAdd = [];
@@ -751,7 +708,378 @@ class CAD {
751
708
  }
752
709
  finally { if (e_4) throw e_4.error; }
753
710
  }
754
- await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
711
+ await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
712
+ },
713
+ createCylindricalConstraint: async (asmId, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
714
+ const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
715
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
716
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
717
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCCylindricalConstraint, name);
718
+ if (constraintId != null) {
719
+ await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, [
720
+ {
721
+ constrId: constraintId,
722
+ mate1: {
723
+ matePath: rMatePath1,
724
+ wcsId: rWcs1,
725
+ flip: mate1.flip,
726
+ reoriented: mate1.reoriented,
727
+ },
728
+ mate2: {
729
+ matePath: rMatePath2,
730
+ wcsId: rWcs2,
731
+ flip: mate2.flip,
732
+ reoriented: mate2.reoriented,
733
+ },
734
+ zOffsetLimits,
735
+ zRotationLimits,
736
+ },
737
+ ]);
738
+ return constraintId;
739
+ }
740
+ return null;
741
+ },
742
+ updateCylindricalConstraints: async (...constraints) => {
743
+ var e_5, _a;
744
+ const constrToAdd = [];
745
+ try {
746
+ for (var constraints_3 = __asyncValues(constraints), constraints_3_1; constraints_3_1 = await constraints_3.next(), !constraints_3_1.done;) {
747
+ const constr = constraints_3_1.value;
748
+ const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
749
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
750
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
751
+ constrToAdd.push({
752
+ constrId: rConstrId,
753
+ mate1: {
754
+ matePath: rMatePath1,
755
+ wcsId: rWcs1,
756
+ flip: constr.mate1.flip,
757
+ reoriented: constr.mate1.reoriented,
758
+ },
759
+ mate2: {
760
+ matePath: rMatePath2,
761
+ wcsId: rWcs2,
762
+ flip: constr.mate2.flip,
763
+ reoriented: constr.mate2.reoriented,
764
+ },
765
+ zOffsetLimits: constr.zOffsetLimits,
766
+ zRotationLimits: constr.zRotationLimits,
767
+ });
768
+ }
769
+ }
770
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
771
+ finally {
772
+ try {
773
+ if (constraints_3_1 && !constraints_3_1.done && (_a = constraints_3.return)) await _a.call(constraints_3);
774
+ }
775
+ finally { if (e_5) throw e_5.error; }
776
+ }
777
+ await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, constrToAdd);
778
+ },
779
+ createRevoluteConstraint: async (asmId, mate1, mate2, zOffset, zRotationLimits, name) => {
780
+ const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
781
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
782
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
783
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCRevoluteConstraint, name);
784
+ if (constraintId != null) {
785
+ const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
786
+ await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, [
787
+ {
788
+ constrId: constraintId,
789
+ mate1: {
790
+ matePath: rMatePath1,
791
+ wcsId: rWcs1,
792
+ flip: mate1.flip,
793
+ reoriented: mate1.reoriented,
794
+ },
795
+ mate2: {
796
+ matePath: rMatePath2,
797
+ wcsId: rWcs2,
798
+ flip: mate2.flip,
799
+ reoriented: mate2.reoriented,
800
+ },
801
+ zOffset: zOffsetParam,
802
+ zRotationLimits,
803
+ },
804
+ ]);
805
+ return constraintId;
806
+ }
807
+ return null;
808
+ },
809
+ updateRevoluteConstraints: async (...constraints) => {
810
+ var e_6, _a;
811
+ const constrToAdd = [];
812
+ try {
813
+ for (var constraints_4 = __asyncValues(constraints), constraints_4_1; constraints_4_1 = await constraints_4.next(), !constraints_4_1.done;) {
814
+ const constr = constraints_4_1.value;
815
+ const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
816
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
817
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
818
+ const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
819
+ constrToAdd.push({
820
+ constrId: rConstrId,
821
+ mate1: {
822
+ matePath: rMatePath1,
823
+ wcsId: rWcs1,
824
+ flip: constr.mate1.flip,
825
+ reoriented: constr.mate1.reoriented,
826
+ },
827
+ mate2: {
828
+ matePath: rMatePath2,
829
+ wcsId: rWcs2,
830
+ flip: constr.mate2.flip,
831
+ reoriented: constr.mate2.reoriented,
832
+ },
833
+ zOffset: zOffsetParam,
834
+ zRotationLimits: constr.zRotationLimits,
835
+ });
836
+ }
837
+ }
838
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
839
+ finally {
840
+ try {
841
+ if (constraints_4_1 && !constraints_4_1.done && (_a = constraints_4.return)) await _a.call(constraints_4);
842
+ }
843
+ finally { if (e_6) throw e_6.error; }
844
+ }
845
+ await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, constrToAdd);
846
+ },
847
+ createSliderConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
848
+ const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
849
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
850
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
851
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCSliderConstraint, name);
852
+ if (constraintId != null) {
853
+ const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
854
+ const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
855
+ await assemblyBuilderAPI.updateSliderConstraints(drawingId, [
856
+ {
857
+ constrId: constraintId,
858
+ mate1: {
859
+ matePath: rMatePath1,
860
+ wcsId: rWcs1,
861
+ flip: mate1.flip,
862
+ reoriented: mate1.reoriented,
863
+ },
864
+ mate2: {
865
+ matePath: rMatePath2,
866
+ wcsId: rWcs2,
867
+ flip: mate2.flip,
868
+ reoriented: mate2.reoriented,
869
+ },
870
+ xOffset: xOffsetParam,
871
+ yOffset: yOffsetParam,
872
+ zOffsetLimits,
873
+ },
874
+ ]);
875
+ return constraintId;
876
+ }
877
+ return null;
878
+ },
879
+ updateSliderConstraints: async (...constraints) => {
880
+ var e_7, _a;
881
+ const constrToAdd = [];
882
+ try {
883
+ for (var constraints_5 = __asyncValues(constraints), constraints_5_1; constraints_5_1 = await constraints_5.next(), !constraints_5_1.done;) {
884
+ const constr = constraints_5_1.value;
885
+ const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
886
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
887
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
888
+ const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
889
+ const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
890
+ constrToAdd.push({
891
+ constrId: rConstrId,
892
+ mate1: {
893
+ matePath: rMatePath1,
894
+ wcsId: rWcs1,
895
+ flip: constr.mate1.flip,
896
+ reoriented: constr.mate1.reoriented,
897
+ },
898
+ mate2: {
899
+ matePath: rMatePath2,
900
+ wcsId: rWcs2,
901
+ flip: constr.mate2.flip,
902
+ reoriented: constr.mate2.reoriented,
903
+ },
904
+ xOffset: xOffsetParam,
905
+ yOffset: yOffsetParam,
906
+ zOffsetLimits: constr.zOffsetLimits,
907
+ });
908
+ }
909
+ }
910
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
911
+ finally {
912
+ try {
913
+ if (constraints_5_1 && !constraints_5_1.done && (_a = constraints_5.return)) await _a.call(constraints_5);
914
+ }
915
+ finally { if (e_7) throw e_7.error; }
916
+ }
917
+ await assemblyBuilderAPI.updateSliderConstraints(drawingId, constrToAdd);
918
+ },
919
+ createPlanarConstraint: async (asmId, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
920
+ const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
921
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
922
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
923
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCPlanarConstraint, name);
924
+ if (constraintId != null) {
925
+ const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
926
+ await assemblyBuilderAPI.updatePlanarConstraints(drawingId, [
927
+ {
928
+ constrId: constraintId,
929
+ mate1: {
930
+ matePath: rMatePath1,
931
+ wcsId: rWcs1,
932
+ flip: mate1.flip,
933
+ reoriented: mate1.reoriented,
934
+ },
935
+ mate2: {
936
+ matePath: rMatePath2,
937
+ wcsId: rWcs2,
938
+ flip: mate2.flip,
939
+ reoriented: mate2.reoriented,
940
+ },
941
+ zOffset: zOffsetParam,
942
+ xOffsetLimits,
943
+ yOffsetLimits,
944
+ zRotationLimits,
945
+ },
946
+ ]);
947
+ return constraintId;
948
+ }
949
+ return null;
950
+ },
951
+ updatePlanarConstraints: async (...constraints) => {
952
+ var e_8, _a;
953
+ const constrToAdd = [];
954
+ try {
955
+ for (var constraints_6 = __asyncValues(constraints), constraints_6_1; constraints_6_1 = await constraints_6.next(), !constraints_6_1.done;) {
956
+ const constr = constraints_6_1.value;
957
+ const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
958
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
959
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
960
+ const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
961
+ constrToAdd.push({
962
+ constrId: rConstrId,
963
+ mate1: {
964
+ matePath: rMatePath1,
965
+ wcsId: rWcs1,
966
+ flip: constr.mate1.flip,
967
+ reoriented: constr.mate1.reoriented,
968
+ },
969
+ mate2: {
970
+ matePath: rMatePath2,
971
+ wcsId: rWcs2,
972
+ flip: constr.mate2.flip,
973
+ reoriented: constr.mate2.reoriented,
974
+ },
975
+ zOffset: zOffsetParam,
976
+ xOffsetLimits: constr.xOffsetLimits,
977
+ yOffsetLimits: constr.yOffsetLimits,
978
+ zRotationLimits: constr.zRotationLimits,
979
+ });
980
+ }
981
+ }
982
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
983
+ finally {
984
+ try {
985
+ if (constraints_6_1 && !constraints_6_1.done && (_a = constraints_6.return)) await _a.call(constraints_6);
986
+ }
987
+ finally { if (e_8) throw e_8.error; }
988
+ }
989
+ await assemblyBuilderAPI.updatePlanarConstraints(drawingId, constrToAdd);
990
+ },
991
+ createParallelConstraint: async (asmId, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
992
+ const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
993
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
994
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
995
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCParallelConstraint, name);
996
+ if (constraintId != null) {
997
+ await assemblyBuilderAPI.updateParallelConstraints(drawingId, [
998
+ {
999
+ constrId: constraintId,
1000
+ mate1: {
1001
+ matePath: rMatePath1,
1002
+ wcsId: rWcs1,
1003
+ flip: mate1.flip,
1004
+ reoriented: mate1.reoriented,
1005
+ },
1006
+ mate2: {
1007
+ matePath: rMatePath2,
1008
+ wcsId: rWcs2,
1009
+ flip: mate2.flip,
1010
+ reoriented: mate2.reoriented,
1011
+ },
1012
+ xOffsetLimits,
1013
+ yOffsetLimits,
1014
+ zOffsetLimits,
1015
+ zRotationLimits,
1016
+ },
1017
+ ]);
1018
+ return constraintId;
1019
+ }
1020
+ return null;
1021
+ },
1022
+ updateParallelConstraints: async (...constraints) => {
1023
+ var e_9, _a;
1024
+ const constrToAdd = [];
1025
+ try {
1026
+ for (var constraints_7 = __asyncValues(constraints), constraints_7_1; constraints_7_1 = await constraints_7.next(), !constraints_7_1.done;) {
1027
+ const constr = constraints_7_1.value;
1028
+ const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
1029
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
1030
+ const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
1031
+ constrToAdd.push({
1032
+ constrId: rConstrId,
1033
+ mate1: {
1034
+ matePath: rMatePath1,
1035
+ wcsId: rWcs1,
1036
+ flip: constr.mate1.flip,
1037
+ reoriented: constr.mate1.reoriented,
1038
+ },
1039
+ mate2: {
1040
+ matePath: rMatePath2,
1041
+ wcsId: rWcs2,
1042
+ flip: constr.mate2.flip,
1043
+ reoriented: constr.mate2.reoriented,
1044
+ },
1045
+ xOffsetLimits: constr.xOffsetLimits,
1046
+ yOffsetLimits: constr.yOffsetLimits,
1047
+ zOffsetLimits: constr.zOffsetLimits,
1048
+ zRotationLimits: constr.zRotationLimits,
1049
+ });
1050
+ }
1051
+ }
1052
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1053
+ finally {
1054
+ try {
1055
+ if (constraints_7_1 && !constraints_7_1.done && (_a = constraints_7.return)) await _a.call(constraints_7);
1056
+ }
1057
+ finally { if (e_9) throw e_9.error; }
1058
+ }
1059
+ await assemblyBuilderAPI.updateParallelConstraints(drawingId, constrToAdd);
1060
+ },
1061
+ update3dConstraintValues: async (...constrValues) => {
1062
+ var e_10, _a;
1063
+ const constrValueParams = [];
1064
+ try {
1065
+ for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
1066
+ const constrVal = constrValues_1_1.value;
1067
+ const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constrVal.constrId));
1068
+ constrValueParams.push({
1069
+ constrId: rConstrId,
1070
+ paramName: constrVal.paramName,
1071
+ value: constrVal.value,
1072
+ });
1073
+ }
1074
+ }
1075
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1076
+ finally {
1077
+ try {
1078
+ if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
1079
+ }
1080
+ finally { if (e_10) throw e_10.error; }
1081
+ }
1082
+ await assemblyBuilderAPI.update3DConstraintValues(drawingId, constrValueParams);
755
1083
  },
756
1084
  createBufferGeometry: async (objectId) => {
757
1085
  await this.queue;
@@ -776,16 +1104,21 @@ class CAD {
776
1104
  const cDrawing = (0, core_1.getDrawing)(drawingId);
777
1105
  const structureTree = cDrawing.structure.tree;
778
1106
  const scene = new three_1.Scene();
1107
+ const result = {
1108
+ nodes: [],
1109
+ solids: [],
1110
+ meshes: [],
1111
+ };
779
1112
  if (rObjectId != null) {
780
1113
  const rootObj = structureTree[rObjectId];
781
1114
  if (rootObj) {
782
- await createRecursiveScene(rootObj, drawingId, scene, options);
1115
+ await createRecursiveScene(rootObj, drawingId, scene, result, options);
783
1116
  }
784
1117
  else {
785
1118
  throw new Error('Root object does not exist!');
786
1119
  }
787
1120
  }
788
- return scene;
1121
+ return Object.assign({ scene }, result);
789
1122
  },
790
1123
  createExpressions: (partId, ...members) => {
791
1124
  return this.resolve(async ([rPartId]) => {
@@ -799,18 +1132,20 @@ class CAD {
799
1132
  };
800
1133
  membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
801
1134
  });
802
- const success = featureAPI.updateExpressionSet(drawingId, rPartId, membersToAdd, [], []);
1135
+ const success = featureAPI.updateExpressionSets(drawingId, [
1136
+ { productId: rPartId, toAddMembers: membersToAdd, toModifyMembers: [], toDeleteList: [] },
1137
+ ]);
803
1138
  return success;
804
1139
  }, partId);
805
1140
  },
806
1141
  createAssemblyAsTemplate: (name) => {
807
1142
  return this.resolve(async ([]) => {
808
- return await classcad_1.ccAPI.assemblyBuilder.createAssemblyAsTemplate(drawingId, name);
1143
+ return await assemblyBuilderAPI.createAssemblyAsTemplate(drawingId, name);
809
1144
  });
810
1145
  },
811
1146
  createRootAssembly: (name) => {
812
1147
  return this.resolve(async ([]) => {
813
- return await classcad_1.ccAPI.assemblyBuilder.createRootAssembly(drawingId, name);
1148
+ return await assemblyBuilderAPI.createRootAssembly(drawingId, name);
814
1149
  });
815
1150
  },
816
1151
  createPart: (name) => {
@@ -822,7 +1157,7 @@ class CAD {
822
1157
  createPartAsTemplate: (name) => {
823
1158
  return this.resolve(async ([]) => {
824
1159
  const partName = name ? name : 'Part';
825
- return await classcad_1.ccAPI.assemblyBuilder.createPartAsTemplate(drawingId, partName);
1160
+ return await assemblyBuilderAPI.createPartAsTemplate(drawingId, partName);
826
1161
  });
827
1162
  },
828
1163
  createWorkAxis: (partId, type, references, position, direction, local, name) => {
@@ -938,7 +1273,7 @@ class CAD {
938
1273
  },
939
1274
  getAssemblyFromContainer: (asmName) => {
940
1275
  return this.resolve(async ([]) => {
941
- const asmIds = classcad_1.ccUtils.assembly.getAssemblyFromContainer(drawingId, asmName);
1276
+ const asmIds = asmUtils.getAssemblyFromContainer(drawingId, asmName);
942
1277
  if (asmIds != undefined) {
943
1278
  return Array.isArray(asmIds) ? asmIds : [asmIds];
944
1279
  }
@@ -947,7 +1282,7 @@ class CAD {
947
1282
  },
948
1283
  getAssemblyNode: (refId, nodeName) => {
949
1284
  return this.resolve(async ([rRefId]) => {
950
- const nodeIds = classcad_1.ccUtils.assembly.getAssemblyNode(drawingId, rRefId, nodeName);
1285
+ const nodeIds = asmUtils.getAssemblyNode(drawingId, rRefId, nodeName);
951
1286
  if (nodeIds != undefined) {
952
1287
  return Array.isArray(nodeIds) ? nodeIds : [nodeIds];
953
1288
  }
@@ -956,7 +1291,7 @@ class CAD {
956
1291
  },
957
1292
  setCurrentNode: (refId) => {
958
1293
  return this.resolve(async ([rRefId]) => {
959
- await classcad_1.ccAPI.assemblyBuilder.setCurrentNode(drawingId, rRefId);
1294
+ await assemblyBuilderAPI.setCurrentNode(drawingId, rRefId);
960
1295
  }, refId);
961
1296
  },
962
1297
  getCurrentNode: () => {
@@ -967,7 +1302,7 @@ class CAD {
967
1302
  },
968
1303
  getCoordSysFromNode: (refId) => {
969
1304
  return this.resolve(async ([rRefId]) => {
970
- const coordSys = classcad_1.ccUtils.assembly.getCoordSysFromNode(drawingId, rRefId);
1305
+ const coordSys = asmUtils.getCoordSysFromNode(drawingId, rRefId);
971
1306
  if (coordSys != undefined) {
972
1307
  return coordSys;
973
1308
  }
@@ -987,7 +1322,7 @@ class CAD {
987
1322
  },
988
1323
  getPartFromContainer: (partName) => {
989
1324
  return this.resolve(async ([]) => {
990
- const partIds = classcad_1.ccUtils.assembly.getPartFromContainer(drawingId, partName);
1325
+ const partIds = asmUtils.getPartFromContainer(drawingId, partName);
991
1326
  if (partIds != undefined) {
992
1327
  return Array.isArray(partIds) ? partIds : [partIds];
993
1328
  }
@@ -996,22 +1331,144 @@ class CAD {
996
1331
  },
997
1332
  getWorkCoordSystem: (refId, wcsName) => {
998
1333
  return this.resolve(async ([rRefId]) => {
999
- const wcsIds = classcad_1.ccUtils.assembly.getWorkCoordSystem(drawingId, rRefId, wcsName);
1334
+ console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
1335
+ const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rRefId, wcsName);
1000
1336
  if (wcsIds != undefined) {
1001
1337
  return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
1002
1338
  }
1003
1339
  return null;
1004
1340
  }, refId);
1005
1341
  },
1342
+ getWorkGeometry: (refId, type, wgName) => {
1343
+ return this.resolve(async ([rRefId]) => {
1344
+ const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
1345
+ if (wgIds != undefined) {
1346
+ return Array.isArray(wgIds) ? wgIds : [wgIds];
1347
+ }
1348
+ return null;
1349
+ }, refId);
1350
+ },
1006
1351
  getConstraint: (refId, constrName) => {
1007
1352
  return this.resolve(async ([rRefId]) => {
1008
- const constrIds = classcad_1.ccUtils.assembly.getConstraint(drawingId, rRefId, constrName);
1353
+ console.warn('Warning: getConstraint() is deprecated, use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.');
1354
+ const constrIds = asmUtils.getConstraint(drawingId, rRefId, constrName);
1009
1355
  if (constrIds != undefined) {
1010
1356
  return Array.isArray(constrIds) ? constrIds : [constrIds];
1011
1357
  }
1012
1358
  return null;
1013
1359
  }, refId);
1014
1360
  },
1361
+ getFastenedConstraint: (refId, constrName) => {
1362
+ return this.resolve(async ([rRefId]) => {
1363
+ const constraint = asmUtils.getFastenedConstraint(drawingId, rRefId, constrName);
1364
+ if (constraint != undefined) {
1365
+ return {
1366
+ constrId: constraint.constrId,
1367
+ mate1: constraint.mate1,
1368
+ mate2: constraint.mate2,
1369
+ xOffset: constraint.xOffset.value,
1370
+ yOffset: constraint.yOffset.value,
1371
+ zOffset: constraint.zOffset.value,
1372
+ };
1373
+ }
1374
+ return null;
1375
+ }, refId);
1376
+ },
1377
+ getFastenedOriginConstraint: (refId, constrName) => {
1378
+ return this.resolve(async ([rRefId]) => {
1379
+ const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rRefId, constrName);
1380
+ if (constraint != undefined) {
1381
+ return {
1382
+ constrId: constraint.constrId,
1383
+ mate1: constraint.mate1,
1384
+ xOffset: constraint.xOffset.value,
1385
+ yOffset: constraint.yOffset.value,
1386
+ zOffset: constraint.zOffset.value,
1387
+ };
1388
+ }
1389
+ return null;
1390
+ }, refId);
1391
+ },
1392
+ getRevoluteConstraint: (refId, constrName) => {
1393
+ return this.resolve(async ([rRefId]) => {
1394
+ const constraint = asmUtils.getRevoluteConstraint(drawingId, rRefId, constrName);
1395
+ if (constraint != undefined) {
1396
+ return {
1397
+ constrId: constraint.constrId,
1398
+ mate1: constraint.mate1,
1399
+ mate2: constraint.mate2,
1400
+ zOffset: constraint.zOffset.value,
1401
+ zRotationLimits: constraint.zRotationLimits,
1402
+ };
1403
+ }
1404
+ return null;
1405
+ }, refId);
1406
+ },
1407
+ getSliderConstraint: (refId, constrName) => {
1408
+ return this.resolve(async ([rRefId]) => {
1409
+ const constraint = asmUtils.getSliderConstraint(drawingId, rRefId, constrName);
1410
+ if (constraint != undefined) {
1411
+ return {
1412
+ constrId: constraint.constrId,
1413
+ mate1: constraint.mate1,
1414
+ mate2: constraint.mate2,
1415
+ xOffset: constraint.xOffset.value,
1416
+ yOffset: constraint.yOffset.value,
1417
+ zOffsetLimits: constraint.zOffsetLimits,
1418
+ };
1419
+ }
1420
+ return null;
1421
+ }, refId);
1422
+ },
1423
+ getPlanarConstraint: (refId, constrName) => {
1424
+ return this.resolve(async ([rRefId]) => {
1425
+ const constraint = asmUtils.getPlanarConstraint(drawingId, rRefId, constrName);
1426
+ if (constraint != undefined) {
1427
+ return {
1428
+ constrId: constraint.constrId,
1429
+ mate1: constraint.mate1,
1430
+ mate2: constraint.mate2,
1431
+ zOffset: constraint.zOffset.value,
1432
+ xOffsetLimits: constraint.xOffsetLimits,
1433
+ yOffsetLimits: constraint.yOffsetLimits,
1434
+ zRotationLimits: constraint.zRotationLimits,
1435
+ };
1436
+ }
1437
+ return null;
1438
+ }, refId);
1439
+ },
1440
+ getParallelConstraint: (refId, constrName) => {
1441
+ return this.resolve(async ([rRefId]) => {
1442
+ const constraint = asmUtils.getParallelConstraint(drawingId, rRefId, constrName);
1443
+ if (constraint != undefined) {
1444
+ return {
1445
+ constrId: constraint.constrId,
1446
+ mate1: constraint.mate1,
1447
+ mate2: constraint.mate2,
1448
+ xOffsetLimits: constraint.xOffsetLimits,
1449
+ yOffsetLimits: constraint.yOffsetLimits,
1450
+ zOffsetLimits: constraint.zOffsetLimits,
1451
+ zRotationLimits: constraint.zRotationLimits,
1452
+ };
1453
+ }
1454
+ return null;
1455
+ }, refId);
1456
+ },
1457
+ getCylindricalConstraint: (refId, constrName) => {
1458
+ return this.resolve(async ([rRefId]) => {
1459
+ const constraint = asmUtils.getCylindricalConstraint(drawingId, rRefId, constrName);
1460
+ if (constraint != undefined) {
1461
+ return {
1462
+ constrId: constraint.constrId,
1463
+ mate1: constraint.mate1,
1464
+ mate2: constraint.mate2,
1465
+ zOffsetLimits: constraint.zOffsetLimits,
1466
+ zRotationLimits: constraint.zRotationLimits,
1467
+ };
1468
+ }
1469
+ return null;
1470
+ }, refId);
1471
+ },
1015
1472
  getFeatureByName: (partId, featureName) => {
1016
1473
  return this.resolve(async ([rProductId]) => {
1017
1474
  const feature = await featureAPI.getFeatureByName(drawingId, rProductId, featureName);
@@ -1021,18 +1478,9 @@ class CAD {
1021
1478
  return null;
1022
1479
  }, partId);
1023
1480
  },
1024
- removeNode: (referenceId, ownerId) => {
1025
- return this.resolve(async ([rReferenceId, rOwnerId]) => {
1026
- await classcad_1.ccAPI.assemblyBuilder.removeNode(drawingId, rReferenceId, rOwnerId);
1027
- }, referenceId, ownerId);
1028
- },
1029
1481
  removeNodes: (...nodes) => {
1030
1482
  return this.resolve(async ([...rNodes]) => {
1031
- const nodesToRemove = [];
1032
- rNodes.forEach(node => {
1033
- nodesToRemove.push([node.referenceId, node.ownerId]);
1034
- });
1035
- return classcad_1.ccAPI.assemblyBuilder.removeNodes(drawingId, nodesToRemove);
1483
+ return assemblyBuilderAPI.removeNodes(drawingId, rNodes);
1036
1484
  }, ...nodes);
1037
1485
  },
1038
1486
  importFeature: (partId, content, format, name) => {
@@ -1055,7 +1503,7 @@ class CAD {
1055
1503
  await featureAPI.closeFeature(drawingId, sketch);
1056
1504
  const tree = (0, core_1.getDrawing)(drawingId).structure.tree;
1057
1505
  const plane = tree[rPlaneId];
1058
- if (plane && base.isA(plane.class, classcad_1.CCClasses.CCWorkPlane)) {
1506
+ if (plane && baseUtils.isA(plane.class, classcad_1.CCClasses.CCWorkPlane)) {
1059
1507
  await sketcherAPI.setWorkPlane(drawingId, sketch, rPlaneId);
1060
1508
  }
1061
1509
  else {
@@ -1073,7 +1521,7 @@ class CAD {
1073
1521
  await featureAPI.closeFeature(drawingId, sketch);
1074
1522
  const tree = (0, core_1.getDrawing)(drawingId).structure.tree;
1075
1523
  const plane = tree[rPlaneId];
1076
- if (plane && base.isA(plane.class, classcad_1.CCClasses.CCWorkPlane)) {
1524
+ if (plane && baseUtils.isA(plane.class, classcad_1.CCClasses.CCWorkPlane)) {
1077
1525
  await sketcherAPI.setWorkPlane(drawingId, sketch, rPlaneId);
1078
1526
  }
1079
1527
  else {
@@ -1091,7 +1539,7 @@ class CAD {
1091
1539
  },
1092
1540
  transformNode: (referenceId, ownerId, transformation) => {
1093
1541
  return this.resolve(async ([rRefId, rOwnerId]) => {
1094
- await classcad_1.ccAPI.assemblyBuilder.setNodeTransformation(drawingId, rRefId, rOwnerId, transformation);
1542
+ await assemblyBuilderAPI.setNodeTransformation(drawingId, rRefId, rOwnerId, transformation);
1095
1543
  }, referenceId, ownerId);
1096
1544
  },
1097
1545
  translate: (partId, featureIds, references, inverted, distance) => {
@@ -1168,7 +1616,9 @@ class CAD {
1168
1616
  };
1169
1617
  membersToModify.push({ name: mem.name, value: featureAPIParam });
1170
1618
  });
1171
- const success = featureAPI.updateExpressionSet(drawingId, rPartId, [], membersToModify, []);
1619
+ const success = featureAPI.updateExpressionSets(drawingId, [
1620
+ { productId: rPartId, toAddMembers: [], toModifyMembers: membersToModify, toDeleteList: [] },
1621
+ ]);
1172
1622
  return success;
1173
1623
  }, partId);
1174
1624
  },
@@ -1198,7 +1648,9 @@ class CAD {
1198
1648
  },
1199
1649
  deleteExpressions: (partId, members) => {
1200
1650
  return this.resolve(async ([rPartId]) => {
1201
- const success = featureAPI.updateExpressionSet(drawingId, rPartId, [], [], members);
1651
+ const success = featureAPI.updateExpressionSets(drawingId, [
1652
+ { productId: rPartId, toAddMembers: [], toModifyMembers: [], toDeleteList: members },
1653
+ ]);
1202
1654
  return success;
1203
1655
  }, partId);
1204
1656
  },
@@ -1213,6 +1665,54 @@ class CAD {
1213
1665
  return null;
1214
1666
  }, partId, ...references);
1215
1667
  },
1668
+ mirror: async (partId, entities, references) => {
1669
+ const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
1670
+ const rEntities = await new Promise(res => this.resolve(ids => res(ids), ...entities));
1671
+ const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
1672
+ const cDrawing = (0, core_1.getDrawing)(drawingId);
1673
+ const entArray = [];
1674
+ for (const rEntity of rEntities) {
1675
+ const entity = cDrawing.structure.tree[rEntity].children;
1676
+ if (entity != undefined) {
1677
+ entArray.push(entity[0]);
1678
+ }
1679
+ }
1680
+ const mirrorId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCMirror, 'Mirror');
1681
+ if (mirrorId != null) {
1682
+ await featureAPI.updateMirror(drawingId, mirrorId, entArray, rReferences);
1683
+ return mirrorId;
1684
+ }
1685
+ return null;
1686
+ },
1687
+ removeOperations: async (operations, toOperation) => {
1688
+ const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
1689
+ const [rToOperation] = await new Promise(res => this.resolve(paths => res(paths), toOperation));
1690
+ if (operations && operations.length > 0) {
1691
+ await baseModelerAPI.deleteObjects(drawingId, rOperations);
1692
+ }
1693
+ else if (rToOperation) {
1694
+ const toRemoveOps = [];
1695
+ const cDrawing = (0, core_1.getDrawing)(drawingId);
1696
+ const tree = cDrawing.structure.tree;
1697
+ const opSeq = cDrawing.api.structure.filterTree(tree, obj => obj.name === 'OperationSequence').pop();
1698
+ const opRefs = opSeq && baseUtils.getChildren(opSeq.id, classcad_1.CCClasses.CCObjectReference, tree);
1699
+ const filteredOps = opRefs === null || opRefs === void 0 ? void 0 : opRefs.map(opRef => { var _a, _b; return (_b = (_a = tree[opRef].members) === null || _a === void 0 ? void 0 : _a.refObj) === null || _b === void 0 ? void 0 : _b.value; });
1700
+ if (filteredOps) {
1701
+ let opNotFound = true;
1702
+ let index = filteredOps.length - 2; // -2 => Avoid RollBackBar
1703
+ while (opNotFound) {
1704
+ if (filteredOps[index] !== rToOperation) {
1705
+ toRemoveOps.push(filteredOps[index]);
1706
+ }
1707
+ else {
1708
+ opNotFound = false;
1709
+ }
1710
+ index--;
1711
+ }
1712
+ }
1713
+ await baseModelerAPI.deleteObjects(drawingId, toRemoveOps);
1714
+ }
1715
+ },
1216
1716
  };
1217
1717
  callback(publicApi);
1218
1718
  resolve(drawingId);