@buerli.io/headless 0.12.0 → 0.13.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @buerli.io/headless
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - - Add new API method `twist()` to create twist feature.
8
+ - Add new API method `getSketch()`to be able to get a sketch by its name from a part or instance.
9
+ - Extended input parameter of methods `extrusion()` and `revolve()`, to be able to use sketch curves,
10
+ sketch regions and composite curves directly, beside sketches which were already possible as input.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ - Updated dependencies
16
+ - Updated dependencies
17
+ - @buerli.io/classcad@0.13.0
18
+
3
19
  ## 0.12.0
4
20
 
5
21
  ### Patch Changes
@@ -474,8 +474,10 @@ class History {
474
474
  return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
475
475
  const extrusion = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCExtrusion, 'Extrusion');
476
476
  if (extrusion) {
477
- const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
478
- if (sketchLines) {
477
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
478
+ ? rSketchOrRegionIds
479
+ : [rSketchOrRegionIds];
480
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
479
481
  const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
480
482
  const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
481
483
  const taperAngleParam = {
@@ -487,7 +489,7 @@ class History {
487
489
  value: resDirection,
488
490
  isExpr: typeof resDirection === 'string',
489
491
  };
490
- await featureAPI.updateExtrusion(drawingId, extrusion, sketchLines, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
492
+ await featureAPI.updateExtrusion(drawingId, extrusion, resSketchOrRegionIds, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
491
493
  return extrusion;
492
494
  }
493
495
  }
@@ -497,11 +499,13 @@ class History {
497
499
  return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
498
500
  const revolve = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCRevolve, 'Revolve');
499
501
  if (revolve) {
500
- const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
501
- if (sketchLines) {
502
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
503
+ ? rSketchOrRegionIds
504
+ : [rSketchOrRegionIds];
505
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
502
506
  const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
503
507
  const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
504
- await featureAPI.updateRevolve(drawingId, revolve, sketchLines, rAxisIds, angle1Param, angle2Param, inverted);
508
+ await featureAPI.updateRevolve(drawingId, revolve, resSketchOrRegionIds, rAxisIds, angle1Param, angle2Param, inverted);
505
509
  return revolve;
506
510
  }
507
511
  }
@@ -1085,8 +1089,239 @@ class History {
1085
1089
  }
1086
1090
  await assemblyBuilderAPI.updateParallelConstraints(drawingId, constrToAdd);
1087
1091
  },
1088
- update3dConstraintValues: async (...constrValues) => {
1092
+ createGroupConstraint: async (id, instanceIds, name) => {
1093
+ const [rId] = await new Promise(res => this.resolve(ids => res(ids), id));
1094
+ const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...instanceIds));
1095
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCGroupConstraint, name);
1096
+ if (constraintId != null) {
1097
+ await assemblyBuilderAPI.updateGroupConstraints(drawingId, [
1098
+ {
1099
+ constrId: constraintId,
1100
+ instanceIds: rInstanceIds,
1101
+ },
1102
+ ]);
1103
+ return constraintId;
1104
+ }
1105
+ return null;
1106
+ },
1107
+ updateGroupConstraints: async (...constraints) => {
1089
1108
  var e_10, _a;
1109
+ const constrToAdd = [];
1110
+ try {
1111
+ for (var constraints_8 = __asyncValues(constraints), constraints_8_1; constraints_8_1 = await constraints_8.next(), !constraints_8_1.done;) {
1112
+ const constr = constraints_8_1.value;
1113
+ const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId));
1114
+ const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...constr.instanceIds));
1115
+ constrToAdd.push({
1116
+ constrId: rConstrId,
1117
+ instanceIds: rInstanceIds,
1118
+ });
1119
+ }
1120
+ }
1121
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1122
+ finally {
1123
+ try {
1124
+ if (constraints_8_1 && !constraints_8_1.done && (_a = constraints_8.return)) await _a.call(constraints_8);
1125
+ }
1126
+ finally { if (e_10) throw e_10.error; }
1127
+ }
1128
+ await assemblyBuilderAPI.updateGroupConstraints(drawingId, constrToAdd);
1129
+ },
1130
+ createLinearPatternConstraint: async (id, instanceId, mate1, firstDirInstanceCount, firstDirDistance, name, mate2, secondDirInstanceCount, secondDirDistance) => {
1131
+ const [rId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId, mate2 === null || mate2 === void 0 ? void 0 : mate2.wcsId));
1132
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
1133
+ let rMatePath2;
1134
+ if (mate2) {
1135
+ rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
1136
+ }
1137
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCLinearPatternConstraint, name);
1138
+ if (constraintId != null) {
1139
+ const firstDirInstanceCountParam = {
1140
+ value: firstDirInstanceCount,
1141
+ isExpr: typeof firstDirInstanceCount === 'string',
1142
+ };
1143
+ const firstDirDistanceParam = {
1144
+ value: firstDirDistance,
1145
+ isExpr: typeof firstDirDistance === 'string',
1146
+ };
1147
+ const secondDirInstanceCountParam = secondDirInstanceCount !== undefined
1148
+ ? {
1149
+ value: secondDirInstanceCount,
1150
+ isExpr: typeof secondDirInstanceCount === 'string',
1151
+ }
1152
+ : undefined;
1153
+ const secondDirDistanceParam = secondDirDistance !== undefined
1154
+ ? {
1155
+ value: secondDirDistance,
1156
+ isExpr: typeof secondDirDistance === 'string',
1157
+ }
1158
+ : undefined;
1159
+ await assemblyBuilderAPI.updateLinearPatternConstraints(drawingId, [
1160
+ {
1161
+ constrId: constraintId,
1162
+ instanceId: rInstanceId,
1163
+ mate1: {
1164
+ matePath: rMatePath1,
1165
+ wcsId: rWcs1,
1166
+ flip: mate1.flip,
1167
+ reoriented: mate1.reoriented,
1168
+ },
1169
+ firstDirInstanceCount: firstDirInstanceCountParam,
1170
+ firstDirDistance: firstDirDistanceParam,
1171
+ mate2: mate2
1172
+ ? {
1173
+ matePath: rMatePath2,
1174
+ wcsId: rWcs2,
1175
+ flip: mate2.flip,
1176
+ reoriented: mate2.reoriented,
1177
+ }
1178
+ : undefined,
1179
+ secondDirInstanceCount: secondDirInstanceCountParam,
1180
+ secondDirDistance: secondDirDistanceParam,
1181
+ },
1182
+ ]);
1183
+ return constraintId;
1184
+ }
1185
+ return null;
1186
+ },
1187
+ updateLinearPatternConstraints: async (...constraints) => {
1188
+ var e_11, _a;
1189
+ const constrToAdd = [];
1190
+ try {
1191
+ for (var constraints_9 = __asyncValues(constraints), constraints_9_1; constraints_9_1 = await constraints_9.next(), !constraints_9_1.done;) {
1192
+ const constr = constraints_9_1.value;
1193
+ const [rConstrId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => {
1194
+ var _a;
1195
+ return this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId, (_a = constr.mate2) === null || _a === void 0 ? void 0 : _a.wcsId);
1196
+ });
1197
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
1198
+ let rMatePath2;
1199
+ if (constr.mate2) {
1200
+ rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
1201
+ }
1202
+ const firstDirInstanceCountParam = {
1203
+ value: constr.firstDirInstanceCount,
1204
+ isExpr: typeof constr.firstDirInstanceCount === 'string',
1205
+ };
1206
+ const firstDirDistanceParam = {
1207
+ value: constr.firstDirDistance,
1208
+ isExpr: typeof constr.firstDirDistance === 'string',
1209
+ };
1210
+ const secondDirInstanceCountParam = constr.secondDirInstanceCount !== undefined
1211
+ ? {
1212
+ value: constr.secondDirInstanceCount,
1213
+ isExpr: typeof constr.secondDirInstanceCount === 'string',
1214
+ }
1215
+ : undefined;
1216
+ const secondDirDistanceParam = constr.secondDirDistance !== undefined
1217
+ ? {
1218
+ value: constr.secondDirDistance,
1219
+ isExpr: typeof constr.secondDirDistance === 'string',
1220
+ }
1221
+ : undefined;
1222
+ constrToAdd.push({
1223
+ constrId: rConstrId,
1224
+ instanceId: rInstanceId,
1225
+ mate1: {
1226
+ matePath: rMatePath1,
1227
+ wcsId: rWcs1,
1228
+ flip: constr.mate1.flip,
1229
+ reoriented: constr.mate1.reoriented,
1230
+ },
1231
+ firstDirInstanceCount: firstDirInstanceCountParam,
1232
+ firstDirDistance: firstDirDistanceParam,
1233
+ mate2: constr.mate2
1234
+ ? {
1235
+ matePath: rMatePath2,
1236
+ wcsId: rWcs2,
1237
+ flip: constr.mate2.flip,
1238
+ reoriented: constr.mate2.reoriented,
1239
+ }
1240
+ : undefined,
1241
+ secondDirInstanceCount: secondDirInstanceCountParam,
1242
+ secondDirDistance: secondDirDistanceParam,
1243
+ });
1244
+ }
1245
+ }
1246
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1247
+ finally {
1248
+ try {
1249
+ if (constraints_9_1 && !constraints_9_1.done && (_a = constraints_9.return)) await _a.call(constraints_9);
1250
+ }
1251
+ finally { if (e_11) throw e_11.error; }
1252
+ }
1253
+ await assemblyBuilderAPI.updateLinearPatternConstraints(drawingId, constrToAdd);
1254
+ },
1255
+ createCircularPatternConstraint: async (id, instanceId, mate1, instanceCount, angle, offset, name) => {
1256
+ const [rId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId));
1257
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
1258
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, classcad_1.CCClasses.CCCircularPatternConstraint, name);
1259
+ if (constraintId != null) {
1260
+ const instanceCountParam = {
1261
+ value: instanceCount,
1262
+ isExpr: typeof instanceCount === 'string',
1263
+ };
1264
+ const angleParam = { value: angle, isExpr: typeof angle === 'string' };
1265
+ const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
1266
+ await assemblyBuilderAPI.updateCircularPatternConstraints(drawingId, [
1267
+ {
1268
+ constrId: constraintId,
1269
+ instanceId: rInstanceId,
1270
+ mate1: {
1271
+ matePath: rMatePath1,
1272
+ wcsId: rWcs1,
1273
+ flip: mate1.flip,
1274
+ reoriented: mate1.reoriented,
1275
+ },
1276
+ instanceCount: instanceCountParam,
1277
+ angle: angleParam,
1278
+ offset: offsetParam,
1279
+ },
1280
+ ]);
1281
+ return constraintId;
1282
+ }
1283
+ return null;
1284
+ },
1285
+ updateCircularPatternConstraints: async (...constraints) => {
1286
+ var e_12, _a;
1287
+ const constrToAdd = [];
1288
+ try {
1289
+ for (var constraints_10 = __asyncValues(constraints), constraints_10_1; constraints_10_1 = await constraints_10.next(), !constraints_10_1.done;) {
1290
+ const constr = constraints_10_1.value;
1291
+ const [rConstrId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId));
1292
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
1293
+ const instanceCountParam = {
1294
+ value: constr.instanceCount,
1295
+ isExpr: typeof constr.instanceCount === 'string',
1296
+ };
1297
+ const angleParam = { value: constr.angle, isExpr: typeof constr.angle === 'string' };
1298
+ const offsetParam = { value: constr.offset, isExpr: typeof constr.offset === 'string' };
1299
+ constrToAdd.push({
1300
+ constrId: rConstrId,
1301
+ instanceId: rInstanceId,
1302
+ mate1: {
1303
+ matePath: rMatePath1,
1304
+ wcsId: rWcs1,
1305
+ flip: constr.mate1.flip,
1306
+ reoriented: constr.mate1.reoriented,
1307
+ },
1308
+ instanceCount: instanceCountParam,
1309
+ angle: angleParam,
1310
+ offset: offsetParam,
1311
+ });
1312
+ }
1313
+ }
1314
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1315
+ finally {
1316
+ try {
1317
+ if (constraints_10_1 && !constraints_10_1.done && (_a = constraints_10.return)) await _a.call(constraints_10);
1318
+ }
1319
+ finally { if (e_12) throw e_12.error; }
1320
+ }
1321
+ await assemblyBuilderAPI.updateCircularPatternConstraints(drawingId, constrToAdd);
1322
+ },
1323
+ update3dConstraintValues: async (...constrValues) => {
1324
+ var e_13, _a;
1090
1325
  const constrValueParams = [];
1091
1326
  try {
1092
1327
  for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
@@ -1099,12 +1334,12 @@ class History {
1099
1334
  });
1100
1335
  }
1101
1336
  }
1102
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
1337
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1103
1338
  finally {
1104
1339
  try {
1105
1340
  if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
1106
1341
  }
1107
- finally { if (e_10) throw e_10.error; }
1342
+ finally { if (e_13) throw e_13.error; }
1108
1343
  }
1109
1344
  await assemblyBuilderAPI.update3DConstraintValues(drawingId, constrValueParams);
1110
1345
  },
@@ -1423,6 +1658,15 @@ class History {
1423
1658
  return null;
1424
1659
  }, id);
1425
1660
  },
1661
+ getSketch: (id, sketchName) => {
1662
+ return this.resolve(async ([rId]) => {
1663
+ const sIds = partUtils.getSketch(drawingId, rId, sketchName);
1664
+ if (sIds != undefined) {
1665
+ return Array.isArray(sIds) ? sIds : [sIds];
1666
+ }
1667
+ return null;
1668
+ }, id);
1669
+ },
1426
1670
  getWorkGeometry: (refId, type, wgName) => {
1427
1671
  return this.resolve(async ([rRefId]) => {
1428
1672
  const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
@@ -1559,6 +1803,52 @@ class History {
1559
1803
  return null;
1560
1804
  }, id);
1561
1805
  },
1806
+ getGroupConstraint: (id, constrName) => {
1807
+ return this.resolve(async ([rId]) => {
1808
+ const constraint = asmUtils.getGroupConstraint(drawingId, rId, constrName);
1809
+ if (constraint != undefined) {
1810
+ return {
1811
+ constrId: constraint.constrId,
1812
+ instanceIds: constraint.instanceIds,
1813
+ };
1814
+ }
1815
+ return null;
1816
+ }, id);
1817
+ },
1818
+ getLinearPatternConstraint: (id, constrName) => {
1819
+ return this.resolve(async ([rId]) => {
1820
+ const constraint = asmUtils.getLinearPatternConstraint(drawingId, rId, constrName);
1821
+ if (constraint != undefined) {
1822
+ return {
1823
+ constrId: constraint.constrId,
1824
+ instanceId: constraint.instanceId,
1825
+ mate1: constraint.mate1,
1826
+ firstDirInstanceCount: constraint.firstDirInstanceCount.value,
1827
+ firstDirDistance: constraint.firstDirDistance.value,
1828
+ mate2: constraint.mate2,
1829
+ secondDirInstanceCount: constraint.secondDirInstanceCount.value,
1830
+ secondDirDistance: constraint.secondDirDistance.value,
1831
+ };
1832
+ }
1833
+ return null;
1834
+ }, id);
1835
+ },
1836
+ getCircularPatternConstraint: (id, constrName) => {
1837
+ return this.resolve(async ([rId]) => {
1838
+ const constraint = asmUtils.getCircularPatternConstraint(drawingId, rId, constrName);
1839
+ if (constraint != undefined) {
1840
+ return {
1841
+ constrId: constraint.constrId,
1842
+ instanceId: constraint.instanceId,
1843
+ mate1: constraint.mate1,
1844
+ instanceCount: constraint.instanceCount.value,
1845
+ angle: constraint.angle.value,
1846
+ offset: constraint.offset.value,
1847
+ };
1848
+ }
1849
+ return null;
1850
+ }, id);
1851
+ },
1562
1852
  getFeatureByName: (partId, featureName) => {
1563
1853
  return this.resolve(async ([rProductId]) => {
1564
1854
  const feature = await featureAPI.getFeatureByName(drawingId, rProductId, featureName);
@@ -1578,7 +1868,7 @@ class History {
1578
1868
  }, id);
1579
1869
  },
1580
1870
  removeInstances: async (...instances) => {
1581
- var e_11, _a;
1871
+ var e_14, _a;
1582
1872
  const instancesToRemove = [];
1583
1873
  try {
1584
1874
  for (var instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = await instances_2.next(), !instances_2_1.done;) {
@@ -1606,12 +1896,12 @@ class History {
1606
1896
  instancesToRemove.push(instanceParam);
1607
1897
  }
1608
1898
  }
1609
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1899
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1610
1900
  finally {
1611
1901
  try {
1612
1902
  if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
1613
1903
  }
1614
- finally { if (e_11) throw e_11.error; }
1904
+ finally { if (e_14) throw e_14.error; }
1615
1905
  }
1616
1906
  return assemblyBuilderAPI.removeInstances(drawingId, instancesToRemove);
1617
1907
  },
@@ -1670,7 +1960,7 @@ class History {
1670
1960
  }, sketchId, planeId, axisId, originId);
1671
1961
  },
1672
1962
  transformInstances: async (...instances) => {
1673
- var e_12, _a;
1963
+ var e_15, _a;
1674
1964
  const instancesToTransform = [];
1675
1965
  try {
1676
1966
  for (var instances_3 = __asyncValues(instances), instances_3_1; instances_3_1 = await instances_3.next(), !instances_3_1.done;) {
@@ -1702,12 +1992,12 @@ class History {
1702
1992
  instancesToTransform.push(instanceParam);
1703
1993
  }
1704
1994
  }
1705
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1995
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1706
1996
  finally {
1707
1997
  try {
1708
1998
  if (instances_3_1 && !instances_3_1.done && (_a = instances_3.return)) await _a.call(instances_3);
1709
1999
  }
1710
- finally { if (e_12) throw e_12.error; }
2000
+ finally { if (e_15) throw e_15.error; }
1711
2001
  }
1712
2002
  return assemblyBuilderAPI.transformInstances(drawingId, instancesToTransform);
1713
2003
  },
@@ -1776,7 +2066,7 @@ class History {
1776
2066
  }, partId);
1777
2067
  },
1778
2068
  setExpressions: async (...expressions) => {
1779
- var e_13, _a;
2069
+ var e_16, _a;
1780
2070
  const expressionsToSet = [];
1781
2071
  try {
1782
2072
  for (var expressions_1 = __asyncValues(expressions), expressions_1_1; expressions_1_1 = await expressions_1.next(), !expressions_1_1.done;) {
@@ -1818,12 +2108,12 @@ class History {
1818
2108
  });
1819
2109
  }
1820
2110
  }
1821
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
2111
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
1822
2112
  finally {
1823
2113
  try {
1824
2114
  if (expressions_1_1 && !expressions_1_1.done && (_a = expressions_1.return)) await _a.call(expressions_1);
1825
2115
  }
1826
- finally { if (e_13) throw e_13.error; }
2116
+ finally { if (e_16) throw e_16.error; }
1827
2117
  }
1828
2118
  const success = await featureAPI.updateExpressions(drawingId, expressionsToSet);
1829
2119
  return success;
@@ -1944,6 +2234,48 @@ class History {
1944
2234
  }
1945
2235
  return null;
1946
2236
  },
2237
+ twist: async (param) => {
2238
+ return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
2239
+ const twist = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCTwist, 'Twist');
2240
+ if (twist) {
2241
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
2242
+ ? rSketchOrRegionIds
2243
+ : [rSketchOrRegionIds];
2244
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
2245
+ const limit1Param = {
2246
+ value: param.limit1,
2247
+ isExpr: typeof param.limit1 === 'string',
2248
+ };
2249
+ const limit2Param = {
2250
+ value: param.limit2,
2251
+ isExpr: typeof param.limit2 === 'string',
2252
+ };
2253
+ const twistAngleParam = {
2254
+ value: param.twistAngle,
2255
+ isExpr: typeof param.twistAngle === 'string',
2256
+ };
2257
+ if (!param.direction) {
2258
+ param.direction = { x: 0, y: 0, z: 1 };
2259
+ }
2260
+ if (!param.twistCenter) {
2261
+ param.twistCenter = { x: 0, y: 0, z: 0 };
2262
+ }
2263
+ const resDirection = resolveVec(param.direction);
2264
+ const directionParam = {
2265
+ value: resDirection,
2266
+ isExpr: typeof resDirection === 'string',
2267
+ };
2268
+ const resTwistCenter = resolveVec(param.twistCenter);
2269
+ const twistCenterParam = {
2270
+ value: resTwistCenter,
2271
+ isExpr: typeof resTwistCenter === 'string',
2272
+ };
2273
+ await featureAPI.updateTwist(drawingId, twist, resSketchOrRegionIds, param.type, limit1Param, limit2Param, directionParam, twistAngleParam, twistCenterParam, param.capEnds);
2274
+ return twist;
2275
+ }
2276
+ }
2277
+ }, param.partId, param.sketchOrRegionIds);
2278
+ },
1947
2279
  };
1948
2280
  callback(publicApi);
1949
2281
  resolve(drawingId);
@@ -14,6 +14,7 @@ const core_1 = require("@buerli.io/core");
14
14
  const three_1 = require("three");
15
15
  const three_stdlib_1 = require("three-stdlib");
16
16
  const meshes_1 = require("./utils/meshes");
17
+ const isShape = (entity) => entity && entity.type === 'Shape';
17
18
  const solidAPI = classcad_1.ccAPI.solid;
18
19
  const toCCVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
19
20
  const toCCNbrVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
@@ -336,7 +337,7 @@ class Solid {
336
337
  },
337
338
  extrude: (height, region) => {
338
339
  return this.resolve(async () => {
339
- if (region instanceof three_1.Shape) {
340
+ if (isShape(region)) {
340
341
  const curveArray = makeCCData(region.curves);
341
342
  return solidAPI.createExtrudeRegion(drawingId, makeNbrVec(height), curveArray);
342
343
  }
@@ -402,7 +403,7 @@ class Solid {
402
403
  },
403
404
  revolve: (position, direction, angle, region) => {
404
405
  return this.resolve(async () => {
405
- if (region instanceof three_1.Shape) {
406
+ if (isShape(region)) {
406
407
  const curveArray = makeCCData(region.curves);
407
408
  return solidAPI.createRevolveRegion(drawingId, makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
408
409
  }
@@ -471,8 +471,10 @@ export class History {
471
471
  return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
472
472
  const extrusion = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCExtrusion, 'Extrusion');
473
473
  if (extrusion) {
474
- const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
475
- if (sketchLines) {
474
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
475
+ ? rSketchOrRegionIds
476
+ : [rSketchOrRegionIds];
477
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
476
478
  const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
477
479
  const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
478
480
  const taperAngleParam = {
@@ -484,7 +486,7 @@ export class History {
484
486
  value: resDirection,
485
487
  isExpr: typeof resDirection === 'string',
486
488
  };
487
- await featureAPI.updateExtrusion(drawingId, extrusion, sketchLines, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
489
+ await featureAPI.updateExtrusion(drawingId, extrusion, resSketchOrRegionIds, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
488
490
  return extrusion;
489
491
  }
490
492
  }
@@ -494,11 +496,13 @@ export class History {
494
496
  return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
495
497
  const revolve = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCRevolve, 'Revolve');
496
498
  if (revolve) {
497
- const sketchLines = partUtils.getSketchlines(drawingId, rSketchOrRegionIds);
498
- if (sketchLines) {
499
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
500
+ ? rSketchOrRegionIds
501
+ : [rSketchOrRegionIds];
502
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
499
503
  const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
500
504
  const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
501
- await featureAPI.updateRevolve(drawingId, revolve, sketchLines, rAxisIds, angle1Param, angle2Param, inverted);
505
+ await featureAPI.updateRevolve(drawingId, revolve, resSketchOrRegionIds, rAxisIds, angle1Param, angle2Param, inverted);
502
506
  return revolve;
503
507
  }
504
508
  }
@@ -1082,8 +1086,239 @@ export class History {
1082
1086
  }
1083
1087
  await assemblyBuilderAPI.updateParallelConstraints(drawingId, constrToAdd);
1084
1088
  },
1085
- update3dConstraintValues: async (...constrValues) => {
1089
+ createGroupConstraint: async (id, instanceIds, name) => {
1090
+ const [rId] = await new Promise(res => this.resolve(ids => res(ids), id));
1091
+ const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...instanceIds));
1092
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCGroupConstraint, name);
1093
+ if (constraintId != null) {
1094
+ await assemblyBuilderAPI.updateGroupConstraints(drawingId, [
1095
+ {
1096
+ constrId: constraintId,
1097
+ instanceIds: rInstanceIds,
1098
+ },
1099
+ ]);
1100
+ return constraintId;
1101
+ }
1102
+ return null;
1103
+ },
1104
+ updateGroupConstraints: async (...constraints) => {
1086
1105
  var e_10, _a;
1106
+ const constrToAdd = [];
1107
+ try {
1108
+ for (var constraints_8 = __asyncValues(constraints), constraints_8_1; constraints_8_1 = await constraints_8.next(), !constraints_8_1.done;) {
1109
+ const constr = constraints_8_1.value;
1110
+ const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId));
1111
+ const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...constr.instanceIds));
1112
+ constrToAdd.push({
1113
+ constrId: rConstrId,
1114
+ instanceIds: rInstanceIds,
1115
+ });
1116
+ }
1117
+ }
1118
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1119
+ finally {
1120
+ try {
1121
+ if (constraints_8_1 && !constraints_8_1.done && (_a = constraints_8.return)) await _a.call(constraints_8);
1122
+ }
1123
+ finally { if (e_10) throw e_10.error; }
1124
+ }
1125
+ await assemblyBuilderAPI.updateGroupConstraints(drawingId, constrToAdd);
1126
+ },
1127
+ createLinearPatternConstraint: async (id, instanceId, mate1, firstDirInstanceCount, firstDirDistance, name, mate2, secondDirInstanceCount, secondDirDistance) => {
1128
+ const [rId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId, mate2 === null || mate2 === void 0 ? void 0 : mate2.wcsId));
1129
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
1130
+ let rMatePath2;
1131
+ if (mate2) {
1132
+ rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
1133
+ }
1134
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCLinearPatternConstraint, name);
1135
+ if (constraintId != null) {
1136
+ const firstDirInstanceCountParam = {
1137
+ value: firstDirInstanceCount,
1138
+ isExpr: typeof firstDirInstanceCount === 'string',
1139
+ };
1140
+ const firstDirDistanceParam = {
1141
+ value: firstDirDistance,
1142
+ isExpr: typeof firstDirDistance === 'string',
1143
+ };
1144
+ const secondDirInstanceCountParam = secondDirInstanceCount !== undefined
1145
+ ? {
1146
+ value: secondDirInstanceCount,
1147
+ isExpr: typeof secondDirInstanceCount === 'string',
1148
+ }
1149
+ : undefined;
1150
+ const secondDirDistanceParam = secondDirDistance !== undefined
1151
+ ? {
1152
+ value: secondDirDistance,
1153
+ isExpr: typeof secondDirDistance === 'string',
1154
+ }
1155
+ : undefined;
1156
+ await assemblyBuilderAPI.updateLinearPatternConstraints(drawingId, [
1157
+ {
1158
+ constrId: constraintId,
1159
+ instanceId: rInstanceId,
1160
+ mate1: {
1161
+ matePath: rMatePath1,
1162
+ wcsId: rWcs1,
1163
+ flip: mate1.flip,
1164
+ reoriented: mate1.reoriented,
1165
+ },
1166
+ firstDirInstanceCount: firstDirInstanceCountParam,
1167
+ firstDirDistance: firstDirDistanceParam,
1168
+ mate2: mate2
1169
+ ? {
1170
+ matePath: rMatePath2,
1171
+ wcsId: rWcs2,
1172
+ flip: mate2.flip,
1173
+ reoriented: mate2.reoriented,
1174
+ }
1175
+ : undefined,
1176
+ secondDirInstanceCount: secondDirInstanceCountParam,
1177
+ secondDirDistance: secondDirDistanceParam,
1178
+ },
1179
+ ]);
1180
+ return constraintId;
1181
+ }
1182
+ return null;
1183
+ },
1184
+ updateLinearPatternConstraints: async (...constraints) => {
1185
+ var e_11, _a;
1186
+ const constrToAdd = [];
1187
+ try {
1188
+ for (var constraints_9 = __asyncValues(constraints), constraints_9_1; constraints_9_1 = await constraints_9.next(), !constraints_9_1.done;) {
1189
+ const constr = constraints_9_1.value;
1190
+ const [rConstrId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => {
1191
+ var _a;
1192
+ return this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId, (_a = constr.mate2) === null || _a === void 0 ? void 0 : _a.wcsId);
1193
+ });
1194
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
1195
+ let rMatePath2;
1196
+ if (constr.mate2) {
1197
+ rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
1198
+ }
1199
+ const firstDirInstanceCountParam = {
1200
+ value: constr.firstDirInstanceCount,
1201
+ isExpr: typeof constr.firstDirInstanceCount === 'string',
1202
+ };
1203
+ const firstDirDistanceParam = {
1204
+ value: constr.firstDirDistance,
1205
+ isExpr: typeof constr.firstDirDistance === 'string',
1206
+ };
1207
+ const secondDirInstanceCountParam = constr.secondDirInstanceCount !== undefined
1208
+ ? {
1209
+ value: constr.secondDirInstanceCount,
1210
+ isExpr: typeof constr.secondDirInstanceCount === 'string',
1211
+ }
1212
+ : undefined;
1213
+ const secondDirDistanceParam = constr.secondDirDistance !== undefined
1214
+ ? {
1215
+ value: constr.secondDirDistance,
1216
+ isExpr: typeof constr.secondDirDistance === 'string',
1217
+ }
1218
+ : undefined;
1219
+ constrToAdd.push({
1220
+ constrId: rConstrId,
1221
+ instanceId: rInstanceId,
1222
+ mate1: {
1223
+ matePath: rMatePath1,
1224
+ wcsId: rWcs1,
1225
+ flip: constr.mate1.flip,
1226
+ reoriented: constr.mate1.reoriented,
1227
+ },
1228
+ firstDirInstanceCount: firstDirInstanceCountParam,
1229
+ firstDirDistance: firstDirDistanceParam,
1230
+ mate2: constr.mate2
1231
+ ? {
1232
+ matePath: rMatePath2,
1233
+ wcsId: rWcs2,
1234
+ flip: constr.mate2.flip,
1235
+ reoriented: constr.mate2.reoriented,
1236
+ }
1237
+ : undefined,
1238
+ secondDirInstanceCount: secondDirInstanceCountParam,
1239
+ secondDirDistance: secondDirDistanceParam,
1240
+ });
1241
+ }
1242
+ }
1243
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1244
+ finally {
1245
+ try {
1246
+ if (constraints_9_1 && !constraints_9_1.done && (_a = constraints_9.return)) await _a.call(constraints_9);
1247
+ }
1248
+ finally { if (e_11) throw e_11.error; }
1249
+ }
1250
+ await assemblyBuilderAPI.updateLinearPatternConstraints(drawingId, constrToAdd);
1251
+ },
1252
+ createCircularPatternConstraint: async (id, instanceId, mate1, instanceCount, angle, offset, name) => {
1253
+ const [rId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId));
1254
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
1255
+ const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rId, CCClasses.CCCircularPatternConstraint, name);
1256
+ if (constraintId != null) {
1257
+ const instanceCountParam = {
1258
+ value: instanceCount,
1259
+ isExpr: typeof instanceCount === 'string',
1260
+ };
1261
+ const angleParam = { value: angle, isExpr: typeof angle === 'string' };
1262
+ const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
1263
+ await assemblyBuilderAPI.updateCircularPatternConstraints(drawingId, [
1264
+ {
1265
+ constrId: constraintId,
1266
+ instanceId: rInstanceId,
1267
+ mate1: {
1268
+ matePath: rMatePath1,
1269
+ wcsId: rWcs1,
1270
+ flip: mate1.flip,
1271
+ reoriented: mate1.reoriented,
1272
+ },
1273
+ instanceCount: instanceCountParam,
1274
+ angle: angleParam,
1275
+ offset: offsetParam,
1276
+ },
1277
+ ]);
1278
+ return constraintId;
1279
+ }
1280
+ return null;
1281
+ },
1282
+ updateCircularPatternConstraints: async (...constraints) => {
1283
+ var e_12, _a;
1284
+ const constrToAdd = [];
1285
+ try {
1286
+ for (var constraints_10 = __asyncValues(constraints), constraints_10_1; constraints_10_1 = await constraints_10.next(), !constraints_10_1.done;) {
1287
+ const constr = constraints_10_1.value;
1288
+ const [rConstrId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId));
1289
+ const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
1290
+ const instanceCountParam = {
1291
+ value: constr.instanceCount,
1292
+ isExpr: typeof constr.instanceCount === 'string',
1293
+ };
1294
+ const angleParam = { value: constr.angle, isExpr: typeof constr.angle === 'string' };
1295
+ const offsetParam = { value: constr.offset, isExpr: typeof constr.offset === 'string' };
1296
+ constrToAdd.push({
1297
+ constrId: rConstrId,
1298
+ instanceId: rInstanceId,
1299
+ mate1: {
1300
+ matePath: rMatePath1,
1301
+ wcsId: rWcs1,
1302
+ flip: constr.mate1.flip,
1303
+ reoriented: constr.mate1.reoriented,
1304
+ },
1305
+ instanceCount: instanceCountParam,
1306
+ angle: angleParam,
1307
+ offset: offsetParam,
1308
+ });
1309
+ }
1310
+ }
1311
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1312
+ finally {
1313
+ try {
1314
+ if (constraints_10_1 && !constraints_10_1.done && (_a = constraints_10.return)) await _a.call(constraints_10);
1315
+ }
1316
+ finally { if (e_12) throw e_12.error; }
1317
+ }
1318
+ await assemblyBuilderAPI.updateCircularPatternConstraints(drawingId, constrToAdd);
1319
+ },
1320
+ update3dConstraintValues: async (...constrValues) => {
1321
+ var e_13, _a;
1087
1322
  const constrValueParams = [];
1088
1323
  try {
1089
1324
  for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
@@ -1096,12 +1331,12 @@ export class History {
1096
1331
  });
1097
1332
  }
1098
1333
  }
1099
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
1334
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1100
1335
  finally {
1101
1336
  try {
1102
1337
  if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
1103
1338
  }
1104
- finally { if (e_10) throw e_10.error; }
1339
+ finally { if (e_13) throw e_13.error; }
1105
1340
  }
1106
1341
  await assemblyBuilderAPI.update3DConstraintValues(drawingId, constrValueParams);
1107
1342
  },
@@ -1420,6 +1655,15 @@ export class History {
1420
1655
  return null;
1421
1656
  }, id);
1422
1657
  },
1658
+ getSketch: (id, sketchName) => {
1659
+ return this.resolve(async ([rId]) => {
1660
+ const sIds = partUtils.getSketch(drawingId, rId, sketchName);
1661
+ if (sIds != undefined) {
1662
+ return Array.isArray(sIds) ? sIds : [sIds];
1663
+ }
1664
+ return null;
1665
+ }, id);
1666
+ },
1423
1667
  getWorkGeometry: (refId, type, wgName) => {
1424
1668
  return this.resolve(async ([rRefId]) => {
1425
1669
  const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
@@ -1556,6 +1800,52 @@ export class History {
1556
1800
  return null;
1557
1801
  }, id);
1558
1802
  },
1803
+ getGroupConstraint: (id, constrName) => {
1804
+ return this.resolve(async ([rId]) => {
1805
+ const constraint = asmUtils.getGroupConstraint(drawingId, rId, constrName);
1806
+ if (constraint != undefined) {
1807
+ return {
1808
+ constrId: constraint.constrId,
1809
+ instanceIds: constraint.instanceIds,
1810
+ };
1811
+ }
1812
+ return null;
1813
+ }, id);
1814
+ },
1815
+ getLinearPatternConstraint: (id, constrName) => {
1816
+ return this.resolve(async ([rId]) => {
1817
+ const constraint = asmUtils.getLinearPatternConstraint(drawingId, rId, constrName);
1818
+ if (constraint != undefined) {
1819
+ return {
1820
+ constrId: constraint.constrId,
1821
+ instanceId: constraint.instanceId,
1822
+ mate1: constraint.mate1,
1823
+ firstDirInstanceCount: constraint.firstDirInstanceCount.value,
1824
+ firstDirDistance: constraint.firstDirDistance.value,
1825
+ mate2: constraint.mate2,
1826
+ secondDirInstanceCount: constraint.secondDirInstanceCount.value,
1827
+ secondDirDistance: constraint.secondDirDistance.value,
1828
+ };
1829
+ }
1830
+ return null;
1831
+ }, id);
1832
+ },
1833
+ getCircularPatternConstraint: (id, constrName) => {
1834
+ return this.resolve(async ([rId]) => {
1835
+ const constraint = asmUtils.getCircularPatternConstraint(drawingId, rId, constrName);
1836
+ if (constraint != undefined) {
1837
+ return {
1838
+ constrId: constraint.constrId,
1839
+ instanceId: constraint.instanceId,
1840
+ mate1: constraint.mate1,
1841
+ instanceCount: constraint.instanceCount.value,
1842
+ angle: constraint.angle.value,
1843
+ offset: constraint.offset.value,
1844
+ };
1845
+ }
1846
+ return null;
1847
+ }, id);
1848
+ },
1559
1849
  getFeatureByName: (partId, featureName) => {
1560
1850
  return this.resolve(async ([rProductId]) => {
1561
1851
  const feature = await featureAPI.getFeatureByName(drawingId, rProductId, featureName);
@@ -1575,7 +1865,7 @@ export class History {
1575
1865
  }, id);
1576
1866
  },
1577
1867
  removeInstances: async (...instances) => {
1578
- var e_11, _a;
1868
+ var e_14, _a;
1579
1869
  const instancesToRemove = [];
1580
1870
  try {
1581
1871
  for (var instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = await instances_2.next(), !instances_2_1.done;) {
@@ -1603,12 +1893,12 @@ export class History {
1603
1893
  instancesToRemove.push(instanceParam);
1604
1894
  }
1605
1895
  }
1606
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
1896
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1607
1897
  finally {
1608
1898
  try {
1609
1899
  if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
1610
1900
  }
1611
- finally { if (e_11) throw e_11.error; }
1901
+ finally { if (e_14) throw e_14.error; }
1612
1902
  }
1613
1903
  return assemblyBuilderAPI.removeInstances(drawingId, instancesToRemove);
1614
1904
  },
@@ -1667,7 +1957,7 @@ export class History {
1667
1957
  }, sketchId, planeId, axisId, originId);
1668
1958
  },
1669
1959
  transformInstances: async (...instances) => {
1670
- var e_12, _a;
1960
+ var e_15, _a;
1671
1961
  const instancesToTransform = [];
1672
1962
  try {
1673
1963
  for (var instances_3 = __asyncValues(instances), instances_3_1; instances_3_1 = await instances_3.next(), !instances_3_1.done;) {
@@ -1699,12 +1989,12 @@ export class History {
1699
1989
  instancesToTransform.push(instanceParam);
1700
1990
  }
1701
1991
  }
1702
- catch (e_12_1) { e_12 = { error: e_12_1 }; }
1992
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1703
1993
  finally {
1704
1994
  try {
1705
1995
  if (instances_3_1 && !instances_3_1.done && (_a = instances_3.return)) await _a.call(instances_3);
1706
1996
  }
1707
- finally { if (e_12) throw e_12.error; }
1997
+ finally { if (e_15) throw e_15.error; }
1708
1998
  }
1709
1999
  return assemblyBuilderAPI.transformInstances(drawingId, instancesToTransform);
1710
2000
  },
@@ -1773,7 +2063,7 @@ export class History {
1773
2063
  }, partId);
1774
2064
  },
1775
2065
  setExpressions: async (...expressions) => {
1776
- var e_13, _a;
2066
+ var e_16, _a;
1777
2067
  const expressionsToSet = [];
1778
2068
  try {
1779
2069
  for (var expressions_1 = __asyncValues(expressions), expressions_1_1; expressions_1_1 = await expressions_1.next(), !expressions_1_1.done;) {
@@ -1815,12 +2105,12 @@ export class History {
1815
2105
  });
1816
2106
  }
1817
2107
  }
1818
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
2108
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
1819
2109
  finally {
1820
2110
  try {
1821
2111
  if (expressions_1_1 && !expressions_1_1.done && (_a = expressions_1.return)) await _a.call(expressions_1);
1822
2112
  }
1823
- finally { if (e_13) throw e_13.error; }
2113
+ finally { if (e_16) throw e_16.error; }
1824
2114
  }
1825
2115
  const success = await featureAPI.updateExpressions(drawingId, expressionsToSet);
1826
2116
  return success;
@@ -1941,6 +2231,48 @@ export class History {
1941
2231
  }
1942
2232
  return null;
1943
2233
  },
2234
+ twist: async (param) => {
2235
+ return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
2236
+ const twist = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCTwist, 'Twist');
2237
+ if (twist) {
2238
+ const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
2239
+ ? rSketchOrRegionIds
2240
+ : [rSketchOrRegionIds];
2241
+ if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
2242
+ const limit1Param = {
2243
+ value: param.limit1,
2244
+ isExpr: typeof param.limit1 === 'string',
2245
+ };
2246
+ const limit2Param = {
2247
+ value: param.limit2,
2248
+ isExpr: typeof param.limit2 === 'string',
2249
+ };
2250
+ const twistAngleParam = {
2251
+ value: param.twistAngle,
2252
+ isExpr: typeof param.twistAngle === 'string',
2253
+ };
2254
+ if (!param.direction) {
2255
+ param.direction = { x: 0, y: 0, z: 1 };
2256
+ }
2257
+ if (!param.twistCenter) {
2258
+ param.twistCenter = { x: 0, y: 0, z: 0 };
2259
+ }
2260
+ const resDirection = resolveVec(param.direction);
2261
+ const directionParam = {
2262
+ value: resDirection,
2263
+ isExpr: typeof resDirection === 'string',
2264
+ };
2265
+ const resTwistCenter = resolveVec(param.twistCenter);
2266
+ const twistCenterParam = {
2267
+ value: resTwistCenter,
2268
+ isExpr: typeof resTwistCenter === 'string',
2269
+ };
2270
+ await featureAPI.updateTwist(drawingId, twist, resSketchOrRegionIds, param.type, limit1Param, limit2Param, directionParam, twistAngleParam, twistCenterParam, param.capEnds);
2271
+ return twist;
2272
+ }
2273
+ }
2274
+ }, param.partId, param.sketchOrRegionIds);
2275
+ },
1944
2276
  };
1945
2277
  callback(publicApi);
1946
2278
  resolve(drawingId);
@@ -8,9 +8,10 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
8
8
  /* eslint-disable max-lines */
9
9
  import { ccAPI } from '@buerli.io/classcad';
10
10
  import { api, getDrawing } from '@buerli.io/core';
11
- import { Group, Mesh, MeshStandardMaterial, Scene, Shape } from 'three';
11
+ import { Group, Mesh, MeshStandardMaterial, Scene } from 'three';
12
12
  import { mergeBufferGeometries } from 'three-stdlib';
13
13
  import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
14
+ const isShape = (entity) => entity && entity.type === 'Shape';
14
15
  const solidAPI = ccAPI.solid;
15
16
  const toCCVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
16
17
  const toCCNbrVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
@@ -332,7 +333,7 @@ export class Solid {
332
333
  },
333
334
  extrude: (height, region) => {
334
335
  return this.resolve(async () => {
335
- if (region instanceof Shape) {
336
+ if (isShape(region)) {
336
337
  const curveArray = makeCCData(region.curves);
337
338
  return solidAPI.createExtrudeRegion(drawingId, makeNbrVec(height), curveArray);
338
339
  }
@@ -398,7 +399,7 @@ export class Solid {
398
399
  },
399
400
  revolve: (position, direction, angle, region) => {
400
401
  return this.resolve(async () => {
401
- if (region instanceof Shape) {
402
+ if (isShape(region)) {
402
403
  const curveArray = makeCCData(region.curves);
403
404
  return solidAPI.createRevolveRegion(drawingId, makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
404
405
  }
@@ -649,6 +649,96 @@ export declare type ApiHistory = {
649
649
  zOffsetLimits: LimitsParam;
650
650
  zRotationLimits: LimitsParam;
651
651
  }[]) => Promise<void>;
652
+ /**
653
+ * Creates a group constraint between selected instances within an assembly.
654
+ * @param id id of the root assembly or an assembly template to create constraints on
655
+ * @param instanceIds ids of instances to be grouped
656
+ * @param name name of the constraint
657
+ * @example // tbd
658
+ * @return id of the group constraint
659
+ */
660
+ createGroupConstraint: (id: VID, instanceIds: VID[], name: string) => Promise<ObjectID | null>;
661
+ /**
662
+ * Updates multiple group constraints.
663
+ * @param constraints array of constraint parameter objects. See following descriptions.
664
+ * @param constrId id of the constraint to update
665
+ * @param instanceIds ids of instances to be grouped
666
+ * @example // tbd
667
+ */
668
+ updateGroupConstraints: (...constraints: {
669
+ constrId: VID;
670
+ instanceIds: VID[];
671
+ }[]) => Promise<void>;
672
+ /**
673
+ * Makes copies of a selected instance and creates a linear pattern constraint between them.
674
+ * @param id id of the root assembly or an assembly template to create constraints on
675
+ * @param instanceId id of the instance to be copied
676
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
677
+ * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
678
+ * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
679
+ * @param name name of the constraint
680
+ * @param mate2 [optional] contains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
681
+ * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
682
+ * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
683
+ * @example // tbd
684
+ * @return id of the linear pattern constraint
685
+ */
686
+ createLinearPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, firstDirInstanceCount: number | string, firstDirDistance: number | string, name: string, mate2?: MateParam, secondDirInstanceCount?: number | string, secondDirDistance?: number | string) => Promise<ObjectID | null>;
687
+ /**
688
+ * Updates multiple linear pattern constraints.
689
+ * @param constraints array of constraint parameter objects. See following descriptions.
690
+ * @param constrId id of the constraint to update
691
+ * @param instanceId id of the instance to be copied
692
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
693
+ * @param firstDirInstanceCount number of copies over the first direction (set by z-axis of mate1)
694
+ * @param firstDirDistance distance between copies over the first direction (set by z-axis of mate1)
695
+ * @param mate2 [optional] contains the mate path ids to its 2nd part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
696
+ * @param secondDirInstanceCount [optional] number of copies over the second direction (set by z-axis of mate2)
697
+ * @param secondDirDistance [optional] distance between copies over the second direction (set by z-axis of mate2)
698
+ * @example // tbd
699
+ */
700
+ updateLinearPatternConstraints: (...constraints: {
701
+ constrId: VID;
702
+ instanceId: VID;
703
+ mate1: MateParam;
704
+ firstDirInstanceCount: number | string;
705
+ firstDirDistance: number | string;
706
+ mate2?: MateParam;
707
+ secondDirInstanceCount?: number | string;
708
+ secondDirDistance?: number | string;
709
+ }[]) => Promise<void>;
710
+ /**
711
+ * Makes copies of a selected instance and creates a circular pattern constraint between them.
712
+ * @param id id of the root assembly or an assembly template to create constraints on
713
+ * @param instanceId id of the instance to be copied
714
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
715
+ * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
716
+ * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
717
+ * @param offset offset between copies (set by z-axis of mate2)
718
+ * @param name name of the constraint
719
+ * @example // tbd
720
+ * @return id of the circular pattern constraint
721
+ */
722
+ createCircularPatternConstraint: (id: VID, instanceId: VID, mate1: MateParam, instanceCount: number | string, angle: number | string, offset: number | string, name: string) => Promise<ObjectID | null>;
723
+ /**
724
+ * Updates multiple circular pattern constraints.
725
+ * @param constraints array of constraint parameter objects. See following descriptions.
726
+ * @param constrId id of the constraint to update
727
+ * @param instanceId id of the instance to be copied
728
+ * @param mate1 contains the mate path ids to its part and its work coordinate system id, and also the flip (0-5) and reoriented (0-3) states; should belong to the selected instance
729
+ * @param instanceCount total number of copies (clockwise around the axis set by z-axis of mate1)
730
+ * @param angle angle between copies (clockwise around the axis set by z-axis of mate1)
731
+ * @param offset offset between copies (set by z-axis of mate2)
732
+ * @example // tbd
733
+ */
734
+ updateCircularPatternConstraints: (...constraints: {
735
+ constrId: VID;
736
+ instanceId: VID;
737
+ mate1: MateParam;
738
+ instanceCount: number | string;
739
+ angle: number | string;
740
+ offset: number | string;
741
+ }[]) => Promise<void>;
652
742
  /**
653
743
  * Updates limited value specified (with 'paramName') of multiple constraints
654
744
  * @param constrValues array of constraint value objects. See following parameter description for that.
@@ -1130,11 +1220,20 @@ export declare type ApiHistory = {
1130
1220
  * Returns the sketch region with the given sketchRegionName from the given instance or part id.
1131
1221
  * If sketchRegionName is not set, all sketch regions of the reference will be returned.
1132
1222
  * @param id id of the instance or part to look for the sketch region
1133
- * @param wcsName name of the sketch region to look for
1223
+ * @param sketchRegionName name of the sketch region to look for
1134
1224
  * @example // tbd
1135
1225
  * @return array containing ids of the sketch regions
1136
1226
  */
1137
1227
  getSketchRegion: (id: VID, sketchRegionName?: string) => IDs;
1228
+ /**
1229
+ * Returns the sketch with the given sketchName from the given instance or part id.
1230
+ * If sketchName is not set, all sketches of the reference will be returned.
1231
+ * @param id id of the instance or part to look for the sketch
1232
+ * @param sketchName name of the sketch to look for
1233
+ * @example // tbd
1234
+ * @return array containing ids of the sketches
1235
+ */
1236
+ getSketch: (id: VID, sketchName?: string) => IDs;
1138
1237
  /**
1139
1238
  * Returns the work geometry of given type with given name from the given instance or part id.
1140
1239
  * If the name of the work geometry is empty, all found work geometry of given type is returned
@@ -1217,6 +1316,30 @@ export declare type ApiHistory = {
1217
1316
  * @return found cylindrical constraint as object.
1218
1317
  */
1219
1318
  getCylindricalConstraint: (id: VID, constrName: string) => Promise<CylindricalConstraintType>;
1319
+ /**
1320
+ * Returns the group constraint of given instance or assembly with specified name.
1321
+ * @param id id of the instance or assembly to look for the constraint
1322
+ * @param constrName name of the constraint to look for
1323
+ * @example // tbd
1324
+ * @return found group constraint as object.
1325
+ */
1326
+ getGroupConstraint: (id: VID, constrName: string) => Promise<GroupConstraintType>;
1327
+ /**
1328
+ * Returns the linear pattern constraint of given instance or assembly with specified name.
1329
+ * @param id id of the instance or assembly to look for the constraint
1330
+ * @param constrName name of the constraint to look for
1331
+ * @example // tbd
1332
+ * @return found linear pattern constraint as object.
1333
+ */
1334
+ getLinearPatternConstraint: (id: VID, constrName: string) => Promise<LinearPatternConstraintType>;
1335
+ /**
1336
+ * Returns the circular pattern constraint of given instance or assembly with specified name.
1337
+ * @param id id of the instance or assembly to look for the constraint
1338
+ * @param constrName name of the constraint to look for
1339
+ * @example // tbd
1340
+ * @return found circular pattern constraint as object.
1341
+ */
1342
+ getCircularPatternConstraint: (id: VID, constrName: string) => Promise<CircularPatternConstraintType>;
1220
1343
  /**
1221
1344
  * Returns the id of the feature / operation with name = featureName. The feature can then
1222
1345
  * be used for further operations, like boolean, transformations and so on.
@@ -1436,6 +1559,32 @@ export declare type ApiHistory = {
1436
1559
  * @return id of the slice by sheet operation
1437
1560
  */
1438
1561
  sliceBySheet: (partId: VID, operationToSlice: VID, operationOfSheet: VID, sideFlag: boolean) => ID;
1562
+ /**
1563
+ * Creates a twist operation
1564
+ * @param partId Id of the part to create the twist in.
1565
+ * @param sketchOrRegionIds Id of the sketch to extrude or multiple ids of sketch regions
1566
+ * @param type Type of twist (up, down, symmetric, custom)
1567
+ * @param limit1 Start of twist (0 = start at sketch, only for type custom necessary)
1568
+ * @param limit2 End of twist, which is actually the height
1569
+ * @param direction Direction of twist (only for type custom necessary)
1570
+ * @param twistAngle Twist angle of the sketch along height of twist
1571
+ * @param twistCenter Point which together with direction defines the twist axis (only for type custom necessary).
1572
+ * The actual center/start of the twist is where the defined twist axis intersects the sketch plane. For other types than
1573
+ * custom, the center will be the bary center of the selected region.
1574
+ * @param capEnds If true, ends will be capped, else a sheet will be created
1575
+ * @return id of the twist operation
1576
+ */
1577
+ twist: (param: {
1578
+ partId: VID;
1579
+ sketchOrRegionIds: VID | VIDs;
1580
+ type: ExtrusionType;
1581
+ limit1: number | string;
1582
+ limit2: number | string;
1583
+ direction?: Vec<number | string>;
1584
+ twistAngle: number | string;
1585
+ twistCenter?: Vec<number | string>;
1586
+ capEnds: 0 | 1;
1587
+ }) => ID;
1439
1588
  };
1440
1589
  export declare class History {
1441
1590
  drawingId: DrawingID | null;
@@ -1590,6 +1739,44 @@ export declare type CylindricalConstraintType = {
1590
1739
  /** min and max limit for the rotation around z-Axis */
1591
1740
  zRotationLimits: LimitsParam;
1592
1741
  };
1742
+ export declare type GroupConstraintType = {
1743
+ /** id of the constraint */
1744
+ constrId: VID;
1745
+ /** ids of instances to be grouped */
1746
+ instanceIds: VID[];
1747
+ };
1748
+ export declare type LinearPatternConstraintType = {
1749
+ /** id of the constraint */
1750
+ constrId: VID;
1751
+ /** id of the instance to be copied */
1752
+ instanceId: VID;
1753
+ /** first mate constraint (z-axis sets the first direction) */
1754
+ mate1: MateParam;
1755
+ /** number of copies over the first direction (set by z-axis of mate1) */
1756
+ firstDirInstanceCount: number | string;
1757
+ /** distance between copies over the first direction (set by z-axis of mate1) */
1758
+ firstDirDistance: number | string;
1759
+ /** second mate constraint (z-axis sets the second direction) */
1760
+ mate2: MateParam;
1761
+ /** number of copies over the second direction (set by z-axis of mate2) */
1762
+ secondDirInstanceCount: number | string;
1763
+ /** number of copies over the second direction (set by z-axis of mate2) */
1764
+ secondDirDistance: number | string;
1765
+ };
1766
+ export declare type CircularPatternConstraintType = {
1767
+ /** id of the constraint */
1768
+ constrId: VID;
1769
+ /** id of the instance to be copied */
1770
+ instanceId: VID;
1771
+ /** first mate constraint (z-axis sets the rotation axis) */
1772
+ mate1: MateParam;
1773
+ /** total number of copies (clockwise around the axis set by z-axis of mate1) */
1774
+ instanceCount: number | string;
1775
+ /** angle between copies (clockwise around the axis set by z-axis of mate1) */
1776
+ angle: number | string;
1777
+ /** offset between copies (set by z-axis of mate2) */
1778
+ offset: number | string;
1779
+ };
1593
1780
  /**
1594
1781
  * Information about constraint.
1595
1782
  * [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/headless",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "A non-manifold CAD workflow for the web",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",
@@ -32,7 +32,7 @@
32
32
  "three-stdlib": ">=2.11.0"
33
33
  },
34
34
  "dependencies": {
35
- "@buerli.io/classcad": "0.12.0",
35
+ "@buerli.io/classcad": "0.13.0",
36
36
  "flat-promise": "^1.0.3"
37
37
  }
38
38
  }