Skip to main content

Sketcher

sketcherAPI#

Provides functions for interaction with the classcad sketcher api.

addConstraints#

Adds constraint to sketch

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, names: string[], cctypes: string[], entitiesArray: ObjectID[][], userValues?: (number | string)[], dimPoses?: PointMemValue[], dimInitialisationOptions?: any[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
namesstring[]New constraint name
cctypesstring[]New constraint class
entitiesArrayObjectID[][]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

async (drawingId: DrawingID, sketchId: ObjectID, type: 'Point' | 'Line' | 'Arc' | 'Circle', params: PointType | LineType | ArcType | CircleType, autoConstr: autoConstrT, restrictions?: RestrictionType[], restrictionValues?: any[], startPointRestrictions?: RestrictionType[], startPointRestrictionValues?: any[]): Promise<ObjectID | null>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
type'Point' l 'Line' l 'Arc' l 'Circle'Type of object to add - "Point", "Line", "Arc", "Circle"
paramsPointType l LineType l ArcType l CircleTypeParameter for a point, line, arc or circle depending on type parameter
autoConstrautoConstrT
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

async (drawingId: DrawingID, sketchId: ObjectID, incidentPointId: ObjectID, params: LineType | ArcType, autoConstr: autoConstrT, restrictions?: RestrictionType[], restrictionValues?: number[], startPointRestrictions?: RestrictionType[], startPointRestrictionValues?: number[]): Promise<ObjectID | null>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
incidentPointIdObjectIDId of another point for incidence constraint
paramsLineType l ArcTypeArray of parameters for a curve or line
autoConstrautoConstrT
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

async (drawingId: DrawingID, sketchId: ObjectID, name: string, curves: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
namestringName of the new sketch region
curvesObjectID[]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

async (drawingId: DrawingID, sketchId: ObjectID, useGeometryId: ObjectID, referenceId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch which the geometry belongs to
useGeometryIdObjectIDId of the CC_Arc/Circle/Line/Point that should be re-linked
referenceIdObjectIDId 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

async (drawingId: DrawingID, sketchId: ObjectID, startPointId: ObjectID, endPointId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
startPointIdObjectIDId of the start point
endPointIdObjectIDId of the end point

Returns Promise<void>

copyCircularPattern#

Copies selected rigidset (or singular object) in circular pattern

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, rigidsetId: ObjectID, rotationOrigin: PointMemValue, angleStep: number, count: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch containing selected rigidset
rigidsetIdObjectIDId of selected rigidset
rotationOriginPointMemValuePoint to be used as an origin for rotation
angleStepnumberAngular offset between neighbouring copied objects
countnumberNumber of copies

Returns Promise<void>

copyMirrorPattern#

Copies selected rigidset (or singular object) in mirror pattern

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, rigidsetId: ObjectID, symmetricLineId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch containing selected rigidset
rigidsetIdObjectIDId of selected rigidset
symmetricLineIdObjectIDId of the line to be used as a symmetric line

Returns Promise<void>

copyObjects#

Copies selected objects of the sketch

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, objectIds: ObjectID[], translate: number, toCopyConstraints: boolean): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch containing selected objects
objectIdsObjectID[]An array of selected object ids
translatenumberOffset from initial objects
toCopyConstraintsbooleanA flag allowing to restrict copying constraints from original selected objects

Returns Promise<void>

copyRectangularPattern#

Copies selected rigidset (or singular object) in rectangular pattern

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, rigidsetId: ObjectID, originIndex: {
index: number;
memberName?: string;
}, translate: PointMemValue, xCount: number, yCount: number): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch containing selected rigidset
rigidsetIdObjectIDId of selected rigidset
originIndex.indexnumber
originIndex.memberName?string
translatePointMemValueVector with horizontal / vertical offset between neighbouring copied objects
xCountnumberNumber of copies along the x-axis
yCountnumberNumber of copies along the y-axis

Returns Promise<void>

copySketch#

Copies the sketch elements from one sketch to another

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, toCopySketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the existing sketch to copy sketch elements into it
toCopySketchIdObjectIDId of the sketch to copy elements from

Returns Promise<void>

createAndSetWorkPlane#

Creates and sets workplane from the selected face for the sketcher

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, faceId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
faceIdObjectIDId of the face

Returns Promise<void>

createFillet#

Creates a fillet in place of a point connecting 2 lines

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, lineIds: ObjectID[], lineStartIds: ObjectID[], incidenceId: ObjectID, control: PointMemValue, start: PointMemValue, mid: PointMemValue, end: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
lineIdsObjectID[]Array of 2 line ids
lineStartIdsObjectID[]Array of ids of 2 points of different lines which are incident to the selected point
incidenceIdObjectIDId of the incidence constraint which connects lineStart points
controlPointMemValuePosition of the selected point
startPointMemValuePosition of the beginning of an arc
midPointMemValuePosition of the middle of an arc
endPointMemValuePosition of the ending of an arc

Returns Promise<void>

createRectangle#

Creates a rectangle formed with 2 points

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, start: PointMemValue, end: PointMemValue, options?: RectOptionsType): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDObjectID - id of the sketch
startPointMemValueThe 1st point to form rectangle
endPointMemValueThe 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

async (drawingId: DrawingID, sketchId: ObjectID, referenceIds: ObjectID[]): Promise<ObjectID[] | null>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch to which the new geometry is appended
referenceIdsObjectID[]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

async (drawingId: DrawingID, sketchId: ObjectID, selectedObjs: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
selectedObjsObjectID[]Involved geometry objects

Returns Promise<void>

createSketch#

Create a new sketch on the only existing part

Declaration

async (drawingId: DrawingID, partId: ObjectID): Promise<ObjectID | null>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectID

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

async (drawingId: DrawingID, sketchId: ObjectID, arcId: ObjectID, vertexId: ObjectID, lineStartIds: ObjectID[], constraintIds: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
sketchIdObjectID
arcIdObjectID
vertexIdObjectID
lineStartIdsObjectID[]
constraintIdsObjectID[]

Returns Promise<void>

generateAutoConstraints#

Automatically generates constraints whenever it makes sense and doesn't add up redundancy

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, objectId: ObjectID, autoConstr: autoConstrT): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
objectIdObjectIDId of the object to autoconstrain (CC_Sketch id if need to autoconstraint each of its objects)
autoConstrautoConstrT

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

async (drawingId: DrawingID, partId: ObjectID, sketchId: ObjectID, strm: ArrayBuffer, sketchName?: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDId of the part to load the sketch into
sketchIdObjectIDId of the sketch to copy elements from loaded sketch into it
strmArrayBufferStream of the ofb file where we want to load a sketch from and copy its sketch elements
sketchName?stringOptional 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

async (drawingId: DrawingID, sketchId: ObjectID, objectIds: ObjectID[], delta: PointMemValue): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
objectIdsObjectID[]Array of objects to be translated
deltaPointMemValueDirection of the translation

Returns Promise<void>

recalc#

Recalculates geometry of the sketch

Declaration

async (drawingId: DrawingID, sketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch

Returns Promise<void>

removeObjects#

Removes objects from the sketch

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, objectIds: ObjectID[], storeState: boolean = true): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
objectIdsObjectID[]Array of object ids to be removed from the sketch
storeState?booleantrueOptional flag for whether the state should be stored or not; true by default

Returns Promise<void>

setSketchRefs#

Sets the references for sketch position

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, planeId: ObjectID | null, invertPlane: boolean, axisId: ObjectID | null, isXAxis: boolean, invertAxis: boolean, originId: ObjectID | null): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch to set the references
planeIdObjectID l nullId of a face or a workplane. This will be the plane where the sketch lies on
invertPlanebooleanIf true, the normal of the plane will be inverted
axisIdObjectID l nullId of an edge or workaxis. This will be the x-Axis
isXAxisbooleanIf 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
invertAxisbooleanIf true, the direction of the axis will be inverted
originIdObjectID l nullOptional point or vertex of the sketch's origin reference

Returns Promise<void>

setWorkPlane#

Sets selected workplane for the sketcher

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, planeId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
planeIdObjectIDId of the plane

Returns Promise<void>

solveConstraints#

Solves all constraints.

Declaration

async (drawingId: DrawingID, sketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId 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

async (drawingId: DrawingID, sketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch

Returns Promise<void>

splitCurves#

Splits 1 or 2 curves in specified parameterized positions

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, curveIds: ObjectID[], paramArr: number[][]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id
sketchIdObjectIDId of the sketch
curveIdsObjectID[]Array of 1 or 2 curve ids to be split
paramArrnumber[][]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

async (drawingId: DrawingID, sketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch

Returns Promise<void>

unlinkReferenceGeometry#

Unlinks "Use"-Geometry in sketch - geometry still exists but it is not connected to reference

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, useGeometryId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch which the geometry belongs to
useGeometryIdObjectIDId 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

async (drawingId: DrawingID, dimensionId: ObjectID, value: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingID
dimensionIdObjectIDId of the dimension
valueAPIParam<number>The new value or expression for dimension and constraint

Returns Promise<void>

updateDimensions#

Updates sketch dimensions

Declaration

async (drawingId: DrawingID, sketchId: ObjectID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch

Returns Promise<void>

updateGeometry#

Updates sketch geometry

Declaration

async (drawingId: DrawingID, sketchId: ObjectID, geometryIds: ObjectID[], params: PointType | LineType | ArcType | CircleType): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
sketchIdObjectIDId of the sketch
geometryIdsObjectID[]Array of geometry object ids to be removed from the sketch
paramsPointType l LineType l ArcType l CircleTypeParameter for a point, line, arc or circle.

Returns Promise<void>

updateSketchRegions#

Updates multiple regions with new sets of curves

Declaration

async (drawingId: DrawingID, regionIds: ObjectID[], curvesArr: ObjectID[][]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
regionIdsObjectID[]Array of ids of regions to be updated
curvesArrObjectID[][]Array of arrays of curve ids; curvesArr[i] will be set as curves of regionIds[i] region

Returns Promise<void>