mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-24 01:15:25 +01:00
Added scale body feature, removed non working offset face feature.
This commit is contained in:
parent
24e8a1a501
commit
8eebfcda86
4 changed files with 67 additions and 68 deletions
|
|
@ -1,65 +0,0 @@
|
|||
import {roundValueForPresentation as r} from 'cad/craft/operationHelper';
|
||||
import {MFace} from "cad/model/mface";
|
||||
import {ApplicationContext} from "context";
|
||||
import {EntityKind} from "cad/model/entities";
|
||||
import {OperationDescriptor} from "cad/craft/operationPlugin";
|
||||
|
||||
|
||||
interface offsetParams {
|
||||
distance: number;
|
||||
faces: [MFace];
|
||||
}
|
||||
|
||||
export const offsetOperation: OperationDescriptor<offsetParams> = {
|
||||
id: 'OFFSET_TOOL',
|
||||
label: 'offset',
|
||||
icon: 'img/cad/offset',
|
||||
info: 'offset faces',
|
||||
paramsInfo: ({distance}) => `(${r(distance)})`,
|
||||
run: (params: offsetParams, ctx: ApplicationContext) => {
|
||||
console.log(params);
|
||||
let occ = ctx.occService;
|
||||
const oci = occ.commandInterface;
|
||||
|
||||
|
||||
var bodiesTooffset = [];
|
||||
var returnObject = {
|
||||
consumed: [],
|
||||
created: []
|
||||
};
|
||||
|
||||
//add all the edges and size to seperate arrays for each offset that edges are selected from
|
||||
|
||||
params.faces.forEach((face) => {
|
||||
const newFaceId = face.id + ":offset";
|
||||
|
||||
oci.offset(newFaceId,face,params.distance);
|
||||
returnObject.created.push(occ.io.getShell(newFaceId));
|
||||
});
|
||||
|
||||
|
||||
console.log(returnObject);
|
||||
|
||||
return returnObject;
|
||||
|
||||
},
|
||||
form: [
|
||||
{
|
||||
type: 'selection',
|
||||
name: 'faces',
|
||||
capture: [EntityKind.FACE],
|
||||
label: 'faces',
|
||||
multi: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'distance',
|
||||
label: 'distance',
|
||||
defaultValue: 5,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
import { CSys } from 'math/csys';
|
||||
import { MShell } from 'cad/model/mshell';
|
||||
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||
import { MFace } from "cad/model/mface";
|
||||
import { ApplicationContext } from "context";
|
||||
import { EntityKind } from "cad/model/entities";
|
||||
import { OperationDescriptor } from "cad/craft/operationPlugin";
|
||||
|
||||
|
||||
interface scaleParams {
|
||||
distance: number;
|
||||
shells: [MShell];
|
||||
}
|
||||
|
||||
export const ScaleOperation: OperationDescriptor<scaleParams> = {
|
||||
id: 'SCALE_BODY',
|
||||
label: 'Scale',
|
||||
icon: 'img/cad/scale',
|
||||
info: 'Scale Body',
|
||||
paramsInfo: ({ distance }) => `(${r(distance)})`,
|
||||
run: (params: scaleParams, ctx: ApplicationContext) => {
|
||||
console.log(params);
|
||||
let occ = ctx.occService;
|
||||
const oci = occ.commandInterface;
|
||||
|
||||
var returnObject = {
|
||||
consumed: params.shells,
|
||||
created: []
|
||||
};
|
||||
|
||||
|
||||
params.shells.forEach((currentShell) => {
|
||||
const newShellId = currentShell.id + ":scaled";
|
||||
oci.copy(currentShell, newShellId);
|
||||
oci.tscale(newShellId, currentShell.csys.x, currentShell.csys.y, currentShell.csys.z, params.distance);
|
||||
returnObject.created.push(occ.io.getShell(newShellId));
|
||||
});
|
||||
|
||||
|
||||
console.log(returnObject);
|
||||
|
||||
return returnObject;
|
||||
|
||||
},
|
||||
form: [
|
||||
{
|
||||
type: 'selection',
|
||||
name: 'shells',
|
||||
capture: [EntityKind.SHELL],
|
||||
label: 'shells',
|
||||
multi: true,
|
||||
defaultValue: {
|
||||
usePreselection: true,
|
||||
preselectionIndex: 0
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: 'distance',
|
||||
label: 'distance',
|
||||
defaultValue: 5,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import { BooleanOperation } from "./features/boolean/boolean.operation";
|
|||
import { RevolveOperation } from "./features/revolve/revolve.operation";
|
||||
import { ShellOperation } from "./features/shell/shell.operation";
|
||||
import { SweepOperation } from "./features/sweep/sweep.operation";
|
||||
import { offsetOperation } from "./features/offsetFace/offsetFace.operation";
|
||||
import { ScaleOperation } from "./features/scaleBody/scaleBody.operation";
|
||||
import { MirrorBodyOperation} from "./features/mirrorBody/mirrorBody.operation";
|
||||
|
||||
//imports of action type commands
|
||||
|
|
@ -38,7 +38,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
ShellOperation,
|
||||
LoftOperation,
|
||||
SweepOperation,
|
||||
offsetOperation,
|
||||
ScaleOperation,
|
||||
MirrorBodyOperation
|
||||
],
|
||||
actions: [GetVolume],
|
||||
|
|
@ -47,7 +47,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
'DATUM_CREATE', 'PLANE', 'EditFace', '-',
|
||||
"EXTRUDE", "REVOLVE", "LOFT", "SWEEP", "-",
|
||||
"BOOLEAN", "-",
|
||||
"SHELL_TOOL", "FILLET_TOOL", "OFFSET_TOOL", "MIRROR_BODY", "-",
|
||||
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY", "MIRROR_BODY", "-",
|
||||
"CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",
|
||||
"HOLE_TOOL", "-", 'GET_VOLUME',
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue