Hints for API usage
Our API documentation might look on the first view slightly complicated, however there are (often) reason for this. Just read the following hints.
object or objects
You often find in the documentation that param can be either a object or objects containing all the parameters. Like in create api.v1.sketcher.lines, constraints etc etc. The main reason is performance when you use typescript or later python because you can avoid multiple calls going throught the websocket connection.
the target param
Most of the features in part modelling manage a single solid and there are just a few like the pattern feature that deal with several solids. So just in the case, where you need to access the i-th solid of a pattern, you have to supply the target object with indices. Otherwise just provide the id for target: featureId
In the example below the second and fourth solid from the pattern feature together with 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 SketchAPI
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, and supplying points with z ≠ 0 will result in an error. While this requirement can be somewhat inconvenient, it is considered acceptable given the significant additional effort that would be needed to support other 2D point types.