Sketcher
#
sketcherAPIProvides functions for interaction with the classcad sketcher api.
#
addConstraintsAdds 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>
#
addGeometryAdds 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.
#
addPolycurveSegmentAdds 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.
#
addSketchRegionAdds 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>
#
changeReferenceGeometryRe-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>
#
closePolyLineCreates 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>
#
copyCircularPatternCopies 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>
#
copyMirrorPatternCopies 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>
#
copyObjectsCopies 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>
#
copyRectangularPatternCopies 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>
#
copySketchCopies 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>
#
createAndSetWorkPlaneCreates 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>
#
createFilletCreates 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>
#
createRectangleCreates 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>
#
createReferenceGeometryCreates 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.
#
createRigidSetAdds 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>
#
createSketchCreate 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.
#
deleteFilletDeleted 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>
#
generateAutoConstraintsAutomatically 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>
#
loadSketchLoads 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>
#
moveObjectsTranslates 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>
#
recalcRecalculates geometry of the sketch
Declaration
Params
Name | Type | Default | Description |
---|---|---|---|
drawingId | DrawingID | The drawing id. | |
sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
#
removeObjectsRemoves 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>
#
setSketchRefsSets 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>
#
setWorkPlaneSets 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>
#
solveConstraintsSolves all constraints.
Declaration
Params
Name | Type | Default | Description |
---|---|---|---|
drawingId | DrawingID | The drawing id. | |
sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
#
splitAllCurvesSplit 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>
#
splitCurvesSplits 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>
#
splitCurvesMergeBackMerge splitted curves back.
Declaration
Params
Name | Type | Default | Description |
---|---|---|---|
drawingId | DrawingID | The drawing id. | |
sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
#
unlinkReferenceGeometryUnlinks "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>
#
updateDimensionValueUpdates 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>
#
updateDimensionsUpdates sketch dimensions
Declaration
Params
Name | Type | Default | Description |
---|---|---|---|
drawingId | DrawingID | The drawing id. | |
sketchId | ObjectID | Id of the sketch |
Returns Promise<void>
#
updateGeometryUpdates 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>
#
updateSketchRegionsUpdates 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>