diff --git a/modules/workbenches/modeler/features/primitive_box/index.ts b/modules/workbenches/modeler/features/primitive_box/index.ts index 5f670c9e..e45eeb81 100644 --- a/modules/workbenches/modeler/features/primitive_box/index.ts +++ b/modules/workbenches/modeler/features/primitive_box/index.ts @@ -1,68 +1,84 @@ import { ApplicationContext } from 'context'; -import { MBrepShell } from 'cad/model/mshell'; import { roundValueForPresentation as r } from 'cad/craft/operationHelper'; -import { occ2brep } from 'cad/occ/occ2models'; import icon32 from './icon32.png'; import icon96 from './icon96.png'; - -export default { - id: 'primitive_box', - label: 'primitive_box', - icon: { - iconSet: { - medium: { - iconType: 'image', - iconContent: icon32 - }, - large: { - iconType: 'image', - iconContent: icon96 - } - }, - }, - info: 'primitive_box', - mutualExclusiveFields: [], - paramsInfo: ({ boxX, boxY, boxZ }) => `(${r(boxX)} ${r(boxY)}) ${r(boxZ)})`, - schema: { - boxX: { - type: 'number', - defaultValue: 200, - label: 'X' - }, - boxY: { - type: 'number', - defaultValue: 280, - label: 'Y' - }, - boxZ: { - type: 'number', - defaultValue: 280, - label: 'Z' - }, - }, - - - run: ({ boxX, boxY, boxZ }, ctx: ApplicationContext) => { - //const occObj = createCylinder(diameter, height, ctx.occService.occContext); - const oc = ctx.occService.occContext; - - - let myBody = new oc.BRepPrimAPI_MakeBox_1(boxX, boxY, boxZ); - //let myBody = new oc.BRepPrimAPI_Make - - const aRes = new oc.TopoDS_Compound(); - const aBuilder = new oc.BRep_Builder(); - aBuilder.MakeCompound(aRes); - aBuilder.Add(aRes, myBody.Shape()); +import { MDFCommand } from "cad/mdf/mdf"; +import { EntityKind } from "cad/model/entities"; +import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition"; - const mobject = new MBrepShell(occ2brep(aRes, ctx.occService.occContext)); - return { - consumed: [], - created: [mobject] - }; - }, +interface PrimitiveBoxParams { + x: Number, + y: Number, + z: Number, + locations: {}, + boolean: BooleanDefinition, } +const PrimitiveBoxOperation: MDFCommand = { + id: 'primitive_box', + label: 'Primitive Box', + icon: 'img/cad/extrude', + info: 'Primitive Box', + paramsInfo: ({ x, y, z }) => `(${r(x)} , ${r(y)} , ${r(z)})`, + form: [ + { + type: 'number', + label: 'X', + name: 'x', + defaultValue: 50, + }, + { + type: 'number', + label: 'Y', + name: 'y', + defaultValue: 50, + }, + { + type: 'number', + label: 'Z', + name: 'z', + defaultValue: 50, + }, + { + type: 'selection', + name: 'locations', + capture: [EntityKind.DATUM], + label: 'locations', + multi: false, + optional: true, + defaultValue: { + usePreselection: true, + preselectionIndex: 0 + }, + }, + + { + type: 'boolean', + name: 'boolean', + label: 'boolean', + optional: true, + } + + ], + + + + + + run: (params: PrimitiveBoxParams, ctx: ApplicationContext) => { + + let occ = ctx.occService; + const oci = occ.commandInterface; + + + oci.box("b", "20", "20", "20"); + + return occ.utils.applyBooleanModifier(["b"], params.boolean); + + }, +} + +export default PrimitiveBoxOperation; \ No newline at end of file