mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
a few changes to the sheet metal environment
This commit is contained in:
parent
dc96c9becf
commit
dca7f574e9
2 changed files with 49 additions and 23 deletions
|
|
@ -6,13 +6,22 @@ import { BooleanDefinition, BooleanKind } from "cad/craft/schema/common/BooleanD
|
||||||
import Axis from "math/axis";
|
import Axis from "math/axis";
|
||||||
import { OperationDescriptor } from "cad/craft/operationBundle";
|
import { OperationDescriptor } from "cad/craft/operationBundle";
|
||||||
|
|
||||||
|
|
||||||
interface smFlangeParams {
|
interface smFlangeParams {
|
||||||
angle: number;
|
angle: number;
|
||||||
face: MFace;
|
face: MFace;
|
||||||
flip: boolean;
|
flip: boolean;
|
||||||
|
boolean: BooleanDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const ROLE_TO_SM_KIND = {
|
||||||
|
'base': 'FLAT/A',
|
||||||
|
'lid': 'FLAT/B',
|
||||||
|
'sweep': 'THICKNESS'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
|
export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
|
||||||
id: 'SM_FLANGE',
|
id: 'SM_FLANGE',
|
||||||
label: 'Flange',
|
label: 'Flange',
|
||||||
|
|
@ -34,7 +43,7 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
|
||||||
for (let i = 0; i < face.edges.length; i++) {
|
for (let i = 0; i < face.edges.length; i++) {
|
||||||
const edgeKind = face.edges[i].productionInfo.sheetMetal.kind;
|
const edgeKind = face.edges[i].productionInfo.sheetMetal.kind;
|
||||||
if (edgeKind == "FLAT/A" && !params.flip) {
|
if (edgeKind == "FLAT/A" && !params.flip) {
|
||||||
revolveVector = face.edges[i].toAxis();
|
revolveVector = face.edges[i].location;
|
||||||
revolveVectorOrigin = revolveVector.origin;
|
revolveVectorOrigin = revolveVector.origin;
|
||||||
revolveVectorDirection = revolveVector.direction.negate();
|
revolveVectorDirection = revolveVector.direction.negate();
|
||||||
revolveVectorOrigin.z -=2;
|
revolveVectorOrigin.z -=2;
|
||||||
|
|
@ -75,19 +84,22 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
const operationResult = occ.utils.applyBooleanModifier(tools, params.boolean, face, [face]);
|
||||||
created: tools,
|
|
||||||
consumed: []
|
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: [
|
form: [
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
label: 'angle',
|
|
||||||
name: 'angle',
|
|
||||||
defaultValue: 90,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'selection',
|
type: 'selection',
|
||||||
name: 'face',
|
name: 'face',
|
||||||
|
|
@ -99,11 +111,24 @@ export const smFlangeOperation: OperationDescriptor<smFlangeParams> = {
|
||||||
preselectionIndex: 0
|
preselectionIndex: 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'number',
|
||||||
|
label: 'angle',
|
||||||
|
name: 'angle',
|
||||||
|
defaultValue: 90,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
label: 'Flip Direction',
|
label: 'Flip Direction',
|
||||||
name: 'flip',
|
name: 'flip',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
type: 'boolean',
|
||||||
|
name: 'boolean',
|
||||||
|
label: 'boolean',
|
||||||
|
optional: true,
|
||||||
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,17 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
|
||||||
|
|
||||||
|
|
||||||
form: [
|
form: [
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
name: 'sketch',
|
||||||
|
capture: [EntityKind.FACE],
|
||||||
|
label: 'Sketch',
|
||||||
|
multi: false,
|
||||||
|
defaultValue: {
|
||||||
|
usePreselection: true,
|
||||||
|
preselectionIndex: 0
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'number',
|
type: 'number',
|
||||||
label: 'Thickness',
|
label: 'Thickness',
|
||||||
|
|
@ -107,17 +118,7 @@ export const smTabOperation: OperationDescriptor<smTabParams> = {
|
||||||
name: 'flipper',
|
name: 'flipper',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: 'selection',
|
|
||||||
name: 'sketch',
|
|
||||||
capture: [EntityKind.FACE],
|
|
||||||
label: 'Sketch',
|
|
||||||
multi: false,
|
|
||||||
defaultValue: {
|
|
||||||
usePreselection: true,
|
|
||||||
preselectionIndex: 0
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
name: 'boolean',
|
name: 'boolean',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue