a few changes to the sheet metal environment

This commit is contained in:
Mike Molinari 2022-11-23 23:34:08 +00:00
parent dc96c9becf
commit dca7f574e9
2 changed files with 49 additions and 23 deletions

View file

@ -6,13 +6,22 @@ import { BooleanDefinition, BooleanKind } from "cad/craft/schema/common/BooleanD
import Axis from "math/axis";
import { OperationDescriptor } from "cad/craft/operationBundle";
interface smFlangeParams {
angle: number;
face: MFace;
flip: boolean;
boolean: BooleanDefinition;
}
const ROLE_TO_SM_KIND = {
'base': 'FLAT/A',
'lid': 'FLAT/B',
'sweep': 'THICKNESS'
}
export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
id: 'SM_FLANGE',
label: 'Flange',
@ -34,7 +43,7 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
for (let i = 0; i < face.edges.length; i++) {
const edgeKind = face.edges[i].productionInfo.sheetMetal.kind;
if (edgeKind == "FLAT/A" && !params.flip) {
revolveVector = face.edges[i].toAxis();
revolveVector = face.edges[i].location;
revolveVectorOrigin = revolveVector.origin;
revolveVectorDirection = revolveVector.direction.negate();
revolveVectorOrigin.z -=2;
@ -75,19 +84,22 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
});
});
return {
created: tools,
consumed: []
}
const operationResult = occ.utils.applyBooleanModifier(tools, params.boolean, face, [face]);
operationResult.created.forEach(shell => {
shell.traverse(obj => {
if (obj.productionInfo?.role) {
obj.productionInfo.sheetMetal = {
kind: ROLE_TO_SM_KIND[obj.productionInfo.role]
}
}
})
});
return operationResult;
},
form: [
{
type: 'number',
label: 'angle',
name: 'angle',
defaultValue: 90,
},
{
type: 'selection',
name: 'face',
@ -99,11 +111,24 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
preselectionIndex: 0
},
},
{
type: 'number',
label: 'angle',
name: 'angle',
defaultValue: 90,
},
{
type: 'checkbox',
label: 'Flip Direction',
name: 'flip',
defaultValue: false,
},
{
type: 'boolean',
name: 'boolean',
label: 'boolean',
optional: true,
}
],
}

View file

@ -83,6 +83,17 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
form: [
{
type: 'selection',
name: 'sketch',
capture: [EntityKind.FACE],
label: 'Sketch',
multi: false,
defaultValue: {
usePreselection: true,
preselectionIndex: 0
},
},
{
type: 'number',
label: 'Thickness',
@ -107,17 +118,7 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
name: 'flipper',
defaultValue: false,
},
{
type: 'selection',
name: 'sketch',
capture: [EntityKind.FACE],
label: 'Sketch',
multi: false,
defaultValue: {
usePreselection: true,
preselectionIndex: 0
},
},
{
type: 'boolean',
name: 'boolean',