mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-08 01:13:27 +01:00
Fix broken import brep functionality.
This commit is contained in:
parent
d4cb720f7e
commit
d66214f21a
1 changed files with 18 additions and 14 deletions
|
|
@ -33,33 +33,37 @@ export const ImportModelOpperation: OperationDescriptor<ImportModelParams> = {
|
||||||
const FileName = params.file.fileName.toUpperCase()
|
const FileName = params.file.fileName.toUpperCase()
|
||||||
|
|
||||||
if (FileName.endsWith("BRP") || FileName.endsWith("BREP")) {
|
if (FileName.endsWith("BRP") || FileName.endsWith("BREP")) {
|
||||||
|
let fileToRead = atob(params.file.content.slice(params.file.content.indexOf(',') + 1));
|
||||||
|
|
||||||
|
console.log(fileToRead);
|
||||||
//FreeCAD some times omits this text from the top of BRP files
|
//FreeCAD some times omits this text from the top of BRP files
|
||||||
//as part of the brp files stored in the .FCStf file archive format
|
//as part of the brp files stored in the .FCStf file archive format
|
||||||
if (!params.file.content.startsWith("DBRep_DrawableShape")) {
|
if (!fileToRead.startsWith("DBRep_DrawableShape")) {
|
||||||
params.file.content = `DBRep_DrawableShape\n` + params.file.content;
|
fileToRead = `DBRep_DrawableShape\n` + fileToRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS.writeFile("newBREPobject", (params.file.content));
|
FS.writeFile("newBREPobject", (fileToRead));
|
||||||
oci.readbrep("newBREPobject", "newBREPobject");
|
oci.readbrep("newBREPobject", "newBREPobject");
|
||||||
returnObject.created.push(occ.io.getShell("newBREPobject"));
|
returnObject.created.push(occ.io.getShell("newBREPobject"));
|
||||||
} else if (FileName.endsWith("FCSTD")) {
|
} else if (FileName.endsWith("FCSTD")) {
|
||||||
|
const archiveData = params.file.content.slice(params.file.content.indexOf(',') + 1);
|
||||||
|
var JSZip = require("jszip");
|
||||||
|
|
||||||
//Add code here to extract zip file
|
const zipContents = await (await JSZip.loadAsync(archiveData, { base64: true })).files;
|
||||||
|
var xmlFreeCADData = await zipContents["GuiDocument.xml"].async("string");
|
||||||
let xmlFreeCADData = "";
|
|
||||||
//add code here to read contents of GuiDocument.xml in to xmlFreeCADData
|
|
||||||
|
|
||||||
let DecodedXmlFreeCADData = await parseStringPromise(xmlFreeCADData);
|
let DecodedXmlFreeCADData = await parseStringPromise(xmlFreeCADData);
|
||||||
DecodedXmlFreeCADData = (JSON.parse(JSON.stringify(DecodedXmlFreeCADData)));
|
DecodedXmlFreeCADData = (JSON.parse(JSON.stringify(DecodedXmlFreeCADData)));
|
||||||
console.log(JSON.stringify(DecodedXmlFreeCADData));
|
console.log(DecodedXmlFreeCADData);
|
||||||
|
|
||||||
//add code here to determin what specfic brp files from within
|
|
||||||
//the archive have the property "Visibility" set as true.
|
|
||||||
|
|
||||||
//Only import objects that have "Visisbility" set as true
|
|
||||||
//withthe same code as above for importing .brp type files.
|
|
||||||
|
|
||||||
|
for (const property in zipContents) {
|
||||||
|
if (property.endsWith("brp")){
|
||||||
|
FS.writeFile(property, `DBRep_DrawableShape\n` + await zipContents[property].async("string"));
|
||||||
|
oci.readbrep(property, property);
|
||||||
|
returnObject.created.push(occ.io.getShell(property));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(zipContents);
|
||||||
} else if (FileName.endsWith("STEP") || FileName.endsWith("STP")) {
|
} else if (FileName.endsWith("STEP") || FileName.endsWith("STP")) {
|
||||||
|
|
||||||
//step Import
|
//step Import
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue