From 8eebfcda86ebd6452d2d41dd5b9d2a2f58b31fc0 Mon Sep 17 00:00:00 2001 From: Mike Molinari Date: Thu, 7 Apr 2022 19:55:45 +0000 Subject: [PATCH] Added scale body feature, removed non working offset face feature. --- .../offsetFace/offsetFace.operation.ts | 65 ------------------- .../{offsetFace => scaleBody}/docs/index.md | 0 .../features/scaleBody/scaleBody.operation.ts | 64 ++++++++++++++++++ modules/workbenches/modeler/index.ts | 6 +- 4 files changed, 67 insertions(+), 68 deletions(-) delete mode 100644 modules/workbenches/modeler/features/offsetFace/offsetFace.operation.ts rename modules/workbenches/modeler/features/{offsetFace => scaleBody}/docs/index.md (100%) create mode 100644 modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts diff --git a/modules/workbenches/modeler/features/offsetFace/offsetFace.operation.ts b/modules/workbenches/modeler/features/offsetFace/offsetFace.operation.ts deleted file mode 100644 index eb9591e1..00000000 --- a/modules/workbenches/modeler/features/offsetFace/offsetFace.operation.ts +++ /dev/null @@ -1,65 +0,0 @@ -import {roundValueForPresentation as r} from 'cad/craft/operationHelper'; -import {MFace} from "cad/model/mface"; -import {ApplicationContext} from "context"; -import {EntityKind} from "cad/model/entities"; -import {OperationDescriptor} from "cad/craft/operationPlugin"; - - -interface offsetParams { - distance: number; - faces: [MFace]; -} - -export const offsetOperation: OperationDescriptor = { - id: 'OFFSET_TOOL', - label: 'offset', - icon: 'img/cad/offset', - info: 'offset faces', - paramsInfo: ({distance}) => `(${r(distance)})`, - run: (params: offsetParams, ctx: ApplicationContext) => { - console.log(params); - let occ = ctx.occService; - const oci = occ.commandInterface; - - - var bodiesTooffset = []; - var returnObject = { - consumed: [], - created: [] - }; - - //add all the edges and size to seperate arrays for each offset that edges are selected from - - params.faces.forEach((face) => { - const newFaceId = face.id + ":offset"; - - oci.offset(newFaceId,face,params.distance); - returnObject.created.push(occ.io.getShell(newFaceId)); - }); - - - console.log(returnObject); - - return returnObject; - - }, - form: [ - { - type: 'selection', - name: 'faces', - capture: [EntityKind.FACE], - label: 'faces', - multi: true, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - { - type: 'number', - name: 'distance', - label: 'distance', - defaultValue: 5, - }, - ], -} diff --git a/modules/workbenches/modeler/features/offsetFace/docs/index.md b/modules/workbenches/modeler/features/scaleBody/docs/index.md similarity index 100% rename from modules/workbenches/modeler/features/offsetFace/docs/index.md rename to modules/workbenches/modeler/features/scaleBody/docs/index.md diff --git a/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts b/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts new file mode 100644 index 00000000..e7d2797c --- /dev/null +++ b/modules/workbenches/modeler/features/scaleBody/scaleBody.operation.ts @@ -0,0 +1,64 @@ +import { CSys } from 'math/csys'; +import { MShell } from 'cad/model/mshell'; +import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; +import { MFace } from "cad/model/mface"; +import { ApplicationContext } from "context"; +import { EntityKind } from "cad/model/entities"; +import { OperationDescriptor } from "cad/craft/operationPlugin"; + + +interface scaleParams { + distance: number; + shells: [MShell]; +} + +export const ScaleOperation: OperationDescriptor = { + id: 'SCALE_BODY', + label: 'Scale', + icon: 'img/cad/scale', + info: 'Scale Body', + paramsInfo: ({ distance }) => `(${r(distance)})`, + run: (params: scaleParams, ctx: ApplicationContext) => { + console.log(params); + let occ = ctx.occService; + const oci = occ.commandInterface; + + var returnObject = { + consumed: params.shells, + created: [] + }; + + + params.shells.forEach((currentShell) => { + const newShellId = currentShell.id + ":scaled"; + oci.copy(currentShell, newShellId); + oci.tscale(newShellId, currentShell.csys.x, currentShell.csys.y, currentShell.csys.z, params.distance); + returnObject.created.push(occ.io.getShell(newShellId)); + }); + + + console.log(returnObject); + + return returnObject; + + }, + form: [ + { + type: 'selection', + name: 'shells', + capture: [EntityKind.SHELL], + label: 'shells', + multi: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + { + type: 'number', + name: 'distance', + label: 'distance', + defaultValue: 5, + }, + ], +} diff --git a/modules/workbenches/modeler/index.ts b/modules/workbenches/modeler/index.ts index ae20ac80..8545b501 100644 --- a/modules/workbenches/modeler/index.ts +++ b/modules/workbenches/modeler/index.ts @@ -14,7 +14,7 @@ import { BooleanOperation } from "./features/boolean/boolean.operation"; import { RevolveOperation } from "./features/revolve/revolve.operation"; import { ShellOperation } from "./features/shell/shell.operation"; import { SweepOperation } from "./features/sweep/sweep.operation"; -import { offsetOperation } from "./features/offsetFace/offsetFace.operation"; +import { ScaleOperation } from "./features/scaleBody/scaleBody.operation"; import { MirrorBodyOperation} from "./features/mirrorBody/mirrorBody.operation"; //imports of action type commands @@ -38,7 +38,7 @@ export const ModelerWorkspace: WorkbenchConfig = { ShellOperation, LoftOperation, SweepOperation, - offsetOperation, + ScaleOperation, MirrorBodyOperation ], actions: [GetVolume], @@ -47,7 +47,7 @@ export const ModelerWorkspace: WorkbenchConfig = { 'DATUM_CREATE', 'PLANE', 'EditFace', '-', "EXTRUDE", "REVOLVE", "LOFT", "SWEEP", "-", "BOOLEAN", "-", - "SHELL_TOOL", "FILLET_TOOL", "OFFSET_TOOL", "MIRROR_BODY", "-", + "SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY", "MIRROR_BODY", "-", "CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-", "HOLE_TOOL", "-", 'GET_VOLUME', ]