diff --git a/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts b/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts new file mode 100644 index 00000000..696396da --- /dev/null +++ b/modules/workbenches/modeler/actions/getInfo/getInfo.action.ts @@ -0,0 +1,71 @@ +import {MShell} from "cad/model/mshell"; +import {ApplicationContext} from "cad/context"; +import {EntityKind} from "cad/model/entities"; +import {ActionDefinition} from "cad/actions/actionSystemBundle"; +import { MEdge } from "cad/model/medge"; + + +interface GetInfoParams { + targetBody: MShell | MEdge; +} + +export const GetInfo: any = { + id: 'GET_INFO', + label: 'OBJECT INFO', + icon: 'img/cad/extrude', + info: 'extrudes 2D sketch', + path:__dirname, + run: (params: GetInfoParams, ctx: ApplicationContext) => { + console.log("this is it", this) + const occ = ctx.occService; + const oci = occ.commandInterface; + + const targetBody = params.targetBody; + + let resultingMessage = ""; + + + if (targetBody.TYPE === EntityKind.EDGE){ + resultingMessage = "Edge Length = "+ targetBody.brepEdge.curve.impl.verb.length().toFixed(4); + } + if (targetBody.TYPE === EntityKind.SHELL){ + let listOfOutputs = []; + const out_old = out; + out = function(msg) { + listOfOutputs.push(msg); + //alert(JSON.stringify(msg)); + out_old(msg); + } + + oci.vprops(params.targetBody); + + out = out_old; + + + const resultingVolumeArray = listOfOutputs.filter(function (str) { return str.includes("Mass") }); + resultingMessage = "Volume = " + resultingVolumeArray[0].trim().replace(' ', '').replace("Mass:","").trim(); + } + + + + + throw {userMessage: resultingMessage}; + return; + }, + + + + form: [ + { + type: 'selection', + name: 'targetBody', + capture: [EntityKind.SHELL, EntityKind.EDGE], + label: 'Body', + multi: false, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + ], +} diff --git a/modules/workbenches/modeler/actions/getVolume/getVolume.action.ts b/modules/workbenches/modeler/actions/getVolume/getVolume.action.ts deleted file mode 100644 index 38fcb12c..00000000 --- a/modules/workbenches/modeler/actions/getVolume/getVolume.action.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {MShell} from "cad/model/mshell"; -import {ApplicationContext} from "cad/context"; -import {EntityKind} from "cad/model/entities"; -import {ActionDefinition} from "cad/actions/actionSystemBundle"; - - -interface getVolumeParams { - targetBody: MShell; -} - -export const GetVolume: any = { - id: 'GET_VOLUME', - label: 'VOLUME', - icon: 'img/cad/extrude', - info: 'extrudes 2D sketch', - path:__dirname, - run: (params: getVolumeParams, ctx: ApplicationContext) => { - - const occ = ctx.services.OCCService; - const oci = occ.commandInterface; - - alert(); - - return; - }, - - - - form: [ - { - type: 'selection', - name: 'targetBody', - capture: [EntityKind.SHELL], - label: 'Body', - multi: false, - defaultValue: { - usePreselection: true, - preselectionIndex: 0 - }, - }, - ], -} diff --git a/modules/workbenches/modeler/index.ts b/modules/workbenches/modeler/index.ts index af3e3bd8..c0a363e5 100644 --- a/modules/workbenches/modeler/index.ts +++ b/modules/workbenches/modeler/index.ts @@ -23,6 +23,8 @@ import {DeleteBodyOperation} from "./features/deleteBody/deleteBody.operation"; import {DefeatureRemoveFaceOperation} from "./features/defeatureRemoveFace/defeatureRemoveFace.operation"; import { WireLineOperation } from "./features/wireLine/wireLine"; //imports of action type commands +import {GetInfo} from "./actions/getInfo/getInfo.action"; +//import workbench icon import {GiCubes} from "react-icons/gi"; @@ -51,9 +53,11 @@ export const ModelerWorkspace: WorkbenchConfig = { DeleteBodyOperation, DefeatureRemoveFaceOperation, WireLineOperation, + + GetInfo, ], actions: [ - // GetVolume, + //GetVolume, ], ui: { toolbar: [ @@ -69,7 +73,7 @@ export const ModelerWorkspace: WorkbenchConfig = { "CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-", - "HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL", "DELETE_BODY", "-", + "HOLE_TOOL", "-", 'GET_INFO', "IMPORT_MODEL", "DELETE_BODY", "-", "WIRE_LINE" ]