diff --git a/modules/workbenches/modeler/features/moveBody/docs/index.md b/modules/workbenches/modeler/features/moveBody/docs/index.md new file mode 100644 index 00000000..e332fb6d --- /dev/null +++ b/modules/workbenches/modeler/features/moveBody/docs/index.md @@ -0,0 +1 @@ +place holder \ No newline at end of file diff --git a/modules/workbenches/modeler/features/moveBody/moveBody.operation.ts b/modules/workbenches/modeler/features/moveBody/moveBody.operation.ts new file mode 100644 index 00000000..c5630374 --- /dev/null +++ b/modules/workbenches/modeler/features/moveBody/moveBody.operation.ts @@ -0,0 +1,68 @@ +import {ApplicationContext} from "cad/context"; +import {EntityKind} from "cad/model/entities"; +import {OperationDescriptor} from "cad/craft/operationBundle"; +import {SetLocation} from "cad/craft/e0/interact"; +import {MDatum} from "cad/model/mdatum"; +import { MShell } from 'cad/model/mshell'; + +interface MoveBodyParams { + datum: MDatum; + body: MShell; +} + +export const MoveBodyOperation: OperationDescriptor = { + id: 'MOVE_BODY', + label: 'Move Body', + icon: 'img/cad/moveBody', + info: 'Move Body', + path:__dirname, + paramsInfo: () => '', + + run: (params: MoveBodyParams, ctx: ApplicationContext) => { + const occ = ctx.occService; + const oci = occ.commandInterface; + + console.log(params); + const returnObject = { + consumed: [params.body], + created: [] + }; + const location = params.datum.csys.outTransformation._normalize(); + + const newShellName = params.body.id+":T"; + + oci.copy(params.body, newShellName); + + SetLocation(newShellName, location.toFlatArray()); + returnObject.created.push(occ.io.getShell(newShellName)); + + return returnObject; + + }, + form: [ + { + type: 'selection', + name: 'datum', + capture: [EntityKind.DATUM], + label: 'Sketch', + multi: false, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + + { + type: 'selection', + name: 'body', + capture: [EntityKind.SHELL], + label: 'body', + multi: false, + defaultValue: { + usePreselection: true, + preselectionIndex: 1 + }, + }, + + ], +} diff --git a/modules/workbenches/modeler/index.ts b/modules/workbenches/modeler/index.ts index 5240cd50..371a6723 100644 --- a/modules/workbenches/modeler/index.ts +++ b/modules/workbenches/modeler/index.ts @@ -22,6 +22,7 @@ import {ImportModelOperation} from "./features/importModel/importModel.operation import {DeleteBodyOperation} from "./features/deleteBody/deleteBody.operation"; import {DefeatureRemoveFaceOperation} from "./features/defeatureRemoveFace/defeatureRemoveFace.operation"; import { WireLineOperation } from "./features/wireLine/wireLine"; +import { MoveBodyOperation } from "./features/moveBody/moveBody.operation" //imports of action type commands import {GetInfo} from "./actions/getInfo/getInfo.action"; import {ExportBREP} from "./actions/exportBREP/exportBREP.action"; @@ -54,6 +55,7 @@ export const ModelerWorkspace: WorkbenchConfig = { DeleteBodyOperation, DefeatureRemoveFaceOperation, WireLineOperation, + MoveBodyOperation, GetInfo, ExportBREP, @@ -71,7 +73,7 @@ export const ModelerWorkspace: WorkbenchConfig = { "SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY", "DEFEATURE_REMOVE_FACE", "-", - "MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-", + "MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "MOVE_BODY" ,"-", "CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",