Skip to main content

Utilities

Helpers for sketches, mates and selections, and conversions into the arguments of ClassCAD's API.

Functions​

createTreeObjSelItem()​

function createTreeObjSelItem(productId, object): SelectedItem;

Makes the selection item of a structure object (TreeObjScope), to select it into the active field.

Its label is the capitals of the object's class (WP for a work plane); it goes when the object leaves the tree.

Parameters​

ParameterTypeDescription
productIdnumberThe product the object is picked in: the current product.
objectScgObjectThe object, from the drawing's structure tree.

Returns​

SelectedItem


getMateRefIds()​

function getMateRefIds(drawingId, constrId): number[] | undefined;

Finds the instances of the current assembly that an assembly constraint joins: the ones its two mates are in.

A mate's path leads from an instance of the current assembly down to the coordinate system the mate is on; a mate whose path or coordinate system is gone counts for nothing. Buerligons outlines the instances while the constraint is under the pointer.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing.
constrIdnumberThe constraint (one with firstRefMate and secondRefMate).

Returns​

number[] | undefined

The ids of the instances (children of the current instance), or undefined where neither mate is valid.

Example​

import { createInfo, getDrawing } from '@buerli.io/core'
import type { DrawingID, ObjectID } from '@buerli.io/core'
import { getMateRefIds } from '@buerli.io/react-cad'

// selects the two instances a constraint joins, as Buerligons outlines them
function selectJoined(drawingId: DrawingID, constraintId: ObjectID) {
const drawing = getDrawing(drawingId)
const joined = getMateRefIds(drawingId, constraintId) ?? []
drawing.api.interaction.setSelected(joined.map((id) => createInfo({ objectId: id, prodRefId: id })))
}

Objects​

MateScope​

const MateScope: "HLConstraintScope" = 'HLConstraintScope';

The selection scope of a mate picked into an assembly constraint's field: a work coordinate system of an instance.

An item of this scope has as its data { path: ObjectID[], csys: ScgObject, flip: FlipType, reorient: ReorientedType }: the instances that lead to the coordinate system, the coordinate system, and how the mate lies on it. The mates CSysDisplay shows are picked this way.

Example​

import { getDrawing } from '@buerli.io/core'
import type { DrawingID, SelectorID } from '@buerli.io/core'
import { MateScope } from '@buerli.io/react-cad'

// what a constraint's field holds: the mate's coordinate system, and how the mate lies on it
function describeMate(drawingId: DrawingID, selectorId: SelectorID) {
const item = getDrawing(drawingId).selection.refs[selectorId]?.items[0]
if (item?.scope !== MateScope) return 'no mate'
return `${item.data.csys.name}, flip ${item.data.flip}, turned ${item.data.reorient}`
}

TreeObjScope​

const TreeObjScope: "TreeObjScope" = 'TreeObjScope';

The selection scope of a structure object picked into a field: a feature, a sketch, a work plane, an instance.

A selector of a feature's field says with it whether it takes a tree object (selection.isSelectable(TreeObjScope, { object })); an item of this scope (createTreeObjSelItem) has the object as its data: { object: ScgObject }. The model tree's rows and the work geometry on the stage are picked this way.

Example​

import { getDrawing } from '@buerli.io/core'
import type { DrawingID, ObjectID } from '@buerli.io/core'
import { createTreeObjSelItem, TreeObjScope } from '@buerli.io/react-cad'

// a click on a work plane of the app's own: it goes into the field that is picking, if the field takes it
function pickIntoField(drawingId: DrawingID, workPlaneId: ObjectID) {
const drawing = getDrawing(drawingId)
const selector = drawing.selection.refs[drawing.selection.active ?? '']
const object = drawing.structure.tree[workPlaneId]
const productId = drawing.structure.currentProduct
if (selector && productId && selector.isSelectable(TreeObjScope, { object })) {
drawing.api.selection.select(createTreeObjSelItem(productId, object))
}
}

conversionUtils​

Converts what react-cad's fields hold into the arguments of ClassCAD's api.v1 calls: a mate, a body.

conversionUtils.mateV1()​

function mateV1(mateV0): {
csys: number | undefined;
flip: "Z" | "X" | "-X" | "Y" | "-Y" | "-Z";
path: number[] | undefined;
reorient: "0" | "90" | "180" | "270";
};

A mate as api.v1.assembly's constraint calls take it: its flip as 'X' … '-Z', its turn as '0' … '270'.

Parameters​

ParameterTypeDescription
mateV0{ csys: number | undefined; flip: FlipType; path: number[] | undefined; reorient: ReorientedType; }The mate as a constraint's field holds it: its path, its coordinate system, and its flip and turn as ClassCAD's numbers (FlipType, ReorientedType).
mateV0.csysnumber | undefinedThe work coordinate system the mate is on.
mateV0.flipFlipTypeWhich of its axes is the mate's main one, and which way (ClassCAD's number).
mateV0.pathnumber[] | undefinedThe instances that lead to the coordinate system.
mateV0.reorientReorientedTypeHow far the mate is turned about its main axis (ClassCAD's number).

Returns​

The same mate, with flip and reorient as the v1 API names them.

NameTypeDescription
csysnumber | undefinedThe work coordinate system the mate is on.
flip"Z" | "X" | "-X" | "Y" | "-Y" | "-Z"Which of the coordinate system's axes is the mate's main one, and which way.
pathnumber[] | undefinedThe instances that lead to the coordinate system.
reorient"0" | "90" | "180" | "270"How far the mate is turned about its main axis, in degrees.

Example​

import { createApi, FlipType, ReorientedType } from '@buerli.io/classcad'
import type { DrawingID, ObjectID } from '@buerli.io/core'
import { conversionUtils } from '@buerli.io/react-cad'

// a constraint's two mates as its dialog's fields hold them, written back to the constraint
const mate1 = { path: [nut], csys: nutCsys, flip: FlipType.FLIP_Z, reorient: ReorientedType.REORIENTED_0 }
const mate2 = { path: [bolt], csys: boltCsys, flip: FlipType.FLIP_Z_INV, reorient: ReorientedType.REORIENTED_90 }
await createApi(drawingId).v1.assembly.updateFastened({
id: constraintId,
mate1: conversionUtils.mateV1(mate1), // flip 'Z', reorient '0'
mate2: conversionUtils.mateV1(mate2), // flip '-Z', reorient '90'
})

conversionUtils.solidsV1()​

function solidsV1(drawingId, ids): {
id: string | number;
indices?: number[];
}[];

Bodies as the v1 API references them (solidV1), such as an entity deletion's targets.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing.
idsnumber[]The bodies' objects in the structure tree.

Returns​

{ id: string | number; indices?: number[]; }[]

Example​

import { createApi } from '@buerli.io/classcad'
import type { DrawingID, ObjectID } from '@buerli.io/core'
import { conversionUtils } from '@buerli.io/react-cad'

// takes the selected bodies out of the part again: an entity deletion of them
async function deleteBodies(drawingId: DrawingID, partId: ObjectID, solidIds: ObjectID[]) {
const targets = conversionUtils.solidsV1(drawingId, solidIds)
await createApi(drawingId).v1.part.entityDeletion({ id: partId, name: 'Entity Deletion', targets })
}

conversionUtils.solidV1()​

function solidV1(drawingId, id): {
id: string | number;
indices?: number[];
};

A body as the v1 API references it: the feature that made it, and its place among the feature's bodies.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing.
idnumberThe body's object in the structure tree.

Returns​

{ id } with the feature's id, and indices where the feature made more than one body.

NameTypeDescription
idstring | numberThe feature that made the body.
indices?number[]The body's place among the feature's bodies, where it made more than one.

mateUtils​

Helpers for the mates of an assembly: which of the assembly's instances a nested instance moves with.

mateUtils.getProductRigidSet()​

function getProductRigidSet(
drawingId,
instanceId,
rigidSets
): number | undefined;

Finds the rigid set an instance moves with: the instance of the current assembly it is in (or the current product itself, for one of its own), if that is one of rigidSets.

An assembly's constraints hold its own instances, and what is nested in one of them moves with it. Buerligons asks so when a mate under the pointer is to be dragged: only the instances a selector allows move.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing.
instanceIdnumberAn instance (a product reference) in the current assembly, at any depth.
rigidSetsnumber[]The rigid sets to look in: instances of the current assembly, or the current product.

Returns​

number | undefined

The rigid set, or undefined where it is not one of rigidSets (or there is no drawing).

Example​

import { getDrawing } from '@buerli.io/core'
import type { DrawingID, ObjectID } from '@buerli.io/core'
import { mateUtils } from '@buerli.io/react-cad'

// which of the current assembly's instances moves when a nested instance under the pointer is dragged
function instanceToDrag(drawingId: DrawingID, hoveredInstance: ObjectID, movable: ObjectID[]) {
const rigidSet = mateUtils.getProductRigidSet(drawingId, hoveredInstance, movable)
if (rigidSet === undefined) return null // it moves with nothing that may move
return getDrawing(drawingId).structure.tree[rigidSet]
}

sketchIntersectionUtils​

Where a sketch's lines, arcs and circles cross one another, in the plane of the sketch: what the sketcher's trim and split cut at.

A curve is given by its geometry ({@link CCLineInfo}, {@link CCArcInfo}, {@link CCCircleInfo}), in the sketch's coordinates (z is 0). A place on a curve is its parameter t: 0 at a line's or an arc's start, 1 at its end (on a circle, a turn from the X axis is 1). The intersect… functions return the parameters of the crossings on either curve, [onFirst, onSecond]. A crossing at an end of a curve does not count on that curve (a line that ends on another cuts it there, but is not cut itself).

Example

import * as THREE from 'three'
import { sketchIntersectionUtils as xu } from '@buerli.io/react-cad'

// two lines of a sketch that cross: where, on either, and the point itself
const line = (x0: number, y0: number, x1: number, y1: number): xu.CCLineInfo => ({
start: new THREE.Vector3(x0, y0, 0),
end: new THREE.Vector3(x1, y1, 0),
dir: new THREE.Vector3(x1 - x0, y1 - y0, 0),
})
const a = line(0, 0, 10, 10)
const b = line(0, 10, 10, 0)
const [onA, onB] = xu.intersectLineLine(a, b) // [[0.5], [0.5]]
const crossing = xu.getParameterizedPosition(onA[0], a) // (5, 5, 0)

sketchIntersectionUtils.CCArcInfo​

type sketchIntersectionUtils.CCArcInfo = {
angularLength: number;
center: THREE.Vector3;
clockwise: boolean;
end: THREE.Vector3;
endAngle: number;
radius: number;
start: THREE.Vector3;
startAngle: number;
};

An arc of a sketch.

Properties​

PropertyTypeDescription
angularLengthnumberThe angle it spans: endAngle - startAngle, negative where it runs clockwise.
centerTHREE.Vector3Its center.
clockwisebooleanWhether it runs clockwise from its start to its end.
endTHREE.Vector3Its end.
endAnglenumberThe angle of its end, in radians, a turn on or back where needed to go the arc's way.
radiusnumberIts radius.
startTHREE.Vector3Its start.
startAnglenumberThe angle of its start about the center, in radians.

sketchIntersectionUtils.CCCircleInfo​

type sketchIntersectionUtils.CCCircleInfo = {
center: THREE.Vector3;
radius: number;
};

A circle of a sketch.

Properties​

PropertyTypeDescription
centerTHREE.Vector3Its center.
radiusnumberIts radius.

sketchIntersectionUtils.CCLineInfo​

type sketchIntersectionUtils.CCLineInfo = {
dir: THREE.Vector3;
end: THREE.Vector3;
start: THREE.Vector3;
};

A line of a sketch.

Properties​

PropertyTypeDescription
dirTHREE.Vector3From its start to its end: end - start.
endTHREE.Vector3Its end.
startTHREE.Vector3Its start.

sketchIntersectionUtils.getNormalizedPosition()​

function getNormalizedPosition(point, sketchObject): number;

The parameter of a point on a curve: 0 at its start, 1 at its end (on a circle, a turn from the X axis is 1).

The point is taken to be on the curve. On a line it is the signed distance from the start along the line, over the line's length; on an arc, the angle from its start over the angle it spans (a point beside the arc comes out below 0 or above 1, whichever end is closer).

Parameters​

ParameterTypeDescription
pointVector3A point on the curve.
sketchObjectsketchIntersectionUtils.SketchObjInfoThe curve.

Returns​

number


sketchIntersectionUtils.getParameterizedPosition()​

function getParameterizedPosition(t, sketchObject): Vector3;

The point at a parameter of a curve: the inverse of getNormalizedPosition.

Parameters​

ParameterTypeDescription
tnumberThe parameter: 0 at the curve's start, 1 at its end.
sketchObjectsketchIntersectionUtils.SketchObjInfoThe curve.

Returns​

Vector3


sketchIntersectionUtils.intersectArcArc()​

function intersectArcArc(arc1, arc2): number[][];

Where two arcs cross.

Parameters​

ParameterType
arc1sketchIntersectionUtils.CCArcInfo
arc2sketchIntersectionUtils.CCArcInfo

Returns​

number[][]

[onArc1, onArc2]: the parameters of the crossings on either arc.


sketchIntersectionUtils.intersectArcCircle()​

function intersectArcCircle(arc, circle): number[][];

Where an arc crosses a circle.

Parameters​

ParameterType
arcsketchIntersectionUtils.CCArcInfo
circlesketchIntersectionUtils.CCCircleInfo

Returns​

number[][]

[onArc, onCircle]: the parameters of the crossings on the arc, and on the circle.


sketchIntersectionUtils.intersectCircleCircle()​

function intersectCircleCircle(circle1, circle2): number[][];

Where two circles cross (arcs count as their whole circles here).

Parameters​

ParameterType
circle1| sketchIntersectionUtils.CCArcInfo | sketchIntersectionUtils.CCCircleInfo
circle2| sketchIntersectionUtils.CCArcInfo | sketchIntersectionUtils.CCCircleInfo

Returns​

number[][]

[onCircle1, onCircle2]: the parameters of the crossings on either circle.


sketchIntersectionUtils.intersectLineArc()​

function intersectLineArc(line, arc): number[][];

Where a line crosses an arc.

Parameters​

ParameterType
linesketchIntersectionUtils.CCLineInfo
arcsketchIntersectionUtils.CCArcInfo

Returns​

number[][]

[onLine, onArc]: the parameters of the crossings on the line, and on the arc.


sketchIntersectionUtils.intersectLineCircle()​

function intersectLineCircle(line, circle): number[][];

Where a line crosses a circle (an arc counts as its whole circle here).

Parameters​

ParameterType
linesketchIntersectionUtils.CCLineInfo
circle| sketchIntersectionUtils.CCArcInfo | sketchIntersectionUtils.CCCircleInfo

Returns​

number[][]

[onLine, onCircle]: the parameters of the crossings on the line, and on the circle.


sketchIntersectionUtils.intersectLineLine()​

function intersectLineLine(line1, line2): number[][];

Where two lines cross.

Parameters​

ParameterType
line1sketchIntersectionUtils.CCLineInfo
line2sketchIntersectionUtils.CCLineInfo

Returns​

number[][]

[onLine1, onLine2]: the parameters of the crossing on either line (none, or one).


sketchIntersectionUtils.SketchObjInfo​

type sketchIntersectionUtils.SketchObjInfo =
| sketchIntersectionUtils.CCLineInfo
| sketchIntersectionUtils.CCArcInfo
| sketchIntersectionUtils.CCCircleInfo;

A line, an arc or a circle of a sketch.

sketchUtils​

Helpers for sketches: what a structure object is in a sketch, a sketch's curves and constraints, and how to look at a sketch.

They read the drawing's structure tree as it is now (getDrawing), so they are called from handlers and effects, not to render.

Example

import { useBounds } from '@react-three/drei'
import { getDrawing } from '@buerli.io/core'
import type { DrawingID } from '@buerli.io/core'
import { sketchUtils } from '@buerli.io/react-cad'

// inside drei's <Bounds>: a button of the app's that looks straight at the sketch being edited
function useFitSketch(drawingId: DrawingID) {
const bounds = useBounds()
return () => {
if (!sketchUtils.isSketchActive(drawingId)) return
const active = getDrawing(drawingId).plugin.active.feature
const sketchId = sketchUtils.getSketchId(drawingId, getDrawing(drawingId).plugin.refs[active!]?.objectId)
const fit = sketchUtils.getSketchFitInfo(drawingId, sketchId, 4)
if (fit) bounds.refresh(fit.globBox).moveTo(fit.position).lookAt({ target: fit.target, up: fit.up }).fit()
}
}

sketchUtils.calculateTangent()​

function calculateTangent(
drawingId,
curveId,
point
): Vector3 | undefined;

Calculates the tangent vector of a CC_Line / CC_Arc / CC_Circle at the specified point.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
curveIdnumberId of a CC_Line / CC_Arc / CC_Circle.
pointVector3Point at which the tangent touches a curve.

Returns​

Vector3 | undefined

Tangent vector value.


sketchUtils.getArcInfo()​

function getArcInfo(
start,
end,
center,
clockwise
): {
bulge: number;
center: Vector3;
endAngle: number;
mid: Vector3;
radius: number;
startAngle: number;
};

Calculates arc midpoint, radius, startAngle, endAngle and bulge values.

Parameters​

ParameterTypeDescription
startVector3Start point of an arc.
endVector3End point of an arc.
centerVector3Center point of an arc.
clockwisebooleanTrue if the direction from start to end is clockwise, false otherwise.

Returns​

An object with center, mid, radius, startAngle, endAngle and bulge values.

NameTypeDescription
bulgenumberIts bulge: the tangent of a quarter of the angle it spans.
centerVector3The arc's center (a copy).
endAnglenumberThe angle of its end, in radians, a turn on where needed to go the arc's way from the start.
midVector3The point halfway along the arc.
radiusnumberIts radius: the mean of the start's and the end's distance from the center.
startAnglenumberThe angle of its start, in radians.

sketchUtils.getArcPreviewValue()​

function getArcPreviewValue(
dir0,
dir1,
sector,
reflex
): number;

Calculates the angle between dir0 and dir1 or their negations depending on sector and reflex values.

Parameters​

ParameterTypeDescription
dir0Vector3The first direction.
dir1Vector3The second direction.
sectornumberThe sector index (0-3).
reflexnumberA flag for changing angle coverage from the current sector to the opposite 3.

Returns​

number

The resulting angle between dir0 and dir1.


sketchUtils.getArcSector()​

function getArcSector(
dimPos,
dir0,
dir1,
center
): 0 | 1 | 2 | 3;

Finds the sector (indexed 0-3) to which the dimPos belongs to. Sectors are divided by dir0 and dir1 vectors and their negations.

Parameters​

ParameterTypeDescription
dimPosVector3A point
dir0Vector3The first direction.
dir1Vector3The second direction.
centerVector3A center point of the arc.

Returns​

0 | 1 | 2 | 3

A sector index (0-3) to which the dimPos belongs to.


sketchUtils.getEntities()​

function getEntities(drawingId, objectId): number[];

Looks up for entities of a 2d constraint / sketch region.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
objectIdnumberId of a 2d constraint / sketch region.

Returns​

number[]

Ids of geometry entities linked to the specified 2d constraint / sketch region.


sketchUtils.getObjCenterPoint()​

function getObjCenterPoint(drawingId, geometryId): Vector3;

Calculates an object's center point.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
geometryIdnumberId of a sketch geometry.

Returns​

Vector3

A center point of specified sketch geometry.


sketchUtils.getSketchBounds()​

function getSketchBounds(boundsMember): {
box: Box3;
center: Vector3;
radius: number;
};

Looks up for sketch's bounds values.

Parameters​

ParameterTypeDescription
boundsMemberScgArrayMemThe sketch.boundingBox member.

Returns​

An object containing the center, radius and box values.

NameTypeDescription
boxBox3The bounds, in the sketch's own coordinates.
centerVector3The center of the sketch's bounds.
radiusnumberThe radius of the sphere around them.

sketchUtils.getSketchFitInfo()​

function getSketchFitInfo(
drawingId,
sketchId,
radiusMultiplier?
):
| {
globBox: Box3;
position: Vector3;
target: Vector3;
up: Vector3;
}
| undefined;

Calculates the global bounding box, camera position, camera target and camera up vector to fit the camera for the given sketch.

Parameters​

ParameterTypeDefault valueDescription
drawingIdDrawingIDundefinedThe drawing id.
sketchIdnumberundefinedId of the sketch.
radiusMultiplier?number1A multiplier for the distance between camera and sketch.

Returns​

An object with globBox, position, target and up values.

Type Literal​
{
globBox: Box3;
position: Vector3;
target: Vector3;
up: Vector3;
}
NameTypeDescription
globBoxBox3The sketch's bounds in world coordinates.
positionVector3Where the camera goes: on the sketch plane's normal, over its middle.
targetVector3What the camera looks at: the middle of the sketch.
upVector3The camera's up: the sketch's Y.

undefined


sketchUtils.getSketchId()​

function getSketchId(drawingId, objId): number;

Searches for the sketch which nests the specified object.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
objIdnumber | undefinedId of an object which (supposedly) is nested within some sketch.

Returns​

number

Id of the sketch which nests the specified object, or -1 if it wasn't found.


sketchUtils.getSketchNormalViewInfo()​

function getSketchNormalViewInfo(
drawingId,
sketchId,
targetPos,
distance
):
| {
globBox: Box3;
position: Vector3;
target: Vector3;
up: Vector3;
}
| undefined;

Calculates the global bounding box, camera position, camera target and camera up vector for the given sketch to target some point with camera oriented orthogonally to it.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
sketchIdnumberId of the sketch.
targetPosVector3A point near the sketch plane to use as the camera target.
distancenumberThe distance value to set between camera and sketch.

Returns​

An object with globBox, position, target and up values.

Type Literal​
{
globBox: Box3;
position: Vector3;
target: Vector3;
up: Vector3;
}
NameTypeDescription
globBoxBox3The sketch's bounds in world coordinates.
positionVector3Where the camera goes: distance along the sketch plane's normal from the target.
targetVector3What the camera looks at: targetPos projected onto the sketch's plane.
upVector3The camera's up: the sketch's Y.

undefined


sketchUtils.getSketchPriority()​

function getSketchPriority(arg): -1 | 1 | 2 | 3 | 4 | 5;

Defines a numeric priority of sketch objects and regions, which may be used for sorting them or as a polygon offset for rendering.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

-1 | 1 | 2 | 3 | 4 | 5

A number value (1-5) which represents the sketch object's priority, or -1 if arg is not a sketch object.


sketchUtils.is2DConstraint()​

function is2DConstraint(arg): boolean;

Checks if the object represents a 2d constraint.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

boolean

True if the object represents a 2d constraint, false otherwise.


sketchUtils.isConstruction()​

function isConstruction(arg): boolean;

Checks if the object is a construction geometry.

Parameters​

ParameterTypeDescription
argScgObjectA structure object or CCClass of a structure object.

Returns​

boolean

True if the object is a construction geometry, false otherwise.


sketchUtils.isSketchActive()​

function isSketchActive(drawingId): boolean;

Checks if the drawing's active feature is a sketch (CC_Sketch): useIsSketchActive, outside of a component.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.

Returns​

boolean

True if CC_Sketch is active, false otherwise.


sketchUtils.isSketchCurve()​

function isSketchCurve(arg): boolean;

Checks if the object represents a sketch curve.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

boolean

True if the object represents a sketch curve, false otherwise.


sketchUtils.isSketchGeometry()​

function isSketchGeometry(arg): boolean;

Checks if the object represents a sketch geometry.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

boolean

True if the object represents a sketch geometry, false otherwise.


sketchUtils.isSketchObj()​

function isSketchObj(arg): boolean;

Checks if the object represents a sketch geometry or 2d constraint or a sketch itself.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

boolean

True if the object represents a sketch or a sketch geometry or a 2d constraint, false otherwise.


sketchUtils.isSketchRegion()​

function isSketchRegion(arg): boolean;

Checks if the object represents a sketch region.

Parameters​

ParameterTypeDescription
argScgObject | ScgClassTypeA structure object or CCClass of a structure object.

Returns​

boolean

True if the object represents a sketch region, false otherwise.


sketchUtils.projectPointOnGeometry()​

function projectPointOnGeometry(
drawingId,
geometryId,
point
): Vector3;

Projects a point onto the specified sketch geometry.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
geometryIdnumberId of a sketch geometry.
pointVector3A point to be projected.

Returns​

Vector3

A projected point.


sketchUtils.rollUpPoints()​

function rollUpPoints(
drawingId,
id1,
id2
): number[];

Takes ids of 2 CC_Points and if they belong to the same line, returns the id of that line; otherwise, returns ids of these points.

Parameters​

ParameterTypeDescription
drawingIdDrawingIDThe drawing id.
id1numberId of the first CC_Point.
id2numberId of the seconds CC_Point.

Returns​

number[]

An array with a single id of the CC_Line if both points belong to the same one, or an array [id1, id2] otherwise.