Skip to main content

Feature

featureAPI#

Provides functions for interaction with the classcad feature api.

rollback#

moveToEnd#

Moves the rollback bar to the end of the feature list.

Calls

  • Feature.OperationMoveToEnd

Declaration

async (drawingId: DrawingID): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.

Returns Promise<void>

moveBefore#

Moves the rollback bar before the given feature.

Calls

  • Feature.OperationMoveBefore

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the feature to move the rollback bar before.

Returns Promise<void>

calculateMovement#

Calculates the feature id according on the new and the old index of the rollback bar.

Declaration

(oldIndex: number, newIndex: number, featureIds: ObjectID[], offset: number = 4): {
moveTo: 'end' | 'before';
featureId: ObjectID;
index: number;
}

Params

NameTypeDefaultDescription
oldIndexnumberThe old rollback bar index.
newIndexnumberThe new rollback bar index.
featureIdsObjectID[]The feature id list.
offset?number4The number of features at the top of the list that should not be considered by the rollback bar.

Returns { moveTo: 'end' | 'before'; featureId: ObjectID; index: number }
An object in the form { moveTo: 'end' | 'before'; featureId: ObjectId, index: number }. If moveTo is equal to 'end', the end of the list is reached and the featureId will be -1.

closeFeature#

Moves GhostRollbackBar back to RollbackBar, sets relevant solids' visibility.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the feature to close.

Returns Promise<void>

createFeature#

Creates a new (empty) Feature in part.

Declaration

async (drawingId: DrawingID, partId: ObjectID, type: string, name: string): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDThe id of the part, where the feature will be added.
typestringClass name of the feature to create.
namestringThe name the created feature will get.

Returns Promise<number>
The id of the new created Feature or null.

createNamedCoordSystem#

Creates new NamedCoordSystem in product and sets its coordinate system.

Declaration

async (drawingId: DrawingID, productId: ObjectID, { name = 'CoordSystem', origin = { x: 0, y: 0, z: 0 }, xVec = { x: 1, y: 0, z: 0 }, yVec = { x: 0, y: 1, z: 0 }, }: {
name?: string;
origin?: PointMemValue;
xVec?: PointMemValue;
yVec?: PointMemValue;
} = {}): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
productIdObjectIDThe id of the product, where the named coordinate system will be added.
name?string'CoordSystem'
origin?PointMemValue{ x: 0, y: 0, z: 0 }
xVec?PointMemValue{ x: 1, y: 0, z: 0 }
yVec?PointMemValue{ x: 0, y: 1, z: 0 }

Returns Promise<number>
The id of the new created NamedCoordSystem or null.

createNamedPoint#

Creates new NamedPoint in product and sets its position.

Declaration

async (drawingId: DrawingID, productId: ObjectID, { name = 'Point', origin = { x: 0, y: 0, z: 0 }, }: {
name?: string;
origin?: PointMemValue;
} = {}): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
productIdObjectIDThe id of the product, where the named point will be added.
name?string'Point'
origin?PointMemValue{ x: 0, y: 0, z: 0 }

Returns Promise<number>
The id of the new created NamedPoint or null.

createWorkGeometry#

Creates new (default) WorkGeometry in a part

Declaration

async (drawingId: DrawingID, partId: ObjectID, type: string, name: string): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDId of the product to which the new work geometry is added
typestringClass of work geometry as string which will be created
namestringName of the created work geometry object

Returns Promise<number>
The id of the new created WorkGeometry or null.

deleteDimensions#

Deletes dimensions

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
idsObjectID[]Ids of the dimensions to delete.

Returns Promise<void>

deleteFeature#

Deletes feature object and its reference in operation sequence.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
idObjectIDId of the feature to delete.

Returns Promise<void>

getFeatureByName#

Returns the id of the feature with name = featureName which is located in solid set.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDPart to look for the feature
featureNamestring l nullName of the feature to look for

Returns Promise<number>
The id of the found feature

linkWithExpression#

Connects expression in ExpressionSet with dimensional constraints in sketcher or parameter in feature.

Declaration

async (drawingId: DrawingID, objectId: ObjectID, expressionName: string, parameterName: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
objectIdObjectIDId of dimension or feature object
expressionNamestringExpression name
parameterNamestringParameter in feature which will be connected to expression

Returns Promise<void>

newPart#

Clears the drawing and creates a new part

Declaration

async (drawingId: DrawingID, name: string): Promise<number>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
namestringName of the new part

Returns Promise<number>
The id of the new part.

openFeature#

Moves GhostRollbackBar to the position before passed feature, sets relevant solids' visibility.

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the feature to open

Returns Promise<void>

operationMoveBefore#

Moves RollbackBar to the position before passed feature (backwards or forwards), sets relevant solids' visibility, if OperationSequence.isDirty = TRUE and forwards(to end direction) then OperationSequence.GenerateSequence ("Recalc") will be called

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDId of the part where the rollback bar will be moved
featureIdObjectIDId of the feature to move the rollback bar to

Returns Promise<void>

operationMoveToEnd#

Moves RollbackBar to the end of OperationSequence and sets relevant solids' visibility, if OperationSequence.isDirty = TRUE then OperationSequence.GenerateSequence ("Recalc") will be called

Declaration

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

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDId of the part where the rollback bar will be moved to the end

Returns Promise<void>

pick#

Returns found vertices, edges or faces depending on given type and points. Given points define where to look for elements.

Declaration

async (drawingId: DrawingID, partId: ObjectID, type: string, points: PointMemValue[]): Promise<number[]>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
partIdObjectIDId of the part to pick elements
typestringType of element to pick, 'vertex' l 'edge' l 'face'
pointsPointMemValue[]Points containing 3D coordinates to look for possible element

Returns Promise<number[]>
Array containing ids of found geometries

unlinkExpression#

Unlinks expression from dimensional constraints in sketcher or parameter in feature

Declaration

async (drawingId: DrawingID, objectId: ObjectID, parameterName: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
objectIdObjectIDId of dimension or feature object
parameterNamestringParameter in feature which will be connected to expression

Returns Promise<void>

updateBooleanOperation#

Sets entities on BooleanOperation This method can be used to complete the boolean operation, if CreateBooleanOperation was used to only create the operation without passing entities or to change the operation entities when editing operation.

Declaration

async (drawingId: DrawingID, operationId: ObjectID, type: BooleanOperationType, entities: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
operationIdObjectIDId of the boolean operation
typeBooleanOperationTypeType of the boolean operation (0= "Union", 1= "Subtraction",2= "Intersection")
entitiesObjectID[]Entities for the operation [entity1,entity2,entity3,...]

Returns Promise<void>

updateBox#

Updates box feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, references: ObjectID[], width: APIParam<number>, length: APIParam<number>, height: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the box feature to update.
referencesObjectID[]Reference of the work coordinate system to place the box at.
widthAPIParam<number>Width of the box.
lengthAPIParam<number>Length of the box.
heightAPIParam<number>Height of the box.

Returns Promise<void>

updateChamfer#

Updates the chamfer feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, type: ChamferType, references: GraphicID[], distance1: APIParam<number>, distance2: APIParam<number>, angle: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the chamfer feature to update.
typeChamferTypeType of the chamfer
referencesGraphicID[]References of the edges to add the chamfers
distance1APIParam<number>First distance of the chamfer
distance2APIParam<number>Second distance of the chamfer, depends on type if necessary
angleAPIParam<number>Angle of the chamfer, depends on type if necessary

Returns Promise<void>

updateCone#

Updates cone feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, references: ObjectID[], bDiameter: APIParam<number>, tDiameter: APIParam<number>, height: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the cone feature to update.
referencesObjectID[]Reference of the work coordinate system to place the cone at.
bDiameterAPIParam<number>Diameter at the bottom of the cone
tDiameterAPIParam<number>Diameter at the top of the cone
heightAPIParam<number>Height of the cone

Returns Promise<void>

updateCylinder#

Updates cylinder feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, references: ObjectID[], diameter: APIParam<number>, height: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the cylinder feature to update.
referencesObjectID[]Reference of the work coordinate system to place the cylinder at.
diameterAPIParam<number>Diameter of the cylinder
heightAPIParam<number>Height of the cylinder

Returns Promise<void>

updateEntityDeletion#

Updates the entity deletion feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, bodiesToDelete: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the entity deletion feature
bodiesToDeleteObjectID[]Ids of the entityObjs to delete

Returns Promise<void>

updateExpressions#

Adds, updates, or deletes expressions in different parts

Declaration

async (drawingId: DrawingID, expressions: ExpressionParam[]): Promise<boolean>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
expressionsExpressionParam[]Array of expression objects containing the product id, to add members, to update members and to delete members

Returns Promise<boolean>

updateExtrusion#

Updates the extrusion feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, selectedIds: ObjectID[], type: ExtrusionType, limit1: APIParam<number>, limit2: APIParam<number>, taperAngle: APIParam<number>, direction: APIParam<PointMemValue>, capEnds: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the extusion feature to update
selectedIdsObjectID[]Array of ids of the sketch contour elements
typeExtrusionTypeType of the extrusion
limit1APIParam<number>First limit of the extrusion
limit2APIParam<number>Second limit of the extusion, depends on the type if necessary
taperAngleAPIParam<number>Taper angle of the extrusion
directionAPIParam<PointMemValue>Direction of the extrusion, by default {0,0,1}
capEnds0 l 1If true, ends will be capped, else a sheet will be created

Returns Promise<void>

updateFillet#

Updates the fillet feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, references: GraphicID[], radius: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the feature fillet to update
referencesGraphicID[]References of the edges to add the chamfers
radiusAPIParam<number>Radius of the fillet

Returns Promise<void>

updateImport#

Updates Import - Removes old solids, sets new imported ones, and renames the feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, stream: any, fileFormat: 'stp' | 'step', fileName: string): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the import feature
streamanyGeometry stream
fileFormat'stp' l 'step'Supported file formats are: 'stp', 'step'
fileNamestringName the import feature will get

Returns Promise<void>

updateMirror#

Updates mirror feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, solidObjectsToMirror: ObjectID[], references: ObjectID[]): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the mirror operation
solidObjectsToMirrorObjectID[]Ids of the solids to be mirrored
referencesObjectID[]Ids of plane(s) or face(s)

Returns Promise<void>

updatePattern#

Updates pattern feature - sets parameters, handles references, does recalc.

Declaration

async (drawingId: DrawingID, operationId: ObjectID, solidObjectsToPattern: ObjectID[], references: GraphicID[], params: [
0 | 1,
APIParam<number>,
APIParam<number>,
0 | 1
], references2: GraphicID[] | null, params2: [
0 | 1,
APIParam<number>,
APIParam<number>
] | null): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
operationIdObjectIDId of the operation
solidObjectsToPatternObjectID[]Solid objects for the operation
referencesGraphicID[]Selected vertices or points for the 1st direction
params[0 l 1, APIParam<number>, APIParam<number>, 0 l 1][inverted, distanceOrAngle, count, merged], where inverted - 0 or 1 - determines the 1st direction of the pattern; distanceOrAngle - distance (LinearPattern) or angle (CircularPattern) between consecutive copied elements over the 1st direction; count - number of copies over the 1st direction (including the original element); merged - 0 or 1 - determines whether the copies will be merged into a single solid (1) or separate solids (0)
references2GraphicID[] l nullSelected vertices or points for the 2nd direction (optional for LinearPattern)
params2[0 l 1, APIParam<number>, APIParam<number>] l null[inverted2, distance2, count2] (optional for LinearPattern), where inverted2 - 0 or 1 - determines the 2nd direction of the pattern; distance2 - distance between consecutive copied elements over the 2nd direction; count2 - number of copies over the 2nd direction (including the original element);

Returns Promise<void>

updateRevolve#

Updates revolve feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, selectedIds: ObjectID[], axisIds: ObjectID[], angle1: APIParam<number>, angle2: APIParam<number>, inverted: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the feature
selectedIdsObjectID[]Ids of curves
axisIdsObjectID[]Ids of the axis entities
angle1APIParam<number>Revolve start angle
angle2APIParam<number>Revolve end angle
inverted0 l 10 or 1 - determines the direction (clockwise / counterclockwise) of revolve

Returns Promise<void>

updateSlice#

Updates slice feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, solidObjectsToSlice: ObjectID[], plane: ObjectID, sideFlag: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the operation
solidObjectsToSliceObjectID[]Array of solid objects to be sliced
planeObjectIDSelected workplane
sideFlag0 l 10 or 1 - determines which side of the solid remains and which one is culled

Returns Promise<void>

updateSliceBySheet#

Updates slice by sheet feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, solidToCut: ObjectID, sheet: ObjectID, inverted: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the operation
solidToCutObjectIDSolid which will be cutted
sheetObjectIDSheet to slice the solidToCut with
inverted0 l 10 or 1 - flag to toggle direction of sheet

Returns Promise<void>

updateSphere#

Updates sphere feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, references: ObjectID[], radius: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the sphere feature to update.
referencesObjectID[]Reference of the work coordinate system to place the sphere at.
radiusAPIParam<number>Radius of the sphere.

Returns Promise<void>

updateTransformation#

Updates transformation feature.

Declaration

async (drawingId: DrawingID, featureId: ObjectID, solidObjectsToTransform: ObjectID[], references: ObjectID[], inverted: 0 | 1, distanceOrAngle: APIParam<number>): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDId of the transformation operation
solidObjectsToTransformObjectID[]Id of the solids to be transformed
referencesObjectID[]Ids of 2 points that define the transformation axis or 2 coordinate systems
inverted0 l 10 or 1 - determines the direction of transformation
distanceOrAngleAPIParam<number>Translation distance or rotation angle

Returns Promise<void>

updateTwist#

Updates the twist feature

Declaration

async (drawingId: DrawingID, featureId: ObjectID, selectedIds: ObjectID[], type: ExtrusionType, limit1: APIParam<number>, limit2: APIParam<number>, direction: APIParam<PointMemValue>, twistAngle: APIParam<number>, twistCenter: APIParam<PointMemValue>, capEnds: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
featureIdObjectIDThe id of the twist feature to update
selectedIdsObjectID[]Array of ids of the sketch contour elements
typeExtrusionTypeType of the twist
limit1APIParam<number>First limit of the twist
limit2APIParam<number>Second limit of the twist, depends on the type if necessary
directionAPIParam<PointMemValue>Direction of the twist, by default {0,0,1}
twistAngleAPIParam<number>Twist angle of the sketch along height of twist
twistCenterAPIParam<PointMemValue>Point which together with direction defines the twist axis. The actual center/start of the twist is where the defined twist axis intersects the sketch plane.
capEnds0 l 1If true, ends will be capped and a solid is created, else a sheet will be created.

Returns Promise<void>

updateWorkAxis#

Updates the work axis

Declaration

async (drawingId: DrawingID, workAxisId: ObjectID, axisType: WorkAxisType, references: GraphicID[], position: APIParam<PointMemValue>, direction: APIParam<PointMemValue>, local: boolean): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
workAxisIdObjectIDThe id of the work axis to update
axisTypeWorkAxisTypeType of the work axis
referencesGraphicID[]References for the work axis, needed for all types except 'Custom'
positionAPIParam<PointMemValue>Position of axis, only needed if type = 'Custom'
directionAPIParam<PointMemValue>Direction of axis, only needed if type = 'Custom'
localbooleanBoolean specifying if position and direction are global or local to parent

Returns Promise<void>

updateWorkCSys#

Updates the work coordinate system

Declaration

async (drawingId: DrawingID, workCoordSystemId: ObjectID, coordSystemType: WorkCoordSystemType, references: GraphicID[], offset: APIParam<PointMemValue>, rotation: APIParam<PointMemValue>, inverted: 0 | 1): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
workCoordSystemIdObjectIDThe id of the work coordinate system to update.
coordSystemTypeWorkCoordSystemTypeType of the work coordinate system
referencesGraphicID[]Refereneces of origin, first axis and second axis
offsetAPIParam<PointMemValue>Offset vector {x,y,z}
rotationAPIParam<PointMemValue>Rotation vector {x,y,z}
inverted0 l 1Inverts the direction of the primary axis

Returns Promise<void>

updateWorkCoordSystem#

Updates the work coordinate system

Declaration

async (drawingId: DrawingID, workCoordSystemId: ObjectID, coordSystemType: WorkCoordSystemType, references: GraphicID[], coordinateSystem: PointMemValue[], offset: APIParam<PointMemValue>, rotation: APIParam<PointMemValue>, inverted: 0 | 1, local: boolean): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
workCoordSystemIdObjectIDThe id of the work coordinate system to update.
coordSystemTypeWorkCoordSystemTypeType of the work coordinate system
referencesGraphicID[]Refereneces of origin, first axis and second axis
coordinateSystemPointMemValue[]Array of points for origin, first axis and second axis, if type is custom
offsetAPIParam<PointMemValue>Offset vector {x,y,z}
rotationAPIParam<PointMemValue>Rotation vector {x,y,z}
inverted0 l 1Inverts the direction of the primary axis
localbooleanBoolean specifying if coord system is global or local to parent

Returns Promise<void>

updateWorkPlane#

Updates the work plane

Declaration

async (drawingId: DrawingID, workPlaneId: ObjectID, planeType: WorkPlaneType, references: GraphicID[], offset: APIParam<number>, angle: APIParam<number>, position: APIParam<PointMemValue>, normal: APIParam<PointMemValue>, local: boolean): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
workPlaneIdObjectIDThe id of the work plane to update.
planeTypeWorkPlaneTypeType of the work plane
referencesGraphicID[]References for the work plane, needed for all types except 'Custom'
offsetAPIParam<number>Offset in normal direction, can be used for all types except 'LinePlaneAndAngle'
angleAPIParam<number>Angle in degrees, needed for type 'LinePlaneAndAngle'
positionAPIParam<PointMemValue>Position of plane, only needed if type = 'Custom'
normalAPIParam<PointMemValue>Normal vector of work plane, only needed if type = 'Custom'
localbooleanIf true, work plane is set in local coordinates of part

Returns Promise<void>

updateWorkPoint#

Updates the work point

Declaration

async (drawingId: DrawingID, workPointId: ObjectID, pointType: WorkPointType, references: GraphicID[], position: APIParam<PointMemValue>, local: boolean): Promise<void>

Params

NameTypeDefaultDescription
drawingIdDrawingIDThe drawing id.
workPointIdObjectIDThe id of the work point to update.
pointTypeWorkPointTypeType of the work point.
referencesGraphicID[]References for the work point, needed for all types except 'Custom'
positionAPIParam<PointMemValue>Position of point, only needed if type = 'Custom'
localbooleanIf true, work point is set in local coordinates of part

Returns Promise<void>