@buerli.io/headless 0.0.33 → 0.0.35-beta.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/build/cjs/history.js +814 -0
- package/build/cjs/index.js +31 -0
- package/build/cjs/solid.js +352 -0
- package/build/{history.js → esm/history.js} +47 -14
- package/build/{index.js → esm/index.js} +0 -0
- package/build/{solid.js → esm/solid.js} +7 -3
- package/build/{history.d.ts → types/history.d.ts} +31 -4
- package/build/{index.d.ts → types/index.d.ts} +2 -1
- package/build/{solid.d.ts → types/solid.d.ts} +0 -0
- package/package.json +10 -8
|
@@ -0,0 +1,814 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
/* eslint-disable max-lines */
|
|
23
|
+
const classcad_1 = require("@buerli.io/classcad");
|
|
24
|
+
const core_1 = require("@buerli.io/core");
|
|
25
|
+
const three_1 = require("three");
|
|
26
|
+
const BufferGeometryUtils_ = __importStar(require("three/examples/jsm/utils/BufferGeometryUtils"));
|
|
27
|
+
const featureAPI = classcad_1.ccAPI.feature;
|
|
28
|
+
let BufferGeometryUtils = BufferGeometryUtils_;
|
|
29
|
+
if (BufferGeometryUtils.BufferGeometryUtils) {
|
|
30
|
+
BufferGeometryUtils = BufferGeometryUtils.BufferGeometryUtils;
|
|
31
|
+
}
|
|
32
|
+
// Qeued execute, returns the first result and expects it to be an ObjectID
|
|
33
|
+
const exec = (instance, drawing, namespace, fn, stream, ...args) => {
|
|
34
|
+
return (instance.queue = instance.queue.then(() => Promise.all(args).then(resolvedArgs => {
|
|
35
|
+
return classcad_1.ccAPI.base.callSafeAPI(drawing, namespace, fn, resolvedArgs, stream).then(res => {
|
|
36
|
+
return (res && res.results[0].result);
|
|
37
|
+
});
|
|
38
|
+
})));
|
|
39
|
+
};
|
|
40
|
+
const toCCVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
|
|
41
|
+
const toArray = (v) => (Array.isArray(v) ? v : v.toArray());
|
|
42
|
+
const toEuler = (v) => toArray(v);
|
|
43
|
+
const makeVec = (v) => toCCVec(toArray(v));
|
|
44
|
+
const getBoxMember = (drawingId, featureId, member) => {
|
|
45
|
+
const cDrawing = core_1.getDrawing(drawingId);
|
|
46
|
+
const members = cDrawing.structure.tree[featureId].members;
|
|
47
|
+
if (members) {
|
|
48
|
+
switch (member) {
|
|
49
|
+
case 'width':
|
|
50
|
+
return members.width.value === undefined ? 10 : Number(members.width.value);
|
|
51
|
+
case 'length':
|
|
52
|
+
return members.length.value === undefined ? 10 : Number(members.length.value);
|
|
53
|
+
case 'height':
|
|
54
|
+
return members.height.value === undefined ? 10 : Number(members.height.value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const getDataType = (value) => {
|
|
59
|
+
switch (typeof value) {
|
|
60
|
+
case 'number':
|
|
61
|
+
return classcad_1.DataType.REAL;
|
|
62
|
+
case 'object':
|
|
63
|
+
return classcad_1.DataType.POINT;
|
|
64
|
+
case 'string':
|
|
65
|
+
return classcad_1.DataType.STRING;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const getBoolType = (type) => {
|
|
69
|
+
switch (type) {
|
|
70
|
+
case 'Union':
|
|
71
|
+
return classcad_1.BooleanOperationType.UNION;
|
|
72
|
+
case 'Subtraction':
|
|
73
|
+
return classcad_1.BooleanOperationType.SUBTRACTION;
|
|
74
|
+
case 'Intersection':
|
|
75
|
+
return classcad_1.BooleanOperationType.INTERSECTION;
|
|
76
|
+
case undefined:
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const getChamferType = (type) => {
|
|
81
|
+
switch (type) {
|
|
82
|
+
case 'Equal_Distance':
|
|
83
|
+
return classcad_1.ChamferType.EQUAL_DISTANCE;
|
|
84
|
+
case 'Two_Distances':
|
|
85
|
+
return classcad_1.ChamferType.TWO_DISTANCES;
|
|
86
|
+
case 'Distance_And_Angle':
|
|
87
|
+
return classcad_1.ChamferType.DISTANCE_AND_ANGLE;
|
|
88
|
+
case undefined:
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const getWCSType = (type) => {
|
|
93
|
+
switch (type) {
|
|
94
|
+
case 'XYAxisOrigin':
|
|
95
|
+
return classcad_1.WorkCoordSystemType.WCS_XYAXISORIGIN;
|
|
96
|
+
case 'Custom':
|
|
97
|
+
return classcad_1.WorkCoordSystemType.WCS_CUSTOM;
|
|
98
|
+
case undefined:
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const getWAType = (type) => {
|
|
103
|
+
switch (type) {
|
|
104
|
+
case 'Custom':
|
|
105
|
+
return classcad_1.WorkAxisType.WA_USERDEFINED;
|
|
106
|
+
case 'WorkPoints':
|
|
107
|
+
return classcad_1.WorkAxisType.WA_WORKPOINTS;
|
|
108
|
+
case 'PointAndDirection':
|
|
109
|
+
return classcad_1.WorkAxisType.WA_POINTDIRECTION;
|
|
110
|
+
case 'SketchLine':
|
|
111
|
+
return classcad_1.WorkAxisType.WA_SKETCHLINE;
|
|
112
|
+
case 'Curve':
|
|
113
|
+
return classcad_1.WorkAxisType.WA_CURVE;
|
|
114
|
+
case '2Points':
|
|
115
|
+
return classcad_1.WorkAxisType.WA_2POINTS;
|
|
116
|
+
case '2Planes':
|
|
117
|
+
return classcad_1.WorkAxisType.WA_2PLANES;
|
|
118
|
+
case undefined:
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const getWPType = (type) => {
|
|
123
|
+
switch (type) {
|
|
124
|
+
case 'Custom':
|
|
125
|
+
return classcad_1.WorkPlaneType.WP_USERDEFINED;
|
|
126
|
+
case 'Plane':
|
|
127
|
+
return classcad_1.WorkPlaneType.WP_PLANE;
|
|
128
|
+
case 'EdgeAndPoint':
|
|
129
|
+
return classcad_1.WorkPlaneType.WP_EDGEPOINT;
|
|
130
|
+
case '3Points':
|
|
131
|
+
return classcad_1.WorkPlaneType.WP_3POINTS;
|
|
132
|
+
case 'PointAndNormal':
|
|
133
|
+
return classcad_1.WorkPlaneType.WP_POINTNORMAL;
|
|
134
|
+
case 'PointAndFace':
|
|
135
|
+
return classcad_1.WorkPlaneType.WP_POINTFACE;
|
|
136
|
+
case 'LinePlaneAndAngle':
|
|
137
|
+
return classcad_1.WorkPlaneType.WP_LINEPLANEANGLE;
|
|
138
|
+
case undefined:
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const getWPTType = (type) => {
|
|
143
|
+
switch (type) {
|
|
144
|
+
case 'Custom':
|
|
145
|
+
return classcad_1.WorkPointType.WPT_USERDEFINED;
|
|
146
|
+
case 'Point':
|
|
147
|
+
return classcad_1.WorkPointType.WPT_BREPVERTEX;
|
|
148
|
+
case 'MidPointLine':
|
|
149
|
+
return classcad_1.WorkPointType.WPT_EDGEMIDPOINT;
|
|
150
|
+
case 'Center':
|
|
151
|
+
return classcad_1.WorkPointType.WPT_CENTER;
|
|
152
|
+
case 'BaryCenter':
|
|
153
|
+
return classcad_1.WorkPointType.WPT_BARYCENTER;
|
|
154
|
+
case 'Intersection':
|
|
155
|
+
return classcad_1.WorkPointType.WPT_INTERSECTION;
|
|
156
|
+
case 'InnerCircle':
|
|
157
|
+
return classcad_1.WorkPointType.WPT_INNERCIRCLE;
|
|
158
|
+
case 'MidPointOf2Points':
|
|
159
|
+
return classcad_1.WorkPointType.WPT_2POINTS;
|
|
160
|
+
case undefined:
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray) => {
|
|
165
|
+
let cDrawing = core_1.getDrawing(drawingId);
|
|
166
|
+
const tree = cDrawing.structure.tree;
|
|
167
|
+
if (object.link || object.solids) {
|
|
168
|
+
// Part
|
|
169
|
+
const solids = object.link ? tree[object.link].solids : object.solids;
|
|
170
|
+
if (solids != undefined) {
|
|
171
|
+
let geometries = [];
|
|
172
|
+
for (const solid of solids) {
|
|
173
|
+
let cachedSolid = cDrawing.geometry.cache[solid];
|
|
174
|
+
if (cachedSolid) {
|
|
175
|
+
// if solid already cached, take it from cache
|
|
176
|
+
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// else get visualisation from classcad
|
|
180
|
+
await classcad_1.ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [solid]);
|
|
181
|
+
cDrawing = core_1.getDrawing(drawingId); // get current drawing state after request
|
|
182
|
+
cachedSolid = cDrawing.geometry.cache[solid];
|
|
183
|
+
if (cachedSolid) {
|
|
184
|
+
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
console.warn(`There is no cached entry for ${solid}!`, cDrawing.geometry.cache);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (geometries.length > 0) {
|
|
192
|
+
const transformation = cDrawing.api.structure.calculateGlobalTransformation(object.id);
|
|
193
|
+
const bufferGeom = BufferGeometryUtils.mergeBufferGeometries(geometries);
|
|
194
|
+
bufferGeom.applyMatrix4(transformation);
|
|
195
|
+
bufferGeomArray.push(bufferGeom);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else if (object.children) {
|
|
200
|
+
// Assembly
|
|
201
|
+
for (const child of object.children) {
|
|
202
|
+
if (tree[child].class === classcad_1.CCClasses.CCProductReference || tree[child].class === classcad_1.CCClasses.CCProductReferenceET) {
|
|
203
|
+
await createRecursiveBufferGeometry(tree[child], drawingId, bufferGeomArray);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const createRecursiveScene = async (object, drawingId, root, options) => {
|
|
209
|
+
let cDrawing = core_1.getDrawing(drawingId);
|
|
210
|
+
const tree = cDrawing.structure.tree;
|
|
211
|
+
if (object.link || object.solids) {
|
|
212
|
+
// Part
|
|
213
|
+
const solids = object.link ? tree[object.link].solids : object.solids;
|
|
214
|
+
if (solids != undefined) {
|
|
215
|
+
let meshes = [];
|
|
216
|
+
for (const solid of solids) {
|
|
217
|
+
let cachedSolid = cDrawing.geometry.cache[solid];
|
|
218
|
+
if (!cachedSolid) {
|
|
219
|
+
// else get visualisation from classcad
|
|
220
|
+
await classcad_1.ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [solid]);
|
|
221
|
+
cDrawing = core_1.getDrawing(drawingId); // get current drawing state after request
|
|
222
|
+
cachedSolid = cDrawing.geometry.cache[solid];
|
|
223
|
+
}
|
|
224
|
+
if (cachedSolid)
|
|
225
|
+
meshes = [...meshes, ...cachedSolid.meshes.map(m => m)];
|
|
226
|
+
}
|
|
227
|
+
if (meshes.length > 0) {
|
|
228
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerFace) {
|
|
229
|
+
const part = new three_1.Group();
|
|
230
|
+
part.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
231
|
+
part.matrixAutoUpdate = false;
|
|
232
|
+
part.userData = { id: object.id };
|
|
233
|
+
part.name = object.name;
|
|
234
|
+
for (const mesh of meshes) {
|
|
235
|
+
part.add(new three_1.Mesh(mesh.geometry, new three_1.MeshStandardMaterial({ color: mesh.color, transparent: mesh.opacity < 1, opacity: mesh.opacity })));
|
|
236
|
+
}
|
|
237
|
+
root.add(part);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const mesh = new three_1.Mesh();
|
|
241
|
+
mesh.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
242
|
+
mesh.matrixAutoUpdate = false;
|
|
243
|
+
mesh.userData = { id: object.id };
|
|
244
|
+
mesh.name = object.name;
|
|
245
|
+
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(meshes.map(m => m.geometry));
|
|
246
|
+
mesh.material = new three_1.MeshStandardMaterial();
|
|
247
|
+
root.add(mesh);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else if (object.children) {
|
|
253
|
+
// Assembly
|
|
254
|
+
const assembly = new three_1.Group();
|
|
255
|
+
assembly.matrix = core_1.MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
256
|
+
assembly.matrixAutoUpdate = false;
|
|
257
|
+
assembly.userData = { id: object.id };
|
|
258
|
+
assembly.name = object.name;
|
|
259
|
+
root.add(assembly);
|
|
260
|
+
for (const child of object.children) {
|
|
261
|
+
if (tree[child].class === classcad_1.CCClasses.CCProductReference || tree[child].class === classcad_1.CCClasses.CCProductReferenceET) {
|
|
262
|
+
await createRecursiveScene(tree[child], drawingId, assembly, options);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
class CAD {
|
|
268
|
+
constructor(url) {
|
|
269
|
+
this.drawingId = null;
|
|
270
|
+
this.queue = Promise.resolve(0);
|
|
271
|
+
this.queue = Promise.resolve(0);
|
|
272
|
+
core_1.init({ url });
|
|
273
|
+
}
|
|
274
|
+
resolve(callback, ...args) {
|
|
275
|
+
// eslint-disable-next-line promise/no-callback-in-promise
|
|
276
|
+
return (this.queue = this.queue.then(() => Promise.all(args).then(callback)));
|
|
277
|
+
}
|
|
278
|
+
init(callback) {
|
|
279
|
+
const promise = new Promise(async (resolve, reject) => {
|
|
280
|
+
const drawingId = await classcad_1.ccAPI.base.createCCDrawing();
|
|
281
|
+
if (!drawingId)
|
|
282
|
+
throw new Error('Drawing could not be created');
|
|
283
|
+
this.drawingId = drawingId;
|
|
284
|
+
const publicApi = {
|
|
285
|
+
addNode: (productId, ownerId, transformation, name) => {
|
|
286
|
+
return this.resolve(async ([rProductId, rOwnerId]) => {
|
|
287
|
+
return classcad_1.ccAPI.assemblyBuilder.addNode(drawingId, rProductId, rOwnerId, transformation, name);
|
|
288
|
+
}, productId, ownerId);
|
|
289
|
+
},
|
|
290
|
+
addNodes: (...nodes) => {
|
|
291
|
+
return this.resolve(async ([]) => {
|
|
292
|
+
const nodesToAdd = [];
|
|
293
|
+
nodes.forEach(node => {
|
|
294
|
+
nodesToAdd.push([node.productId, node.ownerId, node.transformation, node.name]);
|
|
295
|
+
});
|
|
296
|
+
return classcad_1.ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
boolean: (partId, type, entities) => {
|
|
300
|
+
return this.resolve(async ([rPartId, ...rEntities]) => {
|
|
301
|
+
const cDrawing = await core_1.getDrawing(drawingId);
|
|
302
|
+
const entArray = [];
|
|
303
|
+
for (const rEntity of rEntities) {
|
|
304
|
+
const entity = cDrawing.structure.tree[rEntity].children;
|
|
305
|
+
if (entity != undefined) {
|
|
306
|
+
entArray.push(entity[0]);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const boolType = getBoolType(type);
|
|
310
|
+
if (boolType != undefined) {
|
|
311
|
+
const boolId = await featureAPI.createBooleanOperation(drawingId, rPartId, {
|
|
312
|
+
type: boolType,
|
|
313
|
+
entities: entArray,
|
|
314
|
+
});
|
|
315
|
+
if (boolId != null) {
|
|
316
|
+
await featureAPI.updateBooleanOperation(drawingId, boolId, boolType, entArray);
|
|
317
|
+
return boolId;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return null; // Todo: Exceptions?
|
|
321
|
+
}, partId, ...entities);
|
|
322
|
+
},
|
|
323
|
+
box: (partId, references, width, length, height) => {
|
|
324
|
+
return this.resolve(async ([rPartId]) => {
|
|
325
|
+
const boxId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCBox, 'Box');
|
|
326
|
+
if (boxId != null) {
|
|
327
|
+
const widthParam = { value: width, isExpr: typeof width === 'string' };
|
|
328
|
+
const lengthParam = { value: length, isExpr: typeof length === 'string' };
|
|
329
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
330
|
+
await featureAPI.updateBox(drawingId, boxId, references, widthParam, lengthParam, heightParam);
|
|
331
|
+
return boxId;
|
|
332
|
+
}
|
|
333
|
+
return null;
|
|
334
|
+
}, partId);
|
|
335
|
+
},
|
|
336
|
+
cylinder: (partId, references, diameter, height) => {
|
|
337
|
+
return this.resolve(async ([rPartId]) => {
|
|
338
|
+
const cylId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCCylinder, 'Cylinder');
|
|
339
|
+
if (cylId != null) {
|
|
340
|
+
const diameterParam = { value: diameter, isExpr: typeof length === 'string' };
|
|
341
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
342
|
+
await featureAPI.updateCylinder(drawingId, cylId, references, diameterParam, heightParam);
|
|
343
|
+
return cylId;
|
|
344
|
+
}
|
|
345
|
+
return null;
|
|
346
|
+
}, partId);
|
|
347
|
+
},
|
|
348
|
+
chamfer: (partId, type, references, dist1, dist2, angle) => {
|
|
349
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
350
|
+
const dist1Param = { value: dist1, isExpr: typeof dist1 === 'string' };
|
|
351
|
+
const dist2Param = { value: dist2, isExpr: typeof dist2 === 'string' };
|
|
352
|
+
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
353
|
+
const chamferId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCChamfer, 'Chamfer');
|
|
354
|
+
const chamferType = getChamferType(type);
|
|
355
|
+
if (chamferType != undefined && chamferId != null) {
|
|
356
|
+
await featureAPI.updateChamfer(drawingId, chamferId, chamferType, rReferences, dist1Param, dist2Param, angleParam);
|
|
357
|
+
return chamferId;
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}, partId, ...references);
|
|
361
|
+
},
|
|
362
|
+
cone: (partId, references, bDiameter, tDiameter, height) => {
|
|
363
|
+
return this.resolve(async ([rPartId]) => {
|
|
364
|
+
const coneId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCCone, 'Cone');
|
|
365
|
+
if (coneId != null) {
|
|
366
|
+
const bDiamParam = { value: bDiameter, isExpr: typeof bDiameter === 'string' };
|
|
367
|
+
const tDiamParam = { value: tDiameter, isExpr: typeof tDiameter === 'string' };
|
|
368
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
369
|
+
await featureAPI.updateCone(drawingId, coneId, references, bDiamParam, tDiamParam, heightParam);
|
|
370
|
+
return coneId;
|
|
371
|
+
}
|
|
372
|
+
return null;
|
|
373
|
+
}, partId);
|
|
374
|
+
},
|
|
375
|
+
createFastenedConstraint: (asmId, mate1, mate2, xOffset, yOffset, zOffset, name) => {
|
|
376
|
+
return this.resolve(async ([rAsmId]) => {
|
|
377
|
+
const constraintId = await classcad_1.ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedConstraint, name);
|
|
378
|
+
if (constraintId != null) {
|
|
379
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
380
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
381
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
382
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, constraintId, [mate1.matePath, mate1.wcsId, mate1.flip, mate1.reoriented], [mate2.matePath, mate2.wcsId, mate2.flip, mate2.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
383
|
+
return constraintId;
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}, asmId);
|
|
387
|
+
},
|
|
388
|
+
updateFastenedConstraint: (constrId, mate1, mate2, xOffset, yOffset, zOffset) => {
|
|
389
|
+
return this.resolve(async ([rConstrId]) => {
|
|
390
|
+
const xOffsetParam = { value: xOffset, isExpr: false };
|
|
391
|
+
const yOffsetParam = { value: yOffset, isExpr: false };
|
|
392
|
+
const zOffsetParam = { value: zOffset, isExpr: false };
|
|
393
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, rConstrId, [mate1.matePath, mate1.wcsId, mate1.flip, mate1.reoriented], [mate2.matePath, mate2.wcsId, mate2.flip, mate2.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
394
|
+
}, constrId);
|
|
395
|
+
},
|
|
396
|
+
updateFastenedConstraints: (...constraints) => {
|
|
397
|
+
return this.resolve(async ([]) => {
|
|
398
|
+
const constrToAdd = [];
|
|
399
|
+
constraints.forEach(constr => {
|
|
400
|
+
const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
|
|
401
|
+
const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
|
|
402
|
+
const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
|
|
403
|
+
constrToAdd.push([constr.constrId,
|
|
404
|
+
[constr.mate1.matePath, constr.mate1.wcsId, constr.mate1.flip, constr.mate1.reoriented],
|
|
405
|
+
[constr.mate2.matePath, constr.mate2.wcsId, constr.mate2.flip, constr.mate2.reoriented],
|
|
406
|
+
xOffsetParam, yOffsetParam, zOffsetParam]);
|
|
407
|
+
});
|
|
408
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedConstraints(drawingId, constrToAdd);
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
createFastenedOriginConstraint: (asmId, mate1, xOffset, yOffset, zOffset, name) => {
|
|
412
|
+
return this.resolve(async ([rAsmId]) => {
|
|
413
|
+
const constraintId = await classcad_1.ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, classcad_1.CCClasses.CCFastenedOriginConstraint, name);
|
|
414
|
+
if (constraintId != null) {
|
|
415
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
416
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
417
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
418
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, [mate1.matePath, mate1.wcsId, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
419
|
+
return constraintId;
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
}, asmId);
|
|
423
|
+
},
|
|
424
|
+
updateFastenedOriginConstraint: (constrId, mate1, xOffset, yOffset, zOffset) => {
|
|
425
|
+
return this.resolve(async ([rConstrId]) => {
|
|
426
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
427
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
428
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
429
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, [mate1.matePath, mate1.wcsId, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
430
|
+
}, constrId);
|
|
431
|
+
},
|
|
432
|
+
updateFastenedOriginConstraints: (...constraints) => {
|
|
433
|
+
return this.resolve(async ([]) => {
|
|
434
|
+
const constrToAdd = [];
|
|
435
|
+
constraints.forEach(constr => {
|
|
436
|
+
const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
|
|
437
|
+
const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
|
|
438
|
+
const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
|
|
439
|
+
constrToAdd.push([constr.constrId,
|
|
440
|
+
[constr.mate1.matePath, constr.mate1.wcsId, constr.mate1.flip, constr.mate1.reoriented],
|
|
441
|
+
xOffsetParam, yOffsetParam, zOffsetParam]);
|
|
442
|
+
});
|
|
443
|
+
await classcad_1.ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId, constrToAdd);
|
|
444
|
+
});
|
|
445
|
+
},
|
|
446
|
+
createBufferGeometry: async (objectId) => {
|
|
447
|
+
await this.queue;
|
|
448
|
+
this.queue = Promise.resolve(0);
|
|
449
|
+
const rObjectId = await objectId;
|
|
450
|
+
const cDrawing = core_1.getDrawing(drawingId);
|
|
451
|
+
const structureTree = cDrawing.structure.tree;
|
|
452
|
+
const bufferGeomArray = [];
|
|
453
|
+
if (rObjectId != null) {
|
|
454
|
+
const rootObj = structureTree[rObjectId];
|
|
455
|
+
await createRecursiveBufferGeometry(rootObj, drawingId, bufferGeomArray);
|
|
456
|
+
if (bufferGeomArray.length > 0) {
|
|
457
|
+
return bufferGeomArray;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return undefined;
|
|
461
|
+
},
|
|
462
|
+
createScene: async (objectId, options) => {
|
|
463
|
+
await this.queue;
|
|
464
|
+
this.queue = Promise.resolve(0);
|
|
465
|
+
const rObjectId = await objectId;
|
|
466
|
+
const cDrawing = core_1.getDrawing(drawingId);
|
|
467
|
+
const structureTree = cDrawing.structure.tree;
|
|
468
|
+
const scene = new three_1.Scene();
|
|
469
|
+
if (rObjectId != null) {
|
|
470
|
+
const rootObj = structureTree[rObjectId];
|
|
471
|
+
await createRecursiveScene(rootObj, drawingId, scene, options);
|
|
472
|
+
}
|
|
473
|
+
return scene;
|
|
474
|
+
},
|
|
475
|
+
createExpressions: (partId, ...members) => {
|
|
476
|
+
return this.resolve(async (resolvedArgs) => {
|
|
477
|
+
const membersToAdd = [];
|
|
478
|
+
members.forEach(mem => {
|
|
479
|
+
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
|
|
480
|
+
const dataType = getDataType(mem.value);
|
|
481
|
+
const featureAPIParam = {
|
|
482
|
+
value: mem.value,
|
|
483
|
+
isExpr: isExpr,
|
|
484
|
+
};
|
|
485
|
+
membersToAdd.push([mem.name, featureAPIParam, dataType]);
|
|
486
|
+
});
|
|
487
|
+
const success = featureAPI.updateExpressionSet(drawingId, resolvedArgs[0], membersToAdd, [], []);
|
|
488
|
+
return success;
|
|
489
|
+
}, partId);
|
|
490
|
+
},
|
|
491
|
+
createAssemblyAsTemplate: (name) => {
|
|
492
|
+
return this.resolve(async ([]) => {
|
|
493
|
+
return await classcad_1.ccAPI.assemblyBuilder.createAssemblyAsTemplate(drawingId, name);
|
|
494
|
+
});
|
|
495
|
+
},
|
|
496
|
+
createRootAssembly: (name) => {
|
|
497
|
+
return this.resolve(async ([]) => {
|
|
498
|
+
return await classcad_1.ccAPI.assemblyBuilder.createRootAssembly(drawingId, name);
|
|
499
|
+
});
|
|
500
|
+
},
|
|
501
|
+
createPart: (name) => {
|
|
502
|
+
return this.resolve(async ([]) => {
|
|
503
|
+
const partName = name ? name : 'Part';
|
|
504
|
+
return await featureAPI.newPart(drawingId, partName);
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
createPartAsTemplate: (name) => {
|
|
508
|
+
return this.resolve(async ([]) => {
|
|
509
|
+
const partName = name ? name : 'Part';
|
|
510
|
+
return await classcad_1.ccAPI.assemblyBuilder.createPartAsTemplate(drawingId, partName);
|
|
511
|
+
});
|
|
512
|
+
},
|
|
513
|
+
createWorkAxis: (partId, type, references, position, direction, local, name) => {
|
|
514
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
515
|
+
const wAType = getWAType(type);
|
|
516
|
+
const wAName = name ? name : 'WorkAxis';
|
|
517
|
+
const wARefs = rReferences;
|
|
518
|
+
if (wAType != undefined) {
|
|
519
|
+
const wAId = await featureAPI.createWorkAxis(drawingId, rPartId, {
|
|
520
|
+
axisType: wAType,
|
|
521
|
+
references: wARefs,
|
|
522
|
+
name: wAName,
|
|
523
|
+
position: position,
|
|
524
|
+
direction: direction,
|
|
525
|
+
local: local,
|
|
526
|
+
});
|
|
527
|
+
if (wAId != null) {
|
|
528
|
+
const positionParam = {
|
|
529
|
+
value: position,
|
|
530
|
+
isExpr: typeof position === 'string',
|
|
531
|
+
};
|
|
532
|
+
const directionParam = {
|
|
533
|
+
value: direction,
|
|
534
|
+
isExpr: typeof direction === 'string',
|
|
535
|
+
};
|
|
536
|
+
await featureAPI.updateWorkAxis(drawingId, wAId, wAType, wARefs, positionParam, directionParam, local);
|
|
537
|
+
return wAId;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return null;
|
|
541
|
+
}, partId, references);
|
|
542
|
+
},
|
|
543
|
+
createWorkCoordSystem: (partId, type, references, coordinateSystem, offset, rotation, inverted, local, name) => {
|
|
544
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
545
|
+
const wCSType = getWCSType(type);
|
|
546
|
+
const wCSName = name ? name : 'WorkCoordSystem';
|
|
547
|
+
const wCSRefs = rReferences;
|
|
548
|
+
if (wCSType != undefined) {
|
|
549
|
+
const wCSId = await featureAPI.createWorkCoordSystem(drawingId, rPartId, {
|
|
550
|
+
coordSystemType: wCSType,
|
|
551
|
+
name: wCSName,
|
|
552
|
+
references: wCSRefs,
|
|
553
|
+
coordinateSystem,
|
|
554
|
+
offset,
|
|
555
|
+
rotation,
|
|
556
|
+
inverted,
|
|
557
|
+
local,
|
|
558
|
+
});
|
|
559
|
+
if (wCSId != null) {
|
|
560
|
+
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
561
|
+
const rotationParam = {
|
|
562
|
+
value: rotation,
|
|
563
|
+
isExpr: typeof rotation === 'string',
|
|
564
|
+
};
|
|
565
|
+
await featureAPI.updateWorkCoordSystem(drawingId, wCSId, wCSType, wCSRefs, coordinateSystem, offsetParam, rotationParam, inverted, local);
|
|
566
|
+
return wCSId;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return null;
|
|
570
|
+
}, partId, references);
|
|
571
|
+
},
|
|
572
|
+
createWorkPlane: (partId, type, references, offset, angle, position, normal, local, name) => {
|
|
573
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
574
|
+
const wPType = getWPType(type);
|
|
575
|
+
const wPName = name ? name : 'WorkPlane';
|
|
576
|
+
const wPRefs = rReferences;
|
|
577
|
+
if (wPType != undefined) {
|
|
578
|
+
const wPId = await featureAPI.createWorkPlane(drawingId, rPartId, {
|
|
579
|
+
planeType: wPType,
|
|
580
|
+
references: wPRefs,
|
|
581
|
+
offsetOrAngle: offset,
|
|
582
|
+
name: wPName,
|
|
583
|
+
position: position,
|
|
584
|
+
normal: normal,
|
|
585
|
+
local: local,
|
|
586
|
+
});
|
|
587
|
+
if (wPId != undefined) {
|
|
588
|
+
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
589
|
+
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
590
|
+
const positionParam = {
|
|
591
|
+
value: position,
|
|
592
|
+
isExpr: typeof position === 'string',
|
|
593
|
+
};
|
|
594
|
+
const normalParam = { value: normal, isExpr: typeof normal === 'string' };
|
|
595
|
+
await featureAPI.updateWorkPlane(drawingId, wPId, wPType, wPRefs, offsetParam, angleParam, positionParam, normalParam, local);
|
|
596
|
+
return wPId;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return null;
|
|
600
|
+
}, partId, references);
|
|
601
|
+
},
|
|
602
|
+
createWorkPoint: (partId, type, references, position, local, name) => {
|
|
603
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
604
|
+
const wPTType = getWPTType(type);
|
|
605
|
+
const wPTName = name ? name : 'WorkPoint';
|
|
606
|
+
const wPTRefs = rReferences;
|
|
607
|
+
if (wPTType != undefined) {
|
|
608
|
+
const wPTId = await featureAPI.createWorkPoint(drawingId, rPartId, {
|
|
609
|
+
pointType: wPTType,
|
|
610
|
+
references: wPTRefs,
|
|
611
|
+
name: wPTName,
|
|
612
|
+
position: position,
|
|
613
|
+
local: local,
|
|
614
|
+
});
|
|
615
|
+
if (wPTId != undefined) {
|
|
616
|
+
const positionParam = {
|
|
617
|
+
value: position,
|
|
618
|
+
isExpr: typeof position === 'string',
|
|
619
|
+
};
|
|
620
|
+
await featureAPI.updateWorkPoint(drawingId, wPTId, wPTType, wPTRefs, positionParam, local);
|
|
621
|
+
return wPTId;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}, partId, references);
|
|
626
|
+
},
|
|
627
|
+
fillet: (partId, references, radius) => {
|
|
628
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
629
|
+
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
630
|
+
const filletId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCConstantRadiusFillet, 'Fillet');
|
|
631
|
+
if (filletId != null) {
|
|
632
|
+
await featureAPI.updateFillet(drawingId, filletId, rReferences, radiusParam);
|
|
633
|
+
return filletId;
|
|
634
|
+
}
|
|
635
|
+
return null;
|
|
636
|
+
}, partId, ...references);
|
|
637
|
+
},
|
|
638
|
+
getAssemblyFromContainer: (asmName) => {
|
|
639
|
+
return this.resolve(async ([]) => {
|
|
640
|
+
const asmIds = classcad_1.ccUtils.assembly.getAssemblyFromContainer(drawingId, asmName);
|
|
641
|
+
if (asmIds != undefined) {
|
|
642
|
+
return Array.isArray(asmIds) ? asmIds : [asmIds];
|
|
643
|
+
}
|
|
644
|
+
return null;
|
|
645
|
+
});
|
|
646
|
+
},
|
|
647
|
+
getAssemblyNode: (refId, nodeName) => {
|
|
648
|
+
return this.resolve(async ([rRefId]) => {
|
|
649
|
+
const nodeIds = classcad_1.ccUtils.assembly.getAssemblyNode(drawingId, rRefId, nodeName);
|
|
650
|
+
if (nodeIds != undefined) {
|
|
651
|
+
return Array.isArray(nodeIds) ? nodeIds : [nodeIds];
|
|
652
|
+
}
|
|
653
|
+
return null;
|
|
654
|
+
}, refId);
|
|
655
|
+
},
|
|
656
|
+
getPartFromContainer: (partName) => {
|
|
657
|
+
return this.resolve(async ([]) => {
|
|
658
|
+
const partIds = classcad_1.ccUtils.assembly.getPartFromContainer(drawingId, partName);
|
|
659
|
+
if (partIds != undefined) {
|
|
660
|
+
return Array.isArray(partIds) ? partIds : [partIds];
|
|
661
|
+
}
|
|
662
|
+
return null;
|
|
663
|
+
});
|
|
664
|
+
},
|
|
665
|
+
getWorkCoordSystem: (refId, wcsName) => {
|
|
666
|
+
return this.resolve(async ([rRefId]) => {
|
|
667
|
+
const wcsIds = classcad_1.ccUtils.assembly.getWorkCoordSystem(drawingId, rRefId, wcsName);
|
|
668
|
+
if (wcsIds != undefined) {
|
|
669
|
+
return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
|
|
670
|
+
}
|
|
671
|
+
return null;
|
|
672
|
+
}, refId);
|
|
673
|
+
},
|
|
674
|
+
getConstraint: (refId, constrName) => {
|
|
675
|
+
return this.resolve(async ([rRefId]) => {
|
|
676
|
+
const constrIds = classcad_1.ccUtils.assembly.getConstraint(drawingId, rRefId, constrName);
|
|
677
|
+
if (constrIds != undefined) {
|
|
678
|
+
return Array.isArray(constrIds) ? constrIds : [constrIds];
|
|
679
|
+
}
|
|
680
|
+
return null;
|
|
681
|
+
}, refId);
|
|
682
|
+
},
|
|
683
|
+
getFeatureByName: (partId, featureName) => {
|
|
684
|
+
return this.resolve(async ([rProductId]) => {
|
|
685
|
+
const solid = await featureAPI.getFeatureByName(drawingId, rProductId, featureName);
|
|
686
|
+
if (solid !== null) {
|
|
687
|
+
return solid;
|
|
688
|
+
}
|
|
689
|
+
return null;
|
|
690
|
+
}, partId);
|
|
691
|
+
},
|
|
692
|
+
removeNode: (referenceId, ownerId) => {
|
|
693
|
+
return this.resolve(async ([rReferenceId, rOwnerId]) => {
|
|
694
|
+
await classcad_1.ccAPI.assemblyBuilder.removeNode(drawingId, rReferenceId, rOwnerId);
|
|
695
|
+
}, referenceId, ownerId);
|
|
696
|
+
},
|
|
697
|
+
removeNodes: (...nodes) => {
|
|
698
|
+
return this.resolve(async ([]) => {
|
|
699
|
+
const nodesToRemove = [];
|
|
700
|
+
nodes.forEach(node => {
|
|
701
|
+
nodesToRemove.push([node.referenceId, node.ownerId]);
|
|
702
|
+
});
|
|
703
|
+
return classcad_1.ccAPI.assemblyBuilder.removeNodes(drawingId, nodesToRemove);
|
|
704
|
+
});
|
|
705
|
+
},
|
|
706
|
+
importFeature: (partId, content, format, name) => {
|
|
707
|
+
return this.resolve(async ([rPartId]) => {
|
|
708
|
+
const featureName = name ? name : 'Import';
|
|
709
|
+
const importFeatureId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCImport, featureName);
|
|
710
|
+
if (importFeatureId !== null) {
|
|
711
|
+
const solids = await featureAPI.loadGeometryStreamToImportFeature(drawingId, importFeatureId, content, format);
|
|
712
|
+
if (solids !== null) {
|
|
713
|
+
return importFeatureId;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return null;
|
|
717
|
+
}, partId);
|
|
718
|
+
},
|
|
719
|
+
translate: (partId, featureIds, references, inverted, distance) => {
|
|
720
|
+
return this.resolve(async ([rPartId, rFeatureIds, rReferences]) => {
|
|
721
|
+
const translationId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCTranslation, 'Translate');
|
|
722
|
+
if (translationId !== null) {
|
|
723
|
+
const cDrawing = await core_1.getDrawing(drawingId);
|
|
724
|
+
const entArray = [];
|
|
725
|
+
for (const rFeatureId of rFeatureIds) {
|
|
726
|
+
const entity = cDrawing.structure.tree[rFeatureId].children;
|
|
727
|
+
if (entity != undefined) {
|
|
728
|
+
entArray.push(entity[0]);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
const dist = { value: distance, isExpr: typeof distance === 'string' };
|
|
732
|
+
await featureAPI.updateTransformation(drawingId, translationId, entArray, rReferences, inverted, dist);
|
|
733
|
+
return translationId;
|
|
734
|
+
}
|
|
735
|
+
return null;
|
|
736
|
+
}, partId, featureIds, references);
|
|
737
|
+
},
|
|
738
|
+
updateTranslate: (translationId, distance) => {
|
|
739
|
+
return this.resolve(async ([rTranslationId]) => {
|
|
740
|
+
const cDrawing = await core_1.getDrawing(drawingId);
|
|
741
|
+
const members = cDrawing.structure.tree[rTranslationId].members;
|
|
742
|
+
if (members !== null && members !== undefined) {
|
|
743
|
+
const entArray = members['bodiesToTransform'].members.map(m => m.value);
|
|
744
|
+
const references = members['references'].members.map(m => m.value);
|
|
745
|
+
const inverted = members['inverted'].value;
|
|
746
|
+
const dist = distance !== null ? distance : members['translationDistance'].value;
|
|
747
|
+
const distParam = { value: dist, isExpr: typeof distance === 'string' };
|
|
748
|
+
await featureAPI.openFeature(drawingId, rTranslationId);
|
|
749
|
+
await featureAPI.updateTransformation(drawingId, rTranslationId, entArray, references, inverted, distParam);
|
|
750
|
+
await featureAPI.closeFeature(drawingId, rTranslationId);
|
|
751
|
+
}
|
|
752
|
+
}, translationId);
|
|
753
|
+
},
|
|
754
|
+
save: (type) => {
|
|
755
|
+
return classcad_1.ccAPI.baseModeler.save(drawingId, type);
|
|
756
|
+
},
|
|
757
|
+
load: (content, type) => {
|
|
758
|
+
return classcad_1.ccAPI.baseModeler.load(drawingId, content, type);
|
|
759
|
+
},
|
|
760
|
+
loadProduct: (content, type) => {
|
|
761
|
+
return classcad_1.ccAPI.assemblyBuilder.loadProduct(drawingId, content, type);
|
|
762
|
+
},
|
|
763
|
+
pick: (partId, type, points) => {
|
|
764
|
+
return this.resolve(async ([rPartId]) => {
|
|
765
|
+
const refs = await featureAPI.pick(drawingId, rPartId, type, points);
|
|
766
|
+
if (refs != undefined) {
|
|
767
|
+
return Array.isArray(refs) ? refs : [refs];
|
|
768
|
+
}
|
|
769
|
+
return null;
|
|
770
|
+
}, partId);
|
|
771
|
+
},
|
|
772
|
+
setExpressions: (partId, ...members) => {
|
|
773
|
+
return this.resolve(async (resolvedArgs) => {
|
|
774
|
+
const membersToModify = [];
|
|
775
|
+
members.forEach(mem => {
|
|
776
|
+
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
|
|
777
|
+
const featureAPIParam = {
|
|
778
|
+
value: mem.value,
|
|
779
|
+
isExpr: isExpr,
|
|
780
|
+
};
|
|
781
|
+
membersToModify.push([mem.name, featureAPIParam]);
|
|
782
|
+
});
|
|
783
|
+
const success = featureAPI.updateExpressionSet(drawingId, resolvedArgs[0], [], membersToModify, []);
|
|
784
|
+
return success;
|
|
785
|
+
}, partId);
|
|
786
|
+
},
|
|
787
|
+
deleteExpressions: (partId, members) => {
|
|
788
|
+
return this.resolve(async (resolvedArgs) => {
|
|
789
|
+
const success = featureAPI.updateExpressionSet(drawingId, resolvedArgs[0], [], [], members);
|
|
790
|
+
return success;
|
|
791
|
+
}, partId);
|
|
792
|
+
},
|
|
793
|
+
sphere: (partId, references, radius) => {
|
|
794
|
+
return this.resolve(async ([rPartId]) => {
|
|
795
|
+
const sphereId = await featureAPI.createFeature(drawingId, rPartId, classcad_1.CCClasses.CCSphere, 'Sphere');
|
|
796
|
+
if (sphereId != null) {
|
|
797
|
+
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
798
|
+
await featureAPI.updateSphere(drawingId, sphereId, references, radiusParam);
|
|
799
|
+
return sphereId;
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
802
|
+
}, partId);
|
|
803
|
+
},
|
|
804
|
+
};
|
|
805
|
+
callback(publicApi);
|
|
806
|
+
resolve(drawingId);
|
|
807
|
+
});
|
|
808
|
+
return () => promise.then(drawingId => core_1.api.getState().api.removeDrawing(drawingId));
|
|
809
|
+
}
|
|
810
|
+
destroy() {
|
|
811
|
+
this.drawingId && core_1.api.getState().api.removeDrawing(this.drawingId);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
exports.default = CAD;
|