Sketcher
sketcherAPI#
Provides functions for interaction with the classcad sketcher api.
addConstraints#
Adds constraint to sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| names | string[] | New constraint name | |
| cctypes | string[] | New constraint class | |
| entitiesArray | ObjectID[][] | Involved geometry objects | |
| userValues? | (number l string)[] | Only for angle constraint | |
| dimPoses? | PointMemValue[] | For CreateDimension | |
| dimInitialisationOptions? | any[] | For CreateDimension |
Returns Promise<void>
addGeometry#
Adds geometry object to sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| type | 'Point' l 'Line' l 'Arc' l 'Circle' | Type of object to add - "Point", "Line", "Arc", "Circle" | |
| params | PointType l LineType l ArcType l CircleType | Parameter for a point, line, arc or circle depending on type parameter | |
| autoConstr | autoConstrT | ||
| restrictions? | RestrictionType[] | (optional) - array of restriction tokens | |
| restrictionValues? | any[] | (optional) - array of restriction values | |
| startPointRestrictions? | RestrictionType[] | (optional) - array of restriction tokens for the start point | |
| startPointRestrictionValues? | any[] | (optional) - array of restriction values for the start point |
Returns Promise<ObjectID | null>
The id of the new created geometry or null.
addPolycurveSegment#
Adds a line or a curve with spicified parameters and creates an incidence constraint between its start point and another point
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| incidentPointId | ObjectID | Id of another point for incidence constraint | |
| params | LineType l ArcType | Array of parameters for a curve or line | |
| autoConstr | autoConstrT | ||
| restrictions? | RestrictionType[] | (optional) - array of restriction tokens | |
| restrictionValues? | number[] | (optional) - array of restriction values | |
| startPointRestrictions? | RestrictionType[] | (optional) - array of restriction tokens for the start point | |
| startPointRestrictionValues? | number[] | (optional) - array of restriction values for the start point |
Returns Promise<ObjectID | null>
The id of the new created object or null.
addSketchRegion#
Adds a new sketch region
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| name | string | Name of the new sketch region | |
| curves | ObjectID[] | Array of curve ids to represent the sketch region |
Returns Promise<void>
changeReferenceGeometry#
Re-links "Use"-Geometry in sketch - the same geometry will be connected to another referene
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch which the geometry belongs to | |
| useGeometryId | ObjectID | Id of the CC_Arc/Circle/Line/Point that should be re-linked | |
| referenceId | ObjectID | Id of the new edge / vertex to be referenced |
Returns Promise<void>
closePolyLine#
Creates a line between 2 points and incidence constraints between its start / end points and corresponding points
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| startPointId | ObjectID | Id of the start point | |
| endPointId | ObjectID | Id of the end point |
Returns Promise<void>
copyCircularPattern#
Copies selected rigidset (or singular object) in circular pattern
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch containing selected rigidset | |
| rigidsetId | ObjectID | Id of selected rigidset | |
| rotationOrigin | PointMemValue | Point to be used as an origin for rotation | |
| angleStep | number | Angular offset between neighbouring copied objects | |
| count | number | Number of copies |
Returns Promise<void>
copyMirrorPattern#
Copies selected rigidset (or singular object) in mirror pattern
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch containing selected rigidset | |
| rigidsetId | ObjectID | Id of selected rigidset | |
| symmetricLineId | ObjectID | Id of the line to be used as a symmetric line |
Returns Promise<void>
copyObjects#
Copies selected objects of the sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch containing selected objects | |
| objectIds | ObjectID[] | An array of selected object ids | |
| translate | number | Offset from initial objects | |
| toCopyConstraints | boolean | A flag allowing to restrict copying constraints from original selected objects |
Returns Promise<void>
copyRectangularPattern#
Copies selected rigidset (or singular object) in rectangular pattern
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch containing selected rigidset | |
| rigidsetId | ObjectID | Id of selected rigidset | |
| originIndex.index | number | ||
| originIndex.memberName? | string | ||
| translate | PointMemValue | Vector with horizontal / vertical offset between neighbouring copied objects | |
| xCount | number | Number of copies along the x-axis | |
| yCount | number | Number of copies along the y-axis |
Returns Promise<void>
copySketch#
Copies the sketch elements from one sketch to another
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the existing sketch to copy sketch elements into it | |
| toCopySketchId | ObjectID | Id of the sketch to copy elements from |
Returns Promise<void>
createAndSetWorkPlane#
Creates and sets workplane from the selected face for the sketcher
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| faceId | ObjectID | Id of the face |
Returns Promise<void>
createFillet#
Creates a fillet in place of a point connecting 2 lines
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| lineIds | ObjectID[] | Array of 2 line ids | |
| lineStartIds | ObjectID[] | Array of ids of 2 points of different lines which are incident to the selected point | |
| incidenceId | ObjectID | Id of the incidence constraint which connects lineStart points | |
| control | PointMemValue | Position of the selected point | |
| start | PointMemValue | Position of the beginning of an arc | |
| mid | PointMemValue | Position of the middle of an arc | |
| end | PointMemValue | Position of the ending of an arc |
Returns Promise<void>
createRectangle#
Creates a rectangle formed with 2 points
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | ObjectID - id of the sketch | |
| start | PointMemValue | The 1st point to form rectangle | |
| end | PointMemValue | The 2nd point to form rectangle | |
| options? | RectOptionsType | (optional) - Object with optional parameters: isCentered - a flag which defines if the rectangle is created as centered or not; fixation - a flag which defines if fixation constraints should be autogenerated or not; incidence - a flag which defines if coincidence constraints should be autogenerated or not; tangency - a flag which defines if tangency constraints should be autogenerated or not; |
Returns Promise<void>
createReferenceGeometry#
Creates new "Use"-Geometry in sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch to which the new geometry is appended | |
| referenceIds | ObjectID[] | Ids of the CC_Arc/Circle/Line/Point or edge or vertex |
Returns Promise<ObjectID[] | null>
The array of ids of the new created objects or null.
createRigidSet#
Adds rigid set to sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| selectedObjs | ObjectID[] | Involved geometry objects |
Returns Promise<void>
createSketch#
Create a new sketch on the only existing part
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| partId | ObjectID |
Returns Promise<ObjectID | null>
The id of the new created sketch or null.
deleteFillet#
Deleted a fillet by removing an arc and constraints and connecting lines
sketchId - id of the sketch arcId - id of the arc vertexId - id of the point in place of which filleted lines will be connected lineStartIds - array of ids of 2 points of filleted lines which are conneted with an arc constraintIds - array of ids of constraints which should have their entities replaced
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| sketchId | ObjectID | ||
| arcId | ObjectID | ||
| vertexId | ObjectID | ||
| lineStartIds | ObjectID[] | ||
| constraintIds | ObjectID[] |
Returns Promise<void>
generateAutoConstraints#
Automatically generates constraints whenever it makes sense and doesn't add up redundancy
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| objectId | ObjectID | Id of the object to autoconstrain (CC_Sketch id if need to autoconstraint each of its objects) | |
| autoConstr | autoConstrT |
Returns Promise<void>
loadSketch#
Loads an ofb file from stream and copies the sketch elements from sketch with name = sketchName to the existing sketch with id = sketchId.
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| partId | ObjectID | Id of the part to load the sketch into | |
| sketchId | ObjectID | Id of the sketch to copy elements from loaded sketch into it | |
| strm | ArrayBuffer | Stream of the ofb file where we want to load a sketch from and copy its sketch elements | |
| sketchName? | string | Optional name of the sketch to load from filestream, otherwise first sketch will be chosen |
Returns Promise<void>
moveObjects#
Translates objects in the delta direction
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| objectIds | ObjectID[] | Array of objects to be translated | |
| delta | PointMemValue | Direction of the translation |
Returns Promise<void>
recalc#
Recalculates geometry of the sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
removeObjects#
Removes objects from the sketch
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| objectIds | ObjectID[] | Array of object ids to be removed from the sketch | |
| storeState? | boolean | true | Optional flag for whether the state should be stored or not; true by default |
Returns Promise<void>
setSketchRefs#
Sets the references for sketch position
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch to set the references | |
| planeId | ObjectID l null | Id of a face or a workplane. This will be the plane where the sketch lies on | |
| invertPlane | boolean | If true, the normal of the plane will be inverted | |
| axisId | ObjectID l null | Id of an edge or workaxis. This will be the x-Axis | |
| isXAxis | boolean | If true, the axisId will be the x-axis of the sketch, else the x-Axis will be the crossvector of the normal and the axisId | |
| invertAxis | boolean | If true, the direction of the axis will be inverted | |
| originId | ObjectID l null | Optional point or vertex of the sketch's origin reference |
Returns Promise<void>
setWorkPlane#
Sets selected workplane for the sketcher
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| planeId | ObjectID | Id of the plane |
Returns Promise<void>
solveConstraints#
Solves all constraints.
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
splitAllCurves#
Split all curves. Result of split - a container with new objects. After spliting splitCurvesMergeBack should be called.
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
splitCurves#
Splits 1 or 2 curves in specified parameterized positions
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id | |
| sketchId | ObjectID | Id of the sketch | |
| curveIds | ObjectID[] | Array of 1 or 2 curve ids to be split | |
| paramArr | number[][] | Array of 1 or 2 arrays (same length as curveIds array - so paramArr[0] has values for curveIds[0], paramArr[1] for curveIds[1], if it is defined), which consist of split parameter values (in range (0, 1)). Parameter value represents position on the curve from its start to the end (or from 0 to 2*PI for circles) |
Returns Promise<void>
splitCurvesMergeBack#
Merge splitted curves back.
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
unlinkReferenceGeometry#
Unlinks "Use"-Geometry in sketch - geometry still exists but it is not connected to reference
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch which the geometry belongs to | |
| useGeometryId | ObjectID | Id of the CC_Arc/Circle/Line/Point that should be unlinked |
Returns Promise<void>
updateDimensionValue#
Updates value of constraint connected to dimension and recalculates sketch (SolveConstraints and UpdateDimensions)
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | ||
| dimensionId | ObjectID | Id of the dimension | |
| value | APIParam<number> | The new value or expression for dimension and constraint |
Returns Promise<void>
updateDimensions#
Updates sketch dimensions
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
updateGeometry#
Updates sketch geometry
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| sketchId | ObjectID | Id of the sketch | |
| geometryIds | ObjectID[] | Array of geometry object ids to be removed from the sketch | |
| params | PointType l LineType l ArcType l CircleType | Parameter for a point, line, arc or circle. |
Returns Promise<void>
updateSketchRegions#
Updates multiple regions with new sets of curves
Declaration
Params
| Name | Type | Default | Description |
|---|---|---|---|
| drawingId | DrawingID | The drawing id. | |
| regionIds | ObjectID[] | Array of ids of regions to be updated | |
| curvesArr | ObjectID[][] | Array of arrays of curve ids; curvesArr[i] will be set as curves of regionIds[i] region |
Returns Promise<void>