mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-20 07:22:38 +01:00
added support to import brp and brep files
This commit is contained in:
parent
47eef69f93
commit
c306f2f1bb
4 changed files with 80 additions and 4 deletions
|
|
@ -0,0 +1,13 @@
|
|||
# BOOLEAN OPPERATIONS
|
||||
Boolean operations allow for solids to be used as tools to shape and modify other solids.
|
||||
|
||||
# UNION
|
||||
Union allows solids to be combined to create a new solid.
|
||||
|
||||
# SUBTRACT
|
||||
Subtract allows one solid to be used as a cuttong tool for another sold. Usefull for making hole features.
|
||||
Selection A will have selection B removed from it.
|
||||
|
||||
# INTERSECTION
|
||||
Intersection allows for the creation of a new solid in the space where 2 exising solids overlap.
|
||||
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
import { roundValueForPresentation as r } from 'cad/craft/operationHelper';
|
||||
import { ApplicationContext } from "context";
|
||||
import { EntityKind } from "cad/model/entities";
|
||||
import { BooleanDefinition } from "cad/craft/schema/common/BooleanDefinition";
|
||||
import { OperationDescriptor } from "cad/craft/operationPlugin";
|
||||
import { param } from 'cypress/types/jquery';
|
||||
import { MObject } from 'cad/model/mobject';
|
||||
import { LocalFile } from "ui/components/controls/FileControl";
|
||||
import CadError from "../../../../../web/app/utils/errors";
|
||||
|
||||
interface ImportModelParams {
|
||||
file: LocalFile;
|
||||
}
|
||||
|
||||
export const ImportModelOpperation: OperationDescriptor<ImportModelParams> = {
|
||||
id: 'IMPORT_MODEL',
|
||||
label: 'Import',
|
||||
icon: 'img/cad/intersection',
|
||||
info: 'Imports STEP, BREP or FCStd file',
|
||||
paramsInfo: ({ }) => `()`,
|
||||
run: async (params: ImportModelParams, ctx: ApplicationContext) => {
|
||||
console.log(params);
|
||||
let occ = ctx.occService;
|
||||
const oci = occ.commandInterface;
|
||||
|
||||
let returnObject = { created: [], consumed: [] };
|
||||
|
||||
const FileName = params.file.fileName.toUpperCase()
|
||||
|
||||
if (FileName.endsWith("BRP") || FileName.endsWith("BREP")) {
|
||||
alert("Importing BREP file");
|
||||
|
||||
if (!params.file.content.startsWith("DBRep_DrawableShape")) {
|
||||
params.file.content = `DBRep_DrawableShape\n` + params.file.content;
|
||||
}
|
||||
|
||||
await FS.writeFile("newStepObject", await (params.file.content));
|
||||
oci.readbrep("newStepObject", "newStepObject");
|
||||
returnObject.created.push(occ.io.getShell("newStepObject"));
|
||||
} else {
|
||||
throw new CadError({
|
||||
kind: CadError.KIND.INVALID_INPUT,
|
||||
code: 'File type not supported at this time'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return returnObject;
|
||||
|
||||
},
|
||||
form: [
|
||||
{
|
||||
type: 'file',
|
||||
name: 'file',
|
||||
label: 'Select File',
|
||||
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -16,8 +16,9 @@ import { ShellOperation } from "./features/shell/shell.operation";
|
|||
import { SweepOperation } from "./features/sweep/sweep.operation";
|
||||
import { ScaleOperation } from "./features/scaleBody/scaleBody.operation";
|
||||
import { MirrorBodyOperation} from "./features/mirrorBody/mirrorBody.operation";
|
||||
import { PatternLinearOperation } from "./features/patternLinear/patternLinear.operation"
|
||||
import { PatternRadialOperation } from "./features/patternRadial/patternRadial.operation"
|
||||
import { PatternLinearOperation } from "./features/patternLinear/patternLinear.operation";
|
||||
import { PatternRadialOperation } from "./features/patternRadial/patternRadial.operation";
|
||||
import { ImportModelOpperation } from "./features/importModel/importModel.operation";
|
||||
//imports of action type commands
|
||||
import { GetVolume } from './actions/getVolume/getVolume.action';
|
||||
import {GiCubes} from "react-icons/gi";
|
||||
|
|
@ -44,6 +45,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
MirrorBodyOperation,
|
||||
PatternLinearOperation,
|
||||
PatternRadialOperation,
|
||||
ImportModelOpperation,
|
||||
],
|
||||
actions: [],
|
||||
ui: {
|
||||
|
|
@ -54,7 +56,7 @@ export const ModelerWorkspace: WorkbenchConfig = {
|
|||
"SHELL_TOOL", "FILLET_TOOL", "SCALE_BODY","-",
|
||||
"MIRROR_BODY", "PATTERN_LINEAR", "PATTERN_RADIAL", "-",
|
||||
"CYLINDER", "BOX", "CONE", "SPHERE", "TORUS", "-",
|
||||
"HOLE_TOOL", "-", 'GET_VOLUME',
|
||||
"HOLE_TOOL", "-", 'GET_VOLUME', "IMPORT_MODEL"
|
||||
]
|
||||
},
|
||||
icon: GiCubes
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ function SelectedModificationInfo({ history, index,
|
|||
onClose={close}>
|
||||
<div className={ls.requestInfo}>
|
||||
<ImgIcon className={ls.pic} url={appearance && appearance.icon96} size={48}/>
|
||||
<RenderObject object={m.params}/>
|
||||
{/*<RenderObject object={m.params}/>*/}
|
||||
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue