Hints for API usage
At first glance, our API documentation may appear detailed. This structure is intentional and helps address a wide range of use cases. The following hints will guide you through it.
Object or Objects
You often find in the documentation that param can be either an object or an array of objects containing all the parameters (for example, when creating lines, constraints, etc.).
The main reason is performance: when you use TypeScript or later Python, you can avoid multiple calls going through the websocket connection.
The target Param
Most features in part modeling manage a single solid; only a few, like the pattern feature, deal with multiple solids. If you need to access the i-th solid of a pattern, you must supply the target object with indices. Otherwise, provide the id for target, e.g. featureId.
In the example below, the second and fourth solids from the pattern feature together with the solid from feature shaft should be mirrored.
api.v1.part.mirror({ id: partId, targets: [ head1, shaft ], references: [15] });
api.v1.part.mirror({ id: partId, targets: [{ id: patternId, indices: [2,4] }, shaft ], references: [20] });
Points in Sketch API
When creating sketch geometry (for example, using line, arcByCenter, etc.), you must provide startPos and endPos as points in the format [x, y, z].
Since sketch geometry is always created on a workplane with its origin at (0, 0, 0) and oriented along the x-axis, the geometry must lie entirely on that plane. Therefore, only points with z = 0 are accepted.
This condition is enforced; supplying points with z ≠ 0 will result in an error. While this requirement can be somewhat inconvenient, it is acceptable given the significant additional effort that would be needed to support other 2D point types.