OCCT plate with ellipses

OCCT plate with ellipses script details
Type
Typescript logo image
typescript
App Version
0.16.1
Visibility
public
Date Created
Feb 19, 2024, 11:02:06 AM
Last Edit Date
Sep 8, 2024, 5:08:10 AM

Script Details

The Code
async function start() { const squareOpt = new Bit.Inputs.OCCT.SquareDto(); squareOpt.direction = [0, 0, 1]; squareOpt.size = 20; const square = await bitbybit.occt.shapes.face.createSquareFace(squareOpt); const subdivOpt = new Bit.Inputs.OCCT.FaceSubdivisionDto<Bit.Inputs.OCCT.TopoDSFacePointer>(); subdivOpt.shape = square; subdivOpt.removeEndEdgeU = true; subdivOpt.removeEndEdgeV = true; subdivOpt.removeStartEdgeU = true; subdivOpt.removeStartEdgeV = true; const subdivPoints = await bitbybit.occt.shapes.face.subdivideToPoints(subdivOpt) const ellipseOpt = new Bit.Inputs.OCCT.EllipseDto(); ellipseOpt.direction = [0, 0, 1]; ellipseOpt.radiusMajor = 1; ellipseOpt.radiusMinor = 0.6; const ellipse = await bitbybit.occt.shapes.wire.createEllipseWire(ellipseOpt); const transformedEllipses = await bitbybit.occt.transforms.translateShapes({ shapes: bitbybit.lists.repeat({ item: ellipse, times: subdivPoints.length }), translations: subdivPoints }); const pointsOfJscadPolygons = await bitbybit.occt.shapes.wire.divideWiresByParamsToPoints({ shapes: transformedEllipses, nrOfDivisions: 20, removeEndPoint: true, removeStartPoint: false, }); const corners = await bitbybit.occt.shapes.edge.getCornerPointsOfEdgesForShape({ shape: square }); pointsOfJscadPolygons.push(corners); const jscadPolygonsPromise = pointsOfJscadPolygons.map(polygonPoints => { return bitbybit.jscad.polygon.createFromPoints({ points: polygonPoints }); }); const jscadPolygons = await Promise.all(jscadPolygonsPromise); bitbybit.jscad.downloadGeometryDxf({ geometry: jscadPolygons, fileName: "ellipses-in-frame" }); const compound = await bitbybit.occt.shapes.compound.makeCompound({ shapes: [...transformedEllipses, square] }); bitbybit.draw.drawAnyAsync({ entity: compound }); bitbybit.draw.drawAnyAsync({ entity: pointsOfJscadPolygons.flat() }) } async function createShape() { } start();