mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-23 17:04:00 +01:00
updated primitive box command with UI fields
This commit is contained in:
parent
b47957a40b
commit
1de5a7b785
1 changed files with 74 additions and 58 deletions
|
|
@ -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<PrimitiveBoxParams> = {
|
||||
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;
|
||||
Loading…
Reference in a new issue